towl 0.3.7

A fast CLI tool to scan codebases for TODO comments and output them in multiple formats
Documentation
<!DOCTYPE HTML>
<html lang="en" class="navy sidebar-visible" dir="ltr">
    <head>
        <!-- Book generated using mdBook -->
        <meta charset="UTF-8">
        <title>Errors - towl Documentation</title>


        <!-- Custom HTML head -->

        <meta name="description" content="Documentation for towl - a fast CLI tool to scan codebases for TODO comments">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="theme-color" content="#ffffff">

        <link rel="icon" href="../favicon.svg">
        <link rel="shortcut icon" href="../favicon.png">
        <link rel="stylesheet" href="../css/variables.css">
        <link rel="stylesheet" href="../css/general.css">
        <link rel="stylesheet" href="../css/chrome.css">
        <link rel="stylesheet" href="../css/print.css" media="print">

        <!-- Fonts -->
        <link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
        <link rel="stylesheet" href="../fonts/fonts.css">

        <!-- Highlight.js Stylesheets -->
        <link rel="stylesheet" id="highlight-css" href="../highlight.css">
        <link rel="stylesheet" id="tomorrow-night-css" href="../tomorrow-night.css">
        <link rel="stylesheet" id="ayu-highlight-css" href="../ayu-highlight.css">

        <!-- Custom theme stylesheets -->


        <!-- Provide site root and default themes to javascript -->
        <script>
            const path_to_root = "../";
            const default_light_theme = "navy";
            const default_dark_theme = "navy";
            window.path_to_searchindex_js = "../searchindex.js";
        </script>
        <!-- Start loading toc.js asap -->
        <script src="../toc.js"></script>
    </head>
    <body>
    <div id="mdbook-help-container">
        <div id="mdbook-help-popup">
            <h2 class="mdbook-help-title">Keyboard shortcuts</h2>
            <div>
                <p>Press <kbd></kbd> or <kbd></kbd> to navigate between chapters</p>
                <p>Press <kbd>S</kbd> or <kbd>/</kbd> to search in the book</p>
                <p>Press <kbd>?</kbd> to show this help</p>
                <p>Press <kbd>Esc</kbd> to hide this help</p>
            </div>
        </div>
    </div>
    <div id="body-container">
        <!-- Work around some values being stored in localStorage wrapped in quotes -->
        <script>
            try {
                let theme = localStorage.getItem('mdbook-theme');
                let sidebar = localStorage.getItem('mdbook-sidebar');

                if (theme.startsWith('"') && theme.endsWith('"')) {
                    localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
                }

                if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
                    localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
                }
            } catch (e) { }
        </script>

        <!-- Set the theme before any content is loaded, prevents flash -->
        <script>
            const default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? default_dark_theme : default_light_theme;
            let theme;
            try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
            if (theme === null || theme === undefined) { theme = default_theme; }
            const html = document.documentElement;
            html.classList.remove('navy')
            html.classList.add(theme);
            html.classList.add("js");
        </script>

        <input type="checkbox" id="sidebar-toggle-anchor" class="hidden">

        <!-- Hide / unhide sidebar before it is displayed -->
        <script>
            let sidebar = null;
            const sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
            if (document.body.clientWidth >= 1080) {
                try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
                sidebar = sidebar || 'visible';
            } else {
                sidebar = 'hidden';
                sidebar_toggle.checked = false;
            }
            if (sidebar === 'visible') {
                sidebar_toggle.checked = true;
            } else {
                html.classList.remove('sidebar-visible');
            }
        </script>

        <nav id="sidebar" class="sidebar" aria-label="Table of contents">
            <!-- populated by js -->
            <mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
            <noscript>
                <iframe class="sidebar-iframe-outer" src="../toc.html"></iframe>
            </noscript>
            <div id="sidebar-resize-handle" class="sidebar-resize-handle">
                <div class="sidebar-resize-indicator"></div>
            </div>
        </nav>

        <div id="page-wrapper" class="page-wrapper">

            <div class="page">
                <div id="menu-bar-hover-placeholder"></div>
                <div id="menu-bar" class="menu-bar sticky">
                    <div class="left-buttons">
                        <label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
                            <i class="fa fa-bars"></i>
                        </label>
                        <button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
                            <i class="fa fa-paint-brush"></i>
                        </button>
                        <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
                            <li role="none"><button role="menuitem" class="theme" id="default_theme">Auto</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
                            <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
                        </ul>
                        <button id="search-toggle" class="icon-button" type="button" title="Search (`/`)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="/ s" aria-controls="searchbar">
                            <i class="fa fa-search"></i>
                        </button>
                    </div>

                    <h1 class="menu-title">towl Documentation</h1>

                    <div class="right-buttons">
                        <a href="../print.html" title="Print this book" aria-label="Print this book">
                            <i id="print-button" class="fa fa-print"></i>
                        </a>
                        <a href="https://github.com/glottologist/towl" title="Git repository" aria-label="Git repository">
                            <i id="git-repository-button" class="fa fa-github"></i>
                        </a>
                        <a href="https://github.com/glottologist/towl/edit/main/docs/src/src/api/errors.md" title="Suggest an edit" aria-label="Suggest an edit" rel="edit">
                            <i id="git-edit-button" class="fa fa-edit"></i>
                        </a>

                    </div>
                </div>

                <div id="search-wrapper" class="hidden">
                    <form id="searchbar-outer" class="searchbar-outer">
                        <div class="search-wrapper">
                            <input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
                            <div class="spinner-wrapper">
                                <i class="fa fa-spinner fa-spin"></i>
                            </div>
                        </div>
                    </form>
                    <div id="searchresults-outer" class="searchresults-outer hidden">
                        <div id="searchresults-header" class="searchresults-header"></div>
                        <ul id="searchresults">
                        </ul>
                    </div>
                </div>

                <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
                <script>
                    document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
                    document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
                    Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
                        link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
                    });
                </script>

                <div id="content" class="content">
                    <main>
                        <h1 id="errors"><a class="header" href="#errors">Errors</a></h1>
<p>towl uses typed errors throughout, built with <code>thiserror</code>. Each module defines its own error enum, and the top-level <code>TowlError</code> aggregates them.</p>
<h2 id="error-hierarchy"><a class="header" href="#error-hierarchy">Error Hierarchy</a></h2>
<pre><code class="language-text">TowlError
├── TowlConfigError
├── TowlScannerError
│   └── TowlParserError
│       └── TowlCommentError
├── TowlOutputError
│   ├── FormatterError
│   └── WriterError
├── TowlGitHubError
├── TowlProcessorError
├── TowlTuiError
└── TowlLlmError
</code></pre>
<h2 id="towlerror"><a class="header" href="#towlerror"><code>TowlError</code></a></h2>
<p>Top-level error type used by the CLI binary. All sub-error types convert automatically via <code>#[from]</code>.</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>pub enum TowlError {
    Config(TowlConfigError),
    Scanner(TowlScannerError),
    Output(TowlOutputError),
    GitHub(TowlGitHubError),
    Processor(TowlProcessorError),
    Tui(TowlTuiError),
    Llm(TowlLlmError),
}
<span class="boring">}</span></code></pre></pre>
<h2 id="towlconfigerror"><a class="header" href="#towlconfigerror"><code>TowlConfigError</code></a></h2>
<p>Errors during configuration loading, initialisation, and validation.</p>
<div class="table-wrapper"><table><thead><tr><th>Variant</th><th>Cause</th></tr></thead><tbody>
<tr><td><code>PathTraversalAttempt(PathBuf)</code></td><td>Config path contains <code>..</code></td></tr>
<tr><td><code>ConfigAlreadyExists(PathBuf)</code></td><td><code>towl init</code> without <code>--force</code> on existing file</td></tr>
<tr><td><code>WriteToFileError(PathBuf, io::Error)</code></td><td>Failed to write config file</td></tr>
<tr><td><code>UnableToParseToml(toml::ser::Error)</code></td><td>TOML serialisation failure</td></tr>
<tr><td><code>CouldNotCreateConfig(ConfigError)</code></td><td>Config crate loading error</td></tr>
<tr><td><code>GitRepoNotFound { message }</code></td><td>Not inside a git repository</td></tr>
<tr><td><code>GitRemoteNotFound { message }</code></td><td>No <code>origin</code> remote</td></tr>
<tr><td><code>GitInvalidUrl { url, message }</code></td><td>Cannot parse owner/repo from remote URL</td></tr>
<tr><td><code>TooManyConfigPatterns { field, count, max_allowed }</code></td><td>Pattern array exceeds 100 entries</td></tr>
<tr><td><code>ConfigValueTooLong { field, length, max_length }</code></td><td>Config string exceeds 512 characters</td></tr>
<tr><td><code>ContextLinesOutOfRange { value, min, max }</code></td><td>Context lines outside 1..=50</td></tr>
<tr><td><code>RateLimitDelayTooHigh { value, max }</code></td><td>Rate limit delay exceeds maximum</td></tr>
</tbody></table>
</div>
<h2 id="towlscannererror"><a class="header" href="#towlscannererror"><code>TowlScannerError</code></a></h2>
<p>Errors during directory walking and file reading.</p>
<div class="table-wrapper"><table><thead><tr><th>Variant</th><th>Cause</th></tr></thead><tbody>
<tr><td><code>UnableToWalkFile(ignore::Error)</code></td><td>Directory traversal error</td></tr>
<tr><td><code>ParsingError(TowlParserError)</code></td><td>Parser failure (propagated)</td></tr>
<tr><td><code>UnableToReadFileAtPath(PathBuf, io::Error)</code></td><td>File I/O error</td></tr>
<tr><td><code>InvalidPath { path }</code></td><td>Path could not be canonicalised</td></tr>
<tr><td><code>FileTooLarge { path, size, max_allowed }</code></td><td>File exceeds 10 MB</td></tr>
<tr><td><code>TooManyTodos { path, count, max_allowed }</code></td><td>File exceeds 10,000 TODOs</td></tr>
</tbody></table>
</div>
<h2 id="towlparsererror"><a class="header" href="#towlparsererror"><code>TowlParserError</code></a></h2>
<p>Errors during regex compilation and TODO extraction.</p>
<div class="table-wrapper"><table><thead><tr><th>Variant</th><th>Cause</th></tr></thead><tbody>
<tr><td><code>InvalidRegexPattern(String, regex::Error)</code></td><td>Regex failed to compile</td></tr>
<tr><td><code>UnknownConfigPattern(TowlCommentError)</code></td><td>Pattern matched but type unknown</td></tr>
<tr><td><code>RegexGroupMissing</code></td><td>Pattern lacks a capture group <code>(.*)</code></td></tr>
<tr><td><code>PatternTooLong(usize, usize)</code></td><td>Pattern exceeds 256 characters</td></tr>
<tr><td><code>TooManyTotalPatterns { count, max_allowed }</code></td><td>Total patterns across all categories exceeds 50</td></tr>
</tbody></table>
</div>
<h2 id="towlcommenterror"><a class="header" href="#towlcommenterror"><code>TowlCommentError</code></a></h2>
<p>Errors in comment type resolution.</p>
<div class="table-wrapper"><table><thead><tr><th>Variant</th><th>Cause</th></tr></thead><tbody>
<tr><td><code>UnknownTodoType { comment }</code></td><td>String does not map to a known <code>TodoType</code></td></tr>
</tbody></table>
</div>
<h2 id="towloutputerror"><a class="header" href="#towloutputerror"><code>TowlOutputError</code></a></h2>
<p>Errors during formatting and writing.</p>
<div class="table-wrapper"><table><thead><tr><th>Variant</th><th>Cause</th></tr></thead><tbody>
<tr><td><code>InvalidOutputPath(String)</code></td><td>Missing/wrong extension, terminal format with file path</td></tr>
<tr><td><code>UnableToFormatTodos(FormatterError)</code></td><td>Formatter failure</td></tr>
<tr><td><code>UnableToWriteTodos(WriterError)</code></td><td>Writer failure</td></tr>
</tbody></table>
</div>
<h2 id="formattererror"><a class="header" href="#formattererror"><code>FormatterError</code></a></h2>
<p>Errors in output formatting.</p>
<div class="table-wrapper"><table><thead><tr><th>Variant</th><th>Cause</th></tr></thead><tbody>
<tr><td><code>SerializationError(String)</code></td><td>JSON/TOML/CSV serialisation failure</td></tr>
<tr><td><code>IntegerOverflow(usize)</code></td><td>Count exceeds safe integer bounds</td></tr>
</tbody></table>
</div>
<h2 id="writererror"><a class="header" href="#writererror"><code>WriterError</code></a></h2>
<p>Errors in output writing.</p>
<div class="table-wrapper"><table><thead><tr><th>Variant</th><th>Cause</th></tr></thead><tbody>
<tr><td><code>IoError(io::Error)</code></td><td>File system I/O error</td></tr>
<tr><td><code>PathTraversal(PathBuf)</code></td><td>Output path contains <code>..</code></td></tr>
</tbody></table>
</div>
<h2 id="towlgithuberror"><a class="header" href="#towlgithuberror"><code>TowlGitHubError</code></a></h2>
<p>Errors from GitHub API interactions.</p>
<div class="table-wrapper"><table><thead><tr><th>Variant</th><th>Cause</th></tr></thead><tbody>
<tr><td><code>ApiError { message, source }</code></td><td>General GitHub API failure</td></tr>
<tr><td><code>AuthError</code></td><td>401 response -- invalid or expired token</td></tr>
<tr><td><code>RateLimitExceeded { retry_after_secs }</code></td><td>403 with rate limit message</td></tr>
<tr><td><code>IssueAlreadyExists { title }</code></td><td>Duplicate detected before creation</td></tr>
<tr><td><code>RepositoryNotFound { owner, repo }</code></td><td>404 response -- owner/repo not found</td></tr>
<tr><td><code>MissingToken</code></td><td><code>TOWL_GITHUB_TOKEN</code> not set or empty</td></tr>
</tbody></table>
</div>
<h2 id="towlprocessorerror"><a class="header" href="#towlprocessorerror"><code>TowlProcessorError</code></a></h2>
<p>Errors from replacing TODO comments with issue links in source files.</p>
<div class="table-wrapper"><table><thead><tr><th>Variant</th><th>Cause</th></tr></thead><tbody>
<tr><td><code>FileReadError(PathBuf, io::Error)</code></td><td>Failed to read source file</td></tr>
<tr><td><code>FileWriteError(PathBuf, io::Error)</code></td><td>Failed to write modified file</td></tr>
<tr><td><code>LineOutOfBounds { path, line, total_lines }</code></td><td>TODO line number exceeds file length</td></tr>
<tr><td><code>CommentPrefixNotFound { path, line }</code></td><td>Column offset points past end of line</td></tr>
<tr><td><code>PathOutsideRoot { path, root }</code></td><td>File is outside the repository root</td></tr>
<tr><td><code>InvalidIssueUrl { url }</code></td><td>URL does not start with <code>https://github.com/</code></td></tr>
</tbody></table>
</div>
<h2 id="towlllmerror"><a class="header" href="#towlllmerror"><code>TowlLlmError</code></a></h2>
<p>Errors from LLM API interactions and analysis.</p>
<div class="table-wrapper"><table><thead><tr><th>Variant</th><th>Cause</th></tr></thead><tbody>
<tr><td><code>ApiError { message, status }</code></td><td>LLM API returned a non-200 status</td></tr>
<tr><td><code>AuthError</code></td><td>401 -- invalid or missing API key</td></tr>
<tr><td><code>RateLimited { retry_after_secs }</code></td><td>429 -- too many requests</td></tr>
<tr><td><code>ParseError { message }</code></td><td>LLM response could not be parsed as valid JSON</td></tr>
<tr><td><code>NotConfigured</code></td><td><code>TOWL_LLM_API_KEY</code> environment variable not set</td></tr>
<tr><td><code>UnsupportedProvider { provider }</code></td><td>Provider is not "claude", "openai", "claude-code", or "codex"</td></tr>
<tr><td><code>IoError { message }</code></td><td>File I/O error during context gathering</td></tr>
</tbody></table>
</div>
<p><code>is_retryable()</code> returns <code>true</code> for <code>RateLimited</code>, <code>ApiError</code> with status &gt;= 500, and <code>ApiError</code> with no status (network failures).</p>
<h2 id="towltuierror"><a class="header" href="#towltuierror"><code>TowlTuiError</code></a></h2>
<p>Errors from the interactive terminal UI.</p>
<div class="table-wrapper"><table><thead><tr><th>Variant</th><th>Cause</th></tr></thead><tbody>
<tr><td><code>Io(io::Error)</code></td><td>Terminal I/O error from crossterm or ratatui</td></tr>
</tbody></table>
</div>
<h2 id="error-propagation"><a class="header" href="#error-propagation">Error Propagation</a></h2>
<p>Errors propagate upward using <code>?</code> and <code>#[from]</code>:</p>
<pre><code class="language-text">TowlCommentError  --&gt;  TowlParserError    --&gt;  TowlScannerError  --&gt;  TowlError
FormatterError    --&gt;  TowlOutputError     --&gt;  TowlError
WriterError       --&gt;  TowlOutputError     --&gt;  TowlError
TowlGitHubError   ----------------------------&gt;  TowlError
TowlProcessorError ---------------------------&gt;  TowlError
TowlTuiError      ----------------------------&gt;  TowlError
TowlLlmError      ----------------------------&gt;  TowlError
</code></pre>
<p>All errors implement <code>std::fmt::Display</code> with human-readable messages and <code>std::error::Error</code> for standard error handling.</p>

                    </main>

                    <nav class="nav-wrapper" aria-label="Page navigation">
                        <!-- Mobile navigation buttons -->
                            <a rel="prev" href="../api/types.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                                <i class="fa fa-angle-left"></i>
                            </a>

                            <a rel="next prefetch" href="../reference/architecture.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                                <i class="fa fa-angle-right"></i>
                            </a>

                        <div style="clear: both"></div>
                    </nav>
                </div>
            </div>

            <nav class="nav-wide-wrapper" aria-label="Page navigation">
                    <a rel="prev" href="../api/types.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                        <i class="fa fa-angle-left"></i>
                    </a>

                    <a rel="next prefetch" href="../reference/architecture.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                        <i class="fa fa-angle-right"></i>
                    </a>
            </nav>

        </div>




        <script>
            window.playground_copyable = true;
        </script>


        <script src="../elasticlunr.min.js"></script>
        <script src="../mark.min.js"></script>
        <script src="../searcher.js"></script>

        <script src="../clipboard.min.js"></script>
        <script src="../highlight.js"></script>
        <script src="../book.js"></script>

        <!-- Custom JS scripts -->



    </div>
    </body>
</html>