3.1.1 • Published 8 months ago

@diekotto/code-digest v3.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Code Digest Generator

GitHub Release Node npm

Coverage

Statements Branches Functions Lines

Npm package

link: @diekotto/code-digest

A comprehensive tool for generating detailed code digests of your codebase, optimized for Large Language Model (LLM) context windows. Perfect for documentation, code analysis, and AI-assisted development.

Features

  • 📊 Provides a concise metadata summary
  • 📝 Generates a detailed digest of your codebase
  • 🌳 Creates a visual directory tree structure
  • 🚀 Fast execution with Node.js
  • 🔒 Secure artifact storage
  • ⚙️ Configurable file ignoring patterns
  • 🔄 Compatible with CI/CD workflows

Usage Options

Option 1: GitHub Action

Add the following step to your GitHub Actions workflow:

- name: Generate Code Digest
  uses: diekotto/code-digest-action@v2
  with:
    directory: 'src'
    output-format: 'text'

Option 2: CLI Tool via NPX

Run directly without installing:

npx @diekotto/code-digest --directory ./src --output ./output

Option 3: Globally Installed CLI

Install globally:

npm install -g @diekotto/code-digest

Then use anywhere:

code-digest --directory ./src --format both

Configuration

GitHub Action Configuration

InputDescriptionRequiredDefault
node-versionNode.js version to useNo'22'
directoryDirectory to analyzeNo'.'
output-dirOutput directory for generated filesNo'code-digest-output'
ignore-patternsAdditional patterns to ignoreNo''
gitignore-pathPath to custom .gitignore fileNo'.gitignore'
max-file-sizeMaximum file size in MBNo'10'
include-dotInclude dot files in the treeNo'false'
output-formatOutput format (json, text, or both)No'text'
retention-daysNumber of days to retain artifactsNo'90'

CLI Options

OptionAliasDescriptionDefault
--directory-dDirectory to analyzeCurrent working directory
--output-oOutput directory for generated filescode-digest-output
--ignore-iAdditional patterns to ignore (comma separated)-
--gitignore-Path to custom .gitignore file.gitignore
--max-size-Maximum file size in MB10
--include-dot-Include dot files in the treefalse
--format-fOutput format (json, text, or both)text

Output Files

The tool generates multiple files with a timestamp in the output directory:

  • metadata-{timestamp}.json: Contains overall statistics and execution information
  • tree-{timestamp}.txt: Text representation of the directory structure (if format includes 'text')
  • tree-{timestamp}.json: JSON representation of the directory structure (if format includes 'json')
  • digest-{timestamp}.txt: Detailed file information in text format (if format includes 'text')
  • digest-{timestamp}.json: Detailed file information in JSON format (if format includes 'json')

Example Workflow

GitHub Actions Workflow

name: Generate Code Digest

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  digest:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Generate Code Digest
        uses: diekotto/code-digest-action@v2
        with:
          directory: 'src'
          output-format: 'both'
          ignore-patterns: 'node_modules,dist,coverage'

      - name: Download Digest Files
        uses: actions/download-artifact@v4
        with:
          name: code-digest-files

CLI Usage Examples

  1. Generate digest for current directory:
npx @diekotto/code-digest
  1. Generate digest for a specific directory with custom output location:
npx @diekotto/code-digest -d ./src -o ./output
  1. Ignore specific patterns and set custom max file size:
npx @diekotto/code-digest -i "*.log,*.tmp" --max-size 5

Use Cases

  • Code Reviews: Provide structured context for pull request reviews
  • Documentation: Generate detailed codebase summaries
  • AI Integration: Create optimized context for LLM-powered development tools
  • Archival: Maintain searchable snapshots of your codebase

Security

This tool:

  • Uses specific versions of dependent actions (when used as a GitHub Action)
  • Runs in an isolated environment
  • Doesn't require any sensitive permissions
  • Stores artifacts securely

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Diego Maroto

Support

If you encounter any problems or have suggestions, please open an issue in the GitHub repository.

3.1.1

8 months ago

3.1.0

8 months ago

3.0.4

8 months ago

3.0.0

8 months ago

2.3.0

8 months ago

2.2.0

8 months ago

2.1.0

8 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago