A CLI and GUI tool that generates clean, exportable views of your project's file structure. Great for dev, docs, collaboration, or AI models
- Windows
./install-treetrunk-dev.ps1- Linux / macOS
./install-treetrunk-dev.shThis will:
- Install TreeTrunk CLI to
~/.treetrunk(Windows:%USERPROFILE%\.treetrunk) - Add the folder to your PATH (or prompt you to do so)
- Provide a
treetrunkcommand globally
ℹ️ Production/public releases, on the way
Ensure Gradle is installed.
To build the CLI:
./gradlew :cli:shadowJartreetrunk --helptreetrunk rendertreetrunk render /path/to/your/projecttreetrunk list-stylesTo render with a style:
treetrunk render --style ASCII
treetrunk render --custom-style MY_STYLE| Option | Description |
|---|---|
--max-depth <n> |
Maximum depth to render |
--max-children <n> |
Max number of children per folder |
--collapse-empty |
Collapse chains of empty directories |
--forgive |
Allow slight overflow on limits |
--depth-forgiveness <n> |
Additional levels past max depth |
--child-forgiveness <n> |
Additional children per folder |
treetrunk render --output /path/to/output.txtproject-root/
├── build.gradle
├── src/
│ ├── main/
│ │ └── Main.kt
│ └── test/
│ └── MainTest.kt
└── README.md
Output of this project as of 17/07/2025 (gradle exclude preset)
treetrunk render --e gradle
./
└── ./
├── cli/
│ ├── src/
│ │ ├── main/
│ │ │ ├── kotlin.com.glance.treetrunk.cli/
│ │ │ │ ├── commands/
│ │ │ │ │ ├── render/
│ │ │ │ │ │ ├── AdvancedOptions.kt
│ │ │ │ │ │ ├── OutputOptions.kt
│ │ │ │ │ │ ├── RenderCommand.kt
│ │ │ │ │ │ ├── RenderOptions.kt
│ │ │ │ │ │ └── StrategyOptions.kt
│ │ │ │ │ ├── HelperCommands.kt
│ │ │ │ │ ├── ListStylesCommand.kt
│ │ │ │ │ └── TreeTrunkCli.kt
│ │ │ │ └── Main.kt
│ │ │ └── resources
│ │ └── test/
│ │ ├── kotlin
│ │ └── resources
│ └── build.gradle.kts
├── core/
│ ├── src/
│ │ ├── main/
│ │ │ ├── kotlin.com.glance.treetrunk.core/
│ │ │ │ ├── config/
│ │ │ │ │ ├── AdvancedConfig.kt
│ │ │ │ │ ├── AppConfiguration.kt
│ │ │ │ │ ├── RenderConfig.kt
│ │ │ │ │ └── StrategyConfig.kt
│ │ │ │ ├── strategy/
│ │ │ │ │ ├── ignore/
│ │ │ │ │ │ ├── parser/
│ │ │ │ │ │ │ ├── GitIgnoreParser.kt
│ │ │ │ │ │ │ ├── IgnoreResolver.kt
│ │ │ │ │ │ │ └── TreeIgnoreParser.kt
│ │ │ │ │ │ ├── rule/
│ │ │ │ │ │ │ ├── GlobIgnoreRule.kt
│ │ │ │ │ │ │ └── IgnoreRule.kt
│ │ │ │ │ │ └── IgnoreEngine.kt
│ │ │ │ │ ├── include/
│ │ │ │ │ │ ├── parser/
│ │ │ │ │ │ │ ├── IncludeResolver.kt
│ │ │ │ │ │ │ └── TreeIncludeParser.kt
│ │ │ │ │ │ ├── rule/
│ │ │ │ │ │ │ ├── GlobIncludeRule.kt
│ │ │ │ │ │ │ └── IncludeRule.kt
│ │ │ │ │ │ ├── IncludeEngine.kt
│ │ │ │ │ │ └── InclusionMode.kt
│ │ │ │ │ ├── pattern/
│ │ │ │ │ │ └── GlobPattern.kt
│ │ │ │ │ ├── DepthMode.kt
│ │ │ │ │ ├── Strategy.kt
│ │ │ │ │ ├── StrategyFileParser.kt
│ │ │ │ │ ├── StrategyFileParserRegistry.kt
│ │ │ │ │ ├── StrategyLoader.kt
│ │ │ │ │ └── StrategyRule.kt
│ │ │ │ ├── tree/
│ │ │ │ │ ├── model/
│ │ │ │ │ │ └── TreeNode.kt
│ │ │ │ │ ├── render/
│ │ │ │ │ │ ├── text/
│ │ │ │ │ │ │ ├── StyleRegistry.kt
│ │ │ │ │ │ │ ├── TextRenderOpts.kt
│ │ │ │ │ │ │ └── TextTreeRenderer.kt
│ │ │ │ │ │ └── TreeRenderer.kt
│ │ │ │ │ ├── CliTreeSymbols.kt
│ │ │ │ │ ├── Defaults.kt
│ │ │ │ │ └── TreeBuilder.kt
│ │ │ │ └── util
│ │ │ └── resources.strategy/
│ │ │ ├── ignore/
│ │ │ │ ├── defaults.treeignore
│ │ │ │ └── gradle.trunkignore
│ │ │ └── include/
│ │ │ └── kotlin.trunkinclude
│ │ └── test/
│ │ ├── kotlin.com.glance.treetrunk.core.test.strategy/
│ │ │ ├── ignore/
│ │ │ │ └── GlobPatternTest.kt
│ │ │ ├── include
│ │ │ └── preset/
│ │ │ └── StrategyLoaderTest.kt
│ │ └── resources
│ └── build.gradle.kts
├── gradle.wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── scripts.install/
│ ├── install-treetrunk-dev.ps1
│ └── install-treetrunk-dev.sh
├── .gitignore
├── README.md
├── build.gradle.kts
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle.kts
TreeTrunk supports ignore/include rules similar to .gitignore:
- Glob patterns like
*.txtorbuild/ - Custom ignore/include files (e.g.
.treeignore) - Rule presets for ecosystems like Gradle, Node, etc. (coming soon)
| Option | Description |
|---|---|
--ignore <pattern> |
Ignore items matching this pattern |
--include <pattern> |
Explicitly include items matching pattern |
--ignore-files <file> |
File containing ignore rules |
--include-files <file> |
File containing include rules |
--ignore-presets <name> |
Apply preset ignore rules |
--use-local-ignores |
Enable per-directory ignore files |
--propagate-ignores |
Pass ignores to subdirectories |
To construct a directory tree programmatically:
val config = AppConfiguration.builder()
.root(File("path/to/project"))
.renderConfig(RenderConfig())
.strategyConfig(StrategyConfig())
.advancedConfig(AdvancedConfig())
.build()
val tree = TreeBuilder.buildTree(config)The rendering system is pluggable and generic:
interface TreeRenderer<Output, Options> {
fun render(node: TreeNode, options: Options): Output
}Example text rendering:
val renderOutput = TextTreeRenderer.render(tree, TextRenderOpts())
println(renderOutput)Implement:
class JsonTreeRenderer : TreeRenderer<JsonElement, JsonRenderOpts> { ... }- 🚧 JSON, Markdown, GUI renderers
- 🚧 Gradle/Maven plugin integrations
- 🚧 Public jar releases
Contributions are welcome! Planned:
- Developer guides
- Plugin hooks