Copyright | (c) Fuzz Leonard 2025 |
---|---|
License | MIT |
Maintainer | cyborg@bionicfuzz.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Clod.Core
Description
This module provides the core functionality for the Clod application, implemented using a traditional monad stack with capability-based security.
Clod (Claude Loader) is a utility for preparing and uploading files to Claude AI's Project Knowledge feature. It tracks file changes, respects .gitignore and .clodignore patterns, and optimizes filenames for Claude's UI.
Main Features
- Track modified files using a checksum database
- Respect .gitignore and .clodignore patterns
- Handle binary vs. text files
- Optimize filenames for Claude's UI
- Generate a path manifest for mapping optimized names back to original paths
- Capability-based security for file operations
Synopsis
- runClodApp :: ClodConfig -> FilePath -> Bool -> Bool -> IO (Either ClodError ())
- processFile :: FileReadCap -> FileWriteCap -> FilePath -> FilePath -> ClodM FileResult
- findAllFiles :: FilePath -> [FilePath] -> ClodM [FilePath]
Main application entry point
runClodApp :: ClodConfig -> FilePath -> Bool -> Bool -> IO (Either ClodError ()) Source #
Run the main Clod application
File processing with capabilities
Arguments
:: FileReadCap | Capability for reading files |
-> FileWriteCap | Capability for writing files |
-> FilePath | Full path to the file |
-> FilePath | Relative path from project root |
-> ClodM FileResult | Result of processing (Success or Skipped) |
Process a file using capability-based security
This function runs a file through a pipeline of processing steps, with each step using capability tokens to ensure secure access. The steps are:
- Check against ignore patterns
- Verify the file exists (using FileReadCap)
- Verify the file is a text file (using FileReadCap)
- Copy to staging directory (using both FileReadCap and FileWriteCap)
Each step must succeed for the file to be processed. If any step fails, processing stops and the reason is returned.
>>>
-- Process a text file that exists and isn't ignored
>>>
processFile readCap writeCap "/project/src/main.hs" "src/main.hs"
Success
>>>
-- Process a binary file (skipped)
>>>
processFile readCap writeCap "/project/img/logo.png" "img/logo.png"
Skipped "binary file"
>>>
-- Process an ignored file
>>>
processFile readCap writeCap "/project/node_modules/package.json" "node_modules/package.json"
Skipped "matched .clodignore pattern"
findAllFiles :: FilePath -> [FilePath] -> ClodM [FilePath] Source #
Recursively find all files in a directory
This function takes a base path and a list of files/directories, and recursively finds all files within those directories. It returns paths relative to the base path.
-- Find all files in the "src" directory files <- findAllFiles "pathto/repo" ["src"] -- Find all files in multiple directories files <- findAllFiles "pathto/repo" ["src", "docs", "tests"] -- Find all files in the root directory (without "./" prefix) files <- findAllFiles "pathto/repo" [""]