{"_rev":"4-7de33f2d235359ee3edd4531e439686f","time":{"created":"2026-03-31T18:25:11.338Z","modified":"2026-03-31T18:25:12.330Z","0.1.1":"2026-03-31T18:17:41.925Z","0.2.0":"2026-03-31T18:20:15.077Z","0.1.0":"2026-03-31T18:25:11.775Z"},"_id":"@elilands/promptune","name":"@elilands/promptune","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@elilands/promptune","version":"0.1.0","description":"An intelligent prompt generation and optimization engine aware of your codebase","type":"module","main":"dist/index.js","bin":{"promptune":"dist/cli/index.js"},"scripts":{"build":"tsc","dev":"tsx src/cli/index.ts","start":"node dist/cli/index.js","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","lint":"eslint src --ext .ts","format":"prettier --write \"src/**/*.ts\""},"keywords":["ai","prompt-engineering","code-analysis","llm","developer-tools","rag","semantic-search"],"author":{"name":"elilands"},"license":"MIT","dependencies":{"@anthropic-ai/sdk":"^0.16.0","chalk":"^5.3.0","commander":"^12.0.0","dotenv":"^16.4.0","openai":"^4.45.0","zod":"^3.22.0"},"devDependencies":{"@types/node":"^20.11.0","@typescript-eslint/eslint-plugin":"^8.58.0","@typescript-eslint/parser":"^8.58.0","@vitest/coverage-v8":"^4.1.2","eslint":"^8.56.0","eslint-config-prettier":"^10.1.8","prettier":"^3.2.0","tsx":"^4.7.0","typescript":"^5.3.0","vitest":"^4.1.2"},"types":"./dist/index.d.ts","_id":"@elilands/promptune@0.1.0","_nodeVersion":"22.15.1","_npmVersion":"11.10.0","dist":{"integrity":"sha512-0sZALq5Hg/20jI1n+/rFez6RkWHwykDOilBzRc3K8rYSu2PY74WUmwBSZm80REhjjb95ii1FZkPjsrGTSM1V+Q==","shasum":"1868273eb47255174c83d1c19af23d6f4f553408","tarball":"https://registry.npmjs.org/@elilands/promptune/-/promptune-0.1.0.tgz","fileCount":31,"unpackedSize":4081973,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDsHVtdbTgMqih/lFw9Xr9yVRfFJcHHooHDjdkpkxMCDgIhAM9eb7UcAib5w9j+ZotXy5eGXtDa+mIg47j7UHbWb/KJ"}]},"_npmUser":{"name":"elilands","email":"elian.mejiag@gmail.com"},"directories":{},"maintainers":[{"name":"elilands","email":"elian.mejiag@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/promptune_0.1.0_1774981511442_0.7599512239480504"},"_hasShrinkwrap":false}},"maintainers":[{"name":"elilands","email":"elian.mejiag@gmail.com"}],"description":"An intelligent prompt generation and optimization engine aware of your codebase","keywords":["ai","prompt-engineering","code-analysis","llm","developer-tools","rag","semantic-search"],"author":{"name":"elilands"},"license":"MIT","readme":"# 🎯 Promptune — Intelligent Prompt Engine for Code\r\n\r\n> An intelligent prompt generation and optimization engine that understands your codebase and creates contextually-aware prompts for AI models.\r\n\r\n## Overview\r\n\r\n**Promptune** solves a critical problem in AI-assisted development: *generic prompts that don't understand your project*. Instead of writing long, manual prompts, Promptune:\r\n\r\n- 📖 **Reads your codebase** and builds a semantic understanding\r\n- 🧠 **Detects patterns** in your code (hooks, components, services, etc.)\r\n- 🎨 **Understands your style** (naming conventions, architecture, dependencies)\r\n- ✨ **Generates optimized prompts** tailored to your project with minimal noise\r\n\r\n## Features\r\n\r\n### 🔍 Smart Indexing\r\n- **Semantic code indexing** — Creates a RAG-like index optimized for code\r\n- **Pattern detection** — Automatically identifies your code patterns (React hooks, services, middleware, etc.)\r\n- **Dependency awareness** — Knows what libraries you use and avoids suggesting what doesn't exist\r\n- **Caching** — Dramatically speeds up subsequent runs\r\n\r\n### 🧩 Context Pruning\r\n- **Intelligent file selection** — Includes only the most relevant code snippets\r\n- **Token optimization** — Reduces context bloat, lowers LLM costs\r\n- **Relevance scoring** — Ensures the most useful code is included\r\n\r\n### 🎨 Style Mirroring\r\n- **Naming convention detection** — Replicates your camelCase/snake_case patterns\r\n- **Code formatting preferences** — Matches your semicolons, quotes, spacing\r\n- **TypeScript awareness** — Understands strict types, interfaces vs types, etc.\r\n\r\n### 🚀 Model-Aware Generation\r\n- **GPT-4/3.5** — Structured, clear instructions\r\n- **Claude** — Detailed, explanatory context\r\n- **OpenRouter** — Optimized for any model you choose\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install -g @elilands/promptune\r\n# or\r\npnpm add -g @elilands/promptune\r\n```\r\n\r\n## Quick Start\r\n\r\n### 1️⃣ Generate a Prompt\r\n\r\n```bash\r\npromptune generate \"crea un hook useCart para manejar el carrito de compras\"\r\n```\r\n\r\n```bash\r\npromptune generate \"refactoriza este endpoint de pagos\" -f src/api/payment.ts\r\n```\r\n\r\n### 2️⃣ Build Project Index\r\n\r\n```bash\r\npromptune index\r\n```\r\n\r\n### 3️⃣ View Project Info\r\n\r\n```bash\r\npromptune info\r\n```\r\n\r\n## Usage Examples\r\n\r\n### Create a New Feature\r\n```bash\r\npromptune generate \"crea un componente React que muestre un modal de confirmación\"\r\n```\r\n**What happens:**\r\n- Finds similar components in your project\r\n- Analyzes their structure and patterns\r\n- Includes relevant utilities and hooks\r\n- Generates a prompt that matches your exact style\r\n\r\n### Refactor Legacy Code\r\n```bash\r\npromptune generate \"refactoriza para mejorar performance\" -f src/heavy-component.tsx\r\n```\r\n**What happens:**\r\n- Analyzes the target file\r\n- Finds similar patterns in your codebase\r\n- Includes best practices from your other components\r\n- Suggests optimizations aligned with your project\r\n\r\n### Generate Tests\r\n```bash\r\npromptune generate \"escribe tests completos para esta función\" -f src/utils/calculate.ts\r\n```\r\n**What happens:**\r\n- Detects your testing framework\r\n- Includes example tests from your project\r\n- Matches your testing patterns and assertions\r\n- Generates tests that work with your actual setup\r\n\r\n### Migrate Code\r\n```bash\r\npromptune generate \"migra esto de REST a tRPC\"\r\n```\r\n**What happens:**\r\n- Finds tRPC examples in your project (if they exist)\r\n- Understands your API structure\r\n- Generates migration plan with your actual types\r\n\r\n## Configuration\r\n\r\n### Via CLI Options\r\n```bash\r\npromptune generate \"your task\" \\\r\n  --model gpt-4 \\                    # GPT-4, Claude, etc.\r\n  --tokens 4000 \\                    # Max context tokens\r\n  --file src/target.ts \\             # Optional target file\r\n  --root . \\                         # Project root\r\n  --verbose                          # More detailed output\r\n```\r\n\r\n### Via Environment Variables\r\n```bash\r\nPROMPTUNE_MODEL=gpt-4\r\nPROMPTUNE_MAX_TOKENS=4000\r\nPROMPTUNE_VERBOSE=false\r\nOPENAI_API_KEY=sk-...\r\n```\r\n\r\n## How It Works Internally\r\n\r\n### 1. **Semantic Indexing**\r\n```\r\nYour Codebase\r\n    ↓\r\nExtract: functions, classes, types, imports, exports\r\n    ↓\r\nGenerate embeddings for semantic search\r\n    ↓\r\nDetect patterns and architecture\r\n    ↓\r\nCache results for speed\r\n```\r\n\r\n### 2. **Task Analysis**\r\n```\r\nUser Query: \"crea un hook useCart\"\r\n    ↓\r\nDetect action: CREATE\r\n    ↓\r\nFind related code: useAuth, useProducts patterns\r\n    ↓\r\nExtract constraints: Use Zustand, TypeScript strict mode, etc.\r\n    ↓\r\nEstimate token usage\r\n```\r\n\r\n### 3. **Prompt Generation**\r\n```\r\nCombine sections:\r\n  1. Base instruction (adapted to model)\r\n  2. Project context\r\n  3. Code style guide\r\n  4. Examples from repo\r\n  5. Relevant files\r\n  6. Constraints\r\n  7. Specific instructions\r\n    ↓\r\nResult: Highly contextualized prompt\r\n```\r\n\r\n## Project Structure\r\n\r\n```\r\nsrc/\r\n├── cli/                    # CLI interface\r\n│   ├── index.ts           # Command definitions\r\n│   └── core.ts            # Main orchestrator\r\n├── indexer/               # Code indexing engine\r\n│   └── index.ts           # Semantic indexing\r\n├── analyzer/              # Task understanding\r\n│   └── index.ts           # Context analysis\r\n├── generator/             # Prompt generation\r\n│   └── index.ts           # Prompt builder\r\n├── embeddings/            # RAG & semantic search\r\n│   └── index.ts           # Embedding utilities\r\n├── types/                 # TypeScript definitions\r\n│   └── index.ts           # Core types\r\n├── utils/                 # Helper functions\r\n│   └── file.ts            # File utilities\r\n└── index.ts              # Main export\r\n```\r\n\r\n## Advanced Usage\r\n\r\n### Programmatic API\r\n\r\n```typescript\r\nimport { PromptuneCore } from '@elilands/promptune';\r\n\r\nconst promptune = new PromptuneCore({\r\n  root: '/path/to/project',\r\n  aiModel: 'gpt-4',\r\n  maxContextTokens: 4000,\r\n  indexCacheDir: '.promptune',\r\n  verbose: false,\r\n  includePatterns: [],\r\n  excludePatterns: ['node_modules', 'dist'],\r\n});\r\n\r\n// Generate prompt\r\nconst result = await promptune.generatePrompt(\r\n  'crea un componente Button reutilizable',\r\n  'src/components/index.ts' // optional target file\r\n);\r\n\r\nif (result.success && result.prompt) {\r\n  console.log(result.prompt.prompt);\r\n  console.log(`Relevance: ${result.prompt.metadata.relevanceScore}%`);\r\n  console.log(`Tokens: ${result.prompt.metadata.tokenCount}`);\r\n}\r\n\r\n// Get project info\r\nconst info = await promptune.getProjectInfo();\r\nconsole.log(info.metadata);\r\nconsole.log(info.patterns);\r\n\r\n// Build/update index\r\nawait promptune.buildIndex(true); // force rebuild\r\n```\r\n\r\n### Extending Promptune\r\n\r\n```typescript\r\nimport {\r\n  CodeIndexer,\r\n  TaskAnalyzer,\r\n  PromptGenerator,\r\n  SemanticIndex,\r\n} from '@elilands/promptune';\r\n\r\n// Load index\r\nconst indexer = new CodeIndexer('/project/root');\r\nconst index = await indexer.buildIndex();\r\n\r\n// Analyze task\r\nconst analyzer = new TaskAnalyzer(index);\r\nconst taskContext = await analyzer.analyzeTask('your query');\r\n\r\n// Generate custom prompt\r\nconst generator = new PromptGenerator(index, 4000);\r\nconst prompt = generator.generatePrompt(taskContext, 'gpt-4');\r\n```\r\n\r\n## Supported Models\r\n\r\n- **OpenAI**: gpt-4, gpt-3.5-turbo\r\n- **Anthropic**: claude-3-opus, claude-3-sonnet, claude-3-haiku\r\n- **OpenRouter**: Any model via OpenRouter API\r\n- **Local**: Local LLMs (via OpenRouter or custom setup)\r\n\r\n## Performance\r\n\r\nPromptune is designed for speed:\r\n\r\n- **First run**: ~2-5 seconds (depending on project size)\r\n- **Subsequent runs**: <100ms (with cache)\r\n- **Memory**: Minimal footprint (~50-100MB for typical projects)\r\n\r\n## Caching\r\n\r\nPromptune automatically caches the semantic index in `.promptune/`:\r\n\r\n```bash\r\n# Clear cache\r\npromptune clean\r\n\r\n# Force rebuild index\r\npromptune index --force\r\n```\r\n\r\n## Development\r\n\r\n```bash\r\n# Install dependencies\r\nnpm install\r\n\r\n# Build\r\nnpm run build\r\n\r\n# Development mode\r\nnpm run dev\r\n\r\n# Testing\r\nnpm test\r\n\r\n# Linting\r\nnpm run lint\r\n\r\n# Format\r\nnpm run format\r\n```\r\n\r\n## Roadmap\r\n\r\n- [ ] **Vector embeddings** — Integration with OpenAI embeddings API\r\n- [ ] **Prompt evolution** — Learn from which prompts generate better results\r\n- [ ] **VS Code integration** — Generate prompts directly from editor\r\n- [ ] **Prompt templates** — Pre-built templates for common tasks\r\n- [ ] **Team settings** — Share project configuration across teams\r\n- [ ] **Web UI** — Visual prompt builder and preview\r\n- [ ] **Git integration** — Understand recent changes context\r\n- [ ] **Multi-language support** — Better support for non-JavaScript projects\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please:\r\n\r\n1. Fork the repository\r\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\r\n3. Commit changes (`git commit -m 'Add amazing feature'`)\r\n4. Push to branch (`git push origin feature/amazing-feature`)\r\n5. Open a Pull Request\r\n\r\n## License\r\n\r\nMIT License — see LICENSE file for details\r\n\r\n## Support\r\n\r\n- 📖 [Documentation](https://github.com/elilands/promptune/wiki)\r\n- 🐛 [Issue Tracker](https://github.com/elilands/promptune/issues)\r\n- 💬 [Discussions](https://github.com/elilands/promptune/discussions)\r\n\r\n## Why Promptune?\r\n\r\nTraditional prompt engineering is:\r\n- ❌ Manual and tedious\r\n- ❌ Generic across all projects\r\n- ❌ Requires understanding both code AND prompting\r\n- ❌ Hard to maintain as projects evolve\r\n\r\nPromptune solves this by:\r\n- ✅ Automating prompt generation\r\n- ✅ Understanding YOUR codebase\r\n- ✅ Matching your exact code style\r\n- ✅ Evolving with your project\r\n- ✅ Reducing LLM token usage (= lower costs)\r\n\r\n## See Also\r\n\r\n- [Cursor IDE](https://cursor.com) — AI-powered code editor\r\n- [Copilot](https://github.com/features/copilot) — GitHub's AI assistant\r\n- [Codeium](https://codeium.com) — Free AI code assistant\r\n- [Tabnine](https://www.tabnine.com) — AI code completion\r\n\r\n---\r\n\r\nMade with ❤️ by [@elilands](https://github.com/elilands)","readmeFilename":"README.md"}