@draftswithea/anh
v1.0.0
Published
A CLI toolkit for developers — context extraction, SVG conversion, and project-wide renaming.
Downloads
14
Maintainers
Readme
anh
A zero-config CLI toolkit for developers.
npx anh --helpCommands
get-context
Extracts every source file in a folder into a single AI-ready markdown document. The output is placed in your project root with a short hash so you can generate multiple contexts without overwriting previous ones.
npx anh get-context --src src/features
npx anh get-context --src src/features --out ./docs
npx anh get-context --src src/features --include "**/*.ts" --exclude "**/*.test.ts"Options
| Flag | Description | Default |
| ---------------------- | ------------------------------------------ | ------------------ |
| --src <dir> | Source directory (required) | — |
| --include <patterns> | Glob patterns to include (comma-separated) | **/* |
| --exclude <patterns> | Glob patterns to exclude (comma-separated) | — |
| --out <dir> | Where to write the context file | . (project root) |
| --title <title> | Optional document title | Context: <src> |
convert-svg
Converts SVG files to framework components. Works on a single file or an entire directory. Supports React (default), Vue, Solid, Qwik, and Svelte.
# Convert all icons in a folder to React components (one file each)
npx anh convert-svg --from src/icons --to src/icon-components
# Convert to Vue
npx anh convert-svg --from src/icons --to src/icon-components --framework vue
# Convert to a single bundle file
npx anh convert-svg --from src/icons --to src/icon-components --single-file
# Use a custom preset
npx anh convert-svg --from src/icons --to src/components --preset my-react-presetOptions
| Flag | Description | Default |
| ----------------- | ------------------------------------------------- | ------- |
| --from <path> | Source SVG file or directory (required) | — |
| --to <dir> | Output directory (required) | — |
| --framework <n> | react | vue | solid | qwik | svelte | react |
| --single-file | Bundle all into one index file | false |
| --preset <n> | Preset from .anh/presets/svg/<n>.md | — |
SVG Presets
Create .anh/presets/svg/my-preset.md to customize component output:
---
framework: react
---
import React from 'react';
import clsx from 'clsx';
export const {{componentName}} = ({ className, ...props }) => (
<svg {{svgAttrs}} className={clsx('icon', className)} {...props}>
{{svgInner}}
</svg>
);Template variables: {{componentName}}, {{svgAttrs}}, {{svgInner}}
rename
Replaces one name with another across your project or within specific directories.
Supports batch pairs via markdown presets and a --dry-run preview mode.
# Simple rename
npx anh rename --from frmz --to paper-js
# Scope to specific folders
npx anh rename --from frmz --to paper-js --scope src/lib,src/utils
# Only target specific file extensions
npx anh rename --from OldComp --to NewComp --ext ts,tsx
# Preview without writing
npx anh rename --from frmz --to paper-js --dry-run
# Use a preset for batch renames
npx anh rename --preset v2-migrationOptions
| Flag | Description | Default |
| ------------------ | -------------------------------------------- | ------------ |
| --from <term> | Term to replace | — |
| --to <term> | Replacement term | — |
| --scope <dirs> | Comma-separated directories to target | project root |
| --ext <exts> | File extensions to target (e.g. ts,tsx,js) | all files |
| --preset <n> | Preset from .anh/presets/rename/<n>.md | — |
| --dry-run | Preview without writing | false |
| --case-sensitive | Match case-sensitively | true |
Rename Presets
Create .anh/presets/rename/my-rename.md to define batch rename pairs:
---
description: Migrate from v1 to v2 naming
---
- from: frmz
to: paper-js
- from: OldButton
to: PaperButton
- from: useOldHook
to: usePaperHookPresets
All presets live in .anh/presets/ and are written in markdown with optional
YAML front-matter. This keeps them readable, version-controllable, and easy to share.
.anh/
└── presets/
├── svg/
│ ├── react-with-clsx.md
│ └── vue-with-attrs.md
└── rename/
├── v2-migration.md
└── rebrand-2024.mdContributing a new tool
- Create
src/commands/your-command.js - Export a default
registerCommand(program)function - Register it in
bin/anh.jsby adding the path toCOMMAND_MODULES
// src/commands/your-command.js
export default function register(program) {
program
.command("your-command")
.description("What your command does")
.option("--flag <value>", "Description of flag")
.action(async (opts) => {
// your logic
});
}That's it. No boilerplate, no configuration — just export and register.
Requirements
- Node.js ≥ 18
License
MIT
