Skip to content

refactor: simplify API and add plumbing commands - #99

Merged
maxim-uvarov merged 21 commits into
mainfrom
feate/debloat2
Dec 17, 2025
Merged

maxim-uvarov merged 21 commits into
mainfrom
feate/debloat2

Conversation

@maxim-uvarov

Copy link
Copy Markdown
Member

Summary

  • Simplified run command: Removed rarely-used flags (--result-md-path, --save-ansi, --no-backup, --no-save). --echo now outputs only markdown (stats disabled by default)
  • Simplified clear-outputs command: Removed --result-md-path flag, fixed bug where it created empty files without --echo
  • Added plumbing commands (numd/plumbing.nu): Low-level pipeline commands for advanced scripting:
    • parse-file → strip-outputs → execute-blocks → to-markdown / to-numd-script
  • Replaced YAML config with .nu files: Config files are now sourceable Nushell scripts prepended to intermediate script
  • Module restructuring: Moved capture start/stop to capture.nu, parse-help to parse-help.nu

Test plan

  • All 46 unit tests pass
  • Integration tests pass (0 Levenshtein distance for most files)
  • numd run works with --echo, --config-path, --table-width
  • numd clear-outputs works with --echo, --strip-markdown
  • Plumbing pipeline commands work correctly
  • README and CLAUDE.md documentation updated

🤖 Generated with Claude Code

maxim-uvarov and others added 21 commits December 16, 2025 16:40
Analyzed proposed flag removals and added findings:
- Validated logic for --save-ansi, --no-backup, --result-md-path removal
- Noted --no-save removal requires --echo behavioral change
- Identified additional candidates: --no-stats, --print-block-results
- Added summary table of 7 flags that can be removed/consolidated

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove flags in favor of Unix-style piping:
- --save-ansi: use `--echo | save file.ans`
- --no-save: --echo now implies no save
- --no-backup: replaced with git safety check
- --result-md-path: use `--echo | save target.md`

Add check-git-clean function that warns if file has
uncommitted changes or is not tracked by git.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update examples to use --echo instead of --no-save.
Help output auto-regenerated to reflect removed flags.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update preview mode example to use --echo instead of --no-save --echo.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove --no-backup flags (no longer needed)
- Use --echo --no-stats for saving to different paths
- Import compute-change-stats for manual stats calculation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Change stats example to use non-echo mode which returns
the stats record directly instead of full markdown output.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The pipeline input was lost when check-git-clean was called.
Fixed by capturing $in before the git check.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This makes piping work correctly:
  numd run test.md --echo | save test1.md

Previously --echo would append stats table to output,
corrupting the saved file.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Clarify --print-block-results and --no-fail-on-error descriptions.
Fix list syntax in extract-fence-options example.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Config files are now native Nushell scripts that get prepended to
  the intermediate script
- Table width is evaluated at runtime via $env.numd.table-width
  instead of being baked in at generation time
- Flags (--prepend-code, --table-width) override config file settings
- Converted numd_config_example1.yaml and numd_config_example2.yaml
  to .nu format

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extract `capture start` and `capture stop` commands from commands.nu
to dedicated capture.nu file for better code organization.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Extract `parse-help` command from commands.nu to dedicated
parse-help.nu file. Exported as main for cleaner `numd parse-help` usage.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Extract fence options data to const for reuse
- Remove --list flag, always return user-friendly table
- convert-short-options builds its dict from the const
- Fix deprecated get -i to get -o

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add composable pipeline commands following Unix philosophy:
- `parse-file` - parse markdown file into blocks table
- `strip-outputs` - remove # => output lines from blocks
- `execute-blocks` - execute code blocks and update table
- `to-markdown` - render blocks table back to markdown
- `to-numd-script` - extract pure Nushell script from blocks

Refactor `run` and `clear-outputs` to use these pipeline commands.

Usage examples:
  numd parse-file file.md | numd strip-outputs | numd to-markdown
  numd parse-file file.md | numd execute-blocks | numd to-markdown

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update module structure to reflect new file organization
- Add Pipeline Commands section with usage examples
- Document how run and clear-outputs use pipeline internally

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Separate user-friendly (porcelain) and low-level (plumbing) commands:
- mod.nu exports only high-level commands: run, clear-outputs, etc.
- plumbing.nu exports low-level pipeline commands for scripting

Usage:
  use numd                 # high-level commands only
  use numd/plumbing.nu     # low-level: parse-file, strip-outputs, etc.

Also fix temp script path handling - keep logic in run command
where it has access to the file path.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 13 new tests for the new public plumbing APIs:
- strip-outputs (4 tests): output line removal, comment preservation
- to-markdown (4 tests): rendering blocks back to markdown
- to-numd-script (5 tests): extracting pure Nushell scripts

Total tests: 46 → 59

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@maxim-uvarov
maxim-uvarov merged commit a6428cd into main Dec 17, 2025
2 checks passed
maxim-uvarov added a commit that referenced this pull request Dec 17, 2025
maxim-uvarov added a commit that referenced this pull request Dec 17, 2025
@maxim-uvarov
maxim-uvarov deleted the feate/debloat2 branch March 21, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants