Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ All notable changes to PowerCat are documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.0] - 2025-12-21

### ⚠️ Breaking

- Removed implicit inclusion of `.md` files. Users must explicitly opt-in with `-IncludeMarkdown` or `-Extensions ".md"`.

### ✨ Added

- `-IncludeMarkdown` switch to explicitly include Markdown files.
- `-ExcludeExtensions` to remove selected extension types from processing.
- `-ForceOverwrite` to remove and overwrite existing read-only output files when requested.
- Comma-separated `-Extensions` parsing for convenience (e.g. `-Extensions ".ps1,.md"`).

### ✅ Improved

- Positional `SourceDir` clarified as the first required parameter.
- Script wrapper (`scripts/PowerCat.ps1`) now mirrors module behavior and accepts the same flags.
- Expanded Pester tests to cover new behaviors and script parity.

### 🧭 Migration

- Update automation to include `-IncludeMarkdown` or explicit `-Extensions` if you previously relied on implicit Markdown inclusion.

## [1.1.0] - 2025-12-18

### ✨ Added
Expand Down
78 changes: 41 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
## 🔭 Overview

**PowerCat** is a single-shot concatenator for bundling markdown and code into one clean text file.
It's the feline cousin of Unix `cat`—polished for PowerShell, Markdown-aware, and built for sharing code with recruiters, collaborators, and LLMs.
It's the feline cousin of Unix `cat`—polished for PowerShell, built for sharing code with recruiters, collaborators, and LLMs.

> **Breaking change (v2.0.0):** PowerCat no longer includes `.md` files by default. This was an intentional, breaking change to avoid accidentally bundling documentation. To restore previous behavior, explicitly opt-in with `-IncludeMarkdown` or add `-Extensions ".md"`. See ReleaseNotes for migration guidance.

## ✨ Features

Expand All @@ -24,7 +26,7 @@ It's the feline cousin of Unix `cat`—polished for PowerShell, Markdown-aware,
- **Minification:** Strip comments and blank lines with `-Minify` for lean, token-optimized bundles.
- **Size filtering:** Exclude files by size with `-MinSize` and `-MaxSize` to control output volume.
- **Binary file detection:** Automatically skips common binary formats to prevent errors.
- **Extensions:** Default `.md` plus switches (`-Bash`, `-PowerShell`, `-HTML`, `-CSS`, `-Lua`) or custom via `-Extensions`.
- **Extensions:** No implicit defaults — opt-in. Use `-IncludeMarkdown` to include `.md`, or include types via switches (`-Bash`, `-PowerShell`, `-HTML`, `-CSS`, `-Lua`) or `-Extensions`.
- **Sorting:** Control file order with `-Sort Name|Extension|LastWriteTime|Length`.
- **Catignore support:** Exclude files and directories with a `.gitignore`-style `catignore` file.
- **Aliases:** Quick commands `PowerCat`, `pcat`, `concat` all point to `Invoke-PowerCat`.
Expand All @@ -42,19 +44,19 @@ Import-Module PowerCat
### Run as a cmdlet

```powershell
# Output to file
Invoke-PowerCat -SourceDir "C:\Project" -OutputFile "C:\bundle.txt"
# Output to file (positional SourceDir)
Invoke-PowerCat "C:\Project" -OutputFile "C:\bundle.txt"

# Output to stdout (and pipe to file)
Invoke-PowerCat -SourceDir "C:\Project" | Out-File "C:\bundle.txt"
Invoke-PowerCat "C:\Project" | Out-File "C:\bundle.txt"
```

### Aliases

```powershell
PowerCat -s . -o out.txt # Write to file
pcat -s . | Out-File out.txt # Pipe to file
concat -s . -r -f -p # Stdout with fences
PowerCat . -o out.txt # Write to file
pcat . | Out-File out.txt # Pipe to file
concat . -r -f -p # Stdout with fences
```

### Help
Expand All @@ -66,25 +68,27 @@ Get-Help Invoke-PowerCat -Examples

## 🧪 Examples

- **Concatenate `.md` files to stdout (default):**
- **Concatenate matching files to stdout (no implicit Markdown):**

```powershell
Invoke-PowerCat -s "C:\Project"
Invoke-PowerCat "C:\Project"
# Output streams to console; pipe to capture
Invoke-PowerCat -s "C:\Project" | Out-File bundle.txt
Invoke-PowerCat "C:\Project" | Out-File bundle.txt
```

- **Bundle for LLMs with minification, fences, and token stats:**

```powershell
Invoke-PowerCat -s "C:\Project" -Recurse -Minify -Fence -PowerShell -Stats
Invoke-PowerCat "C:\Project" -Recurse -Minify -Fence -PowerShell -Stats
```

Output includes:

- Stripped comments and blank lines (lean for token limits)
- Code fenced blocks (markdown-aware)
- Token estimate (4 chars/token baseline):
```

```powershell
=== PowerCat Statistics ===
Files processed: 15
Total characters: 45,230
Expand All @@ -95,28 +99,28 @@ Estimated tokens: 11,308 (4 chars/token baseline)
- **Write to file with JSON headers for structured parsing:**

```powershell
Invoke-PowerCat -s "C:\Project" -o "C:\bundle.txt" -Recurse -HeaderFormat JSON -Lua
Invoke-PowerCat "C:\Project" -o "C:\bundle.txt" -Recurse -HeaderFormat JSON -Lua
```

Output includes structured headers like `{"file":"script.lua"}` for better LLM parsing.

- **Exclude large files to optimize for token limits:**

