<p align="center">
<img src="https://github.com/user-attachments/assets/ad569d6e-1e01-407c-a282-3e3d2abb97dd" width="200" alt="yggdrasil logo"/>
</p>
<h1 align="center"> Yggdrasil</h1>
<p align="center">
<strong>The god-tree of your codebase</strong><br/>
Flatten your entire project into an AI-ready codex β index + contents, in one command.
</p>
---
## π€ What is Yggdrasil?
Yggdrasil CLI is a **project flattener and diff tool**:
it takes your codebase and transforms it into a single, structured document β or compares snapshots with rich, annotated diffs.
Think of it as **`tree` + `cat` + `diff`**, but with superpowers:
- π **Files** β indexed, filtered by extension, glob, or blacklist.
- π **Contents** β full text for each file, neatly marked.
- π **Anchors** β clickable links from index β content (Markdown mode).
- π¨ **Stylish CLI** β cyberpunk colors, or plain mode for piping.
- π‘ **Controls** β `--only`, `--ignore`, `--black`, `--white`, `--out`.
βͺ `--black` / `--white` accept either a **file path** *or* launch an **interactive paste mode** β perfect for dropping in VS Codeβs *Copy Relative Path* output.
- π§© **Diff Mode** β cross-file block detection with `[MOVED]` annotations.
- π **Align Tags** β `--align-tags` keeps metadata comments lined up.
---
## π Why would I want this?
- π€ **AI Prompts**: Feed your repo or a diff as one codex to ChatGPT/Claude.
- π **Docs & Reviews**: Export a clean snapshot for collaborators.
- π§βπ» **Developers**: Browse or compare projects with context in your terminal.
- ποΈ **Archival**: Serialize project state for reproducibility.
Yggdrasil doesnβt just *list files* β it builds a **codex of your project**, and now shows how files evolve.
---
## π How does it work?
Yggdrasil generates two kinds of outputs:
1. **Snapshot Mode** β index + file contents.
2. **Diff Mode** β compares two sets of files, showing inline diffs *and* cross-file `[MOVED]` metadata.
### Snapshot Examples
```bash
# Export your repo as Markdown (index + contents)
ygg --show --md --contents --out SHOW.md
# List only file paths (no contents)
ygg --show rs
ygg --show py
```
### Diff Examples
```bash
# Compare two versions of a controller
ygg diff controller.py -- controller_old.py
# Compare multiple files against a single snapshot
ygg diff controller.py updates sampling trainer.py -- controller_old.py
# Align tags neatly at a column
ygg diff --align-tags src/ -- old_src/
```
---
## π Manifest files
A manifest is just a plain text file with **one path per line**.
Only the files listed in the manifest will be shown.
Example `WHITE.md`:
```
src/pages/codebase.tsx
src/data/codebaseAssets.tsx
src/i18n/codebase.en.json
src/i18n/codebase.es.json
src/types/codebase.ts
```
Run with:
```bash
ygg --show --white WHITE.md --contents
```
---
## βοΈ Interactive Lists (VS Code paste mode)
You donβt even need a manifest file.
Run:
```bash
ygg --black
```
or
```bash
ygg --white
```
Then paste your paths β for example, directly from **VS Code β Right-click β Copy Relative Path** β
and finish with:
* **Ctrl + D** (Linux/macOS)
* **Ctrl + Z**, then **Enter** (Windows)
Example:
```
src/main.rs
src/utils/io.rs
README.md
```
Each line becomes a filter pattern β instantly usable as a manifest (`--white`) or ignore list (`--black`).
Perfect for ad-hoc flattening or focused diffs when working on multiple files at once.
---
## π Installation
Youβll need [Rust](https://www.rust-lang.org/tools/install).
```bash
cargo install yggdrasil-cli
```
Then ensure `~/.cargo/bin` is in your `PATH`.
Upgrade after edits:
```bash
cargo install --path . --force
```
---
## π² Philosophy
In Norse myth, **Yggdrasil** is the world-tree connecting all realms.
In your terminal, Yggdrasil connects all files β flattening complexity into a single codex, and now diffing branches of your code-tree.
Itβs built to be:
* **Minimal**: no configs, just flags.
* **Readable**: AI-friendly and human-friendly.
* **Extensible**: Markdown, CLI, diff formatters, ignore lists, output redirection.
Goal: Make your projectβs structure **transparent and portable**.
---
## π£ Roadmap
### v0.1 β v0.2
* β
Index & contents export (`--show`, `--contents`)
* β
Markdown mode (`--md`)
* β
Ignore & blacklist support (`--ignore`, `--black`)
* β
Manifest inclusion (`--white`)
* β
Output to file (`--out`)
* β
Cross-file diff engine (`ygg diff`)
* β
`[MOVED]` metadata overlay
* β
`--align-tags` flag
* β
Interactive `--black` / `--white` paste mode
### Future (v0.3 β v1.0)
* β³ Tree vs flat mode toggle
* β³ Configurable themes / styles
* β³ Unified codex+diff export
---
## π License
MIT, like almost everything else thatβs friendly and open-source.