1.0.2 • Published 5 months ago
@cogflows/promptcode-preset-mcp v1.0.2
promptcode-preset-mcp
A CLI tool for managing file presets for code prompting. Quickly assemble collections of files from your codebase into prompts for AI/LLM interactions.
Installation
Global installation (recommended)
# Install from npm
pnpm install -g @cogflows/promptcode-preset-mcp
# Or install from GitHub
pnpm install -g github:cogflows/promptcode-preset-mcpLocal development
# Clone the repository
git clone https://github.com/cogflows/promptcode-preset-mcp.git
cd promptcode-preset-mcp
# Install dependencies
pnpm install
# Build and link globally
pnpm build
pnpm link --globalUsage
List presets
promptcode lsGet preset content
# Export to temp file and print path
promptcode get <preset-name>
# Export and open in default editor
promptcode get <preset-name> --openSet workspace directory
# Use environment variable
WORKSPACE=/path/to/project promptcode ls
WORKSPACE=/path/to/project promptcode get coreCreating Presets
Presets are JSON files stored in .promptcode/presets/ within your workspace directory.
Example preset file .promptcode/presets/core.json:
{
"name": "core",
"files": [
"src/main.ts",
"src/utils.ts",
"README.md"
]
}Example Workflow
Create a presets directory in your project:
mkdir -p .promptcode/presetsCreate preset files:
echo '{ "name": "api", "files": ["src/api/index.ts", "src/api/routes.ts", "src/types.ts"] }' > .promptcode/presets/api.jsonList available presets:
promptcode lsOutput:
[ { "name": "api", "fileCount": 3, "totalTokens": 1250 } ]Export preset content:
promptcode get apiOutput:
/var/folders/.../T/preset-api-2025-06-02T19-12-41-238Z.txtUse the exported file with your AI tool:
# Copy to clipboard (macOS) cat $(promptcode get api) | pbcopy # Or open directly promptcode get api --open
Features
- Token counting: Uses OpenAI's tiktoken to count tokens in files
- Caching: Token counts are cached for performance
- Workspace support: Work with presets from any project directory
- Clean output: Returns just the file path for easy scripting
Development
The project is written in TypeScript and uses:
- Node.js ES modules
- tiktoken for token counting
- TypeScript for type safety
Project Structure
src/
├── cli.ts # CLI interface
├── presetManager.ts # Preset loading/saving logic
├── tokenCounter.ts # Token counting with caching
└── types/
└── filePreset.ts # TypeScript interfaces