```powershell
Invoke-PowerCat -s "C:\Project" -Recurse -MaxSize 50KB -Bash
Invoke-PowerCat "C:\Project" -Recurse -MaxSize 50KB -Bash
```

- **Custom extensions and sorting:**

```powershell
Invoke-PowerCat -s "C:\Project" -o "C:\bundle.txt" -Extensions ".ps1",".json",".sh" -Sort Extension
Invoke-PowerCat "C:\Project" -o "C:\bundle.txt" -Extensions ".ps1",".json",".sh" -Sort Extension
```

- **Use catignore to exclude directories:**

Create a `catignore` file in your project:

```
```plaintext
node_modules/
.git/
*.log
Expand All @@ -127,13 +131,14 @@ obj/
Then run:

```powershell
Invoke-PowerCat -s "C:\Project" -o "C:\bundle.txt" -Recurse
Invoke-PowerCat "C:\Project" -o "C:\bundle.txt" -Recurse
```

- **View token estimation before bundling:**

```powershell
Invoke-PowerCat -s "C:\Project" -Recurse -Minify -Stats
# Note: PowerCat no longer includes Markdown by default. Use `-IncludeMarkdown` to include `.md` files.
Invoke-PowerCat "C:\Project" -Recurse -Minify -Stats
# See: Files processed, Total characters, Estimated tokens
# Then decide: pipe to file, adjust MaxSize, or minify further
```
Expand All @@ -149,13 +154,13 @@ Module usage:

```powershell
Import-Module .\src\PowerCat\ -Force
Invoke-PowerCat -s . -o out.txt
Invoke-PowerCat . -o out.txt
```

Script usage:

```powershell
.\scripts\PowerCat.ps1 -s . -o out.txt
.\scripts\PowerCat.ps1 . -o out.txt
```

_Note:_ If you see scripts blocked, run `Set-ExecutionPolicy RemoteSigned -Scope CurrentUser` as admin or follow your org policy.
Expand All @@ -178,10 +183,10 @@ Get-ChildItem -Recurse -Filter "*.ps1" | Get-Content
**PowerCat:**

```powershell
Invoke-PowerCat -s . -Recurse -Fence -PowerShell
Invoke-PowerCat . -Recurse -Fence -PowerShell
# Output:
# --- File: script1.ps1 ---
#
#
# '''ps1
# function HelloWorld { Write-Host "Hello" }
# '''
Expand All @@ -193,22 +198,21 @@ Invoke-PowerCat -s . -Recurse -Fence -PowerShell
# '''
```


**The difference:**

| Feature | `cat` | PowerCat |
|---------|-------|----------|
| Stdout output | ✅ | ✅ (default) |
| File output (optional) | ❌ | ✅ |
| File headers | ❌ | ✅ (Markdown/JSON/YAML) |
| Code fencing | ❌ | ✅ (Markdown fences) |
| Minification | ❌ | ✅ (strip comments) |
| Token estimation | ❌ | ✅ (AI context planning) |
| Size filtering | ❌ | ✅ (min/max size) |
| Exclusion patterns | ❌ | ✅ (catignore support) |
| Sorting control | ❌ | ✅ (by name, extension, size, date) |
| Multiple extensions | ❌ | ✅ (flexible file type selection) |
| Binary safety | ❌ | ✅ (auto-skip executables, images, etc.) |
| Feature | `cat` | PowerCat |
| ---------------------- | ----- | ---------------------------------------- |
| Stdout output | ✅ | ✅ (default) |
| File output (optional) | ❌ | ✅ |
| File headers | ❌ | ✅ (Markdown/JSON/YAML) |
| Code fencing | ❌ | ✅ (Markdown fences) |
| Minification | ❌ | ✅ (strip comments) |
| Token estimation | ❌ | ✅ (AI context planning) |
| Size filtering | ❌ | ✅ (min/max size) |
| Exclusion patterns | ❌ | ✅ (catignore support) |
| Sorting control | ❌ | ✅ (by name, extension, size, date) |
| Multiple extensions | ❌ | ✅ (flexible file type selection) |
| Binary safety | ❌ | ✅ (auto-skip executables, images, etc.) |

PowerCat is purpose-built for sharing code with recruiters, collaborators, and LLMs—creating readable, structured, token-aware bundles that respect context limits.

Expand Down
23 changes: 23 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,26 @@ It’s the feline cousin of `cat`—polished for PowerShell, Markdown‑aware, a
- Fixed `-OutputFile` path expansion to only occur when parameter is provided, preventing erroneous directory resolution on stdout-only invocations.
- Corrected test suite to validate both stdout and file-output behaviors.

## Version 2.0.0 (2025-12-21)

### Breaking Changes

- **Implicit Markdown removed:** PowerCat no longer includes `.md` files by default. Users must explicitly opt-in with `-IncludeMarkdown` or `-Extensions ".md"`. This avoids accidentally bundling documentation and makes automated workflows safer.

### Added

- `-IncludeMarkdown`: explicit switch to include `.md` files.
- `-ExcludeExtensions`: exclude specific extensions from selection (accepts comma-separated lists).
- `-ForceOverwrite` (`-force` alias for script): remove existing read-only output files when present and explicitly requested.
- Support for comma-separated `-Extensions` strings for convenience (e.g. `-Extensions ".ps1,.md"`).

### Improved

- Positional `SourceDir` is required for clarity (first positional parameter).
- Script and module parity tightened; script wrapper mirrors module behaviors and accepts the same flags.
- Tests expanded to cover new behaviors and script parity; all tests pass.

### Notes

- This release is a breaking change due to the removal of implicit Markdown inclusion. Update automation or scripts to pass `-IncludeMarkdown` where `.md` files are required.

Loading