{"_id":"@amit641/testpilot-ai","_rev":"3-898a86b2df73e3b998660ca333db4f02","name":"@amit641/testpilot-ai","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.0":{"name":"@amit641/testpilot-ai","version":"0.1.0","keywords":["test","testing","ai","llm","test-generation","vitest","jest","mocha","typescript","unit-test","automation","openai","anthropic","claude","gpt","coverage","self-healing","auto-fix","verify"],"author":"","license":"MIT","_id":"@amit641/testpilot-ai@0.1.0","maintainers":[{"name":"amit641","email":"amit.chowdhary2111@gmail.com"}],"homepage":"https://amit641.github.io/autotest/","bugs":{"url":"https://github.com/amit641/autotest/issues"},"bin":{"testpilot":"dist/cli.js"},"dist":{"shasum":"36d84936ca21ec3c7714dfc0da6ddf188131ecd2","tarball":"https://registry.npmjs.org/@amit641/testpilot-ai/-/testpilot-ai-0.1.0.tgz","fileCount":8,"integrity":"sha512-GmKMfVW36Gc+Z+vgwX1G5WrhNAGuA6yXy8t9/Yi/Wd17WbmfNtcfgrDButLNLi4HLZcdval00FdgZDMR+K7ZeA==","signatures":[{"sig":"MEQCIFbCaqMNBhNXh5rlOjLrI4HbafoGxuk78Yobr3Cc8os7AiARo1m/Et1235C9KL6g3Rec3/3j9pnH3IBuTSbjsEndqw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":297707},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"gitHead":"cbd950a39c63c558484dafecc1ba7c928b35b3a5","scripts":{"dev":"tsup --watch","lint":"tsc --noEmit","test":"vitest run","build":"tsup","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"amit641","email":"amit.chowdhary2111@gmail.com"},"repository":{"url":"git+https://github.com/amit641/autotest.git","type":"git"},"_npmVersion":"9.8.1","description":"AI-powered test generation that actually works. Generate, verify, and auto-fix tests with any LLM.","directories":{},"_nodeVersion":"18.18.1","dependencies":{"commander":"^12.0.0","aiclientjs":"^0.1.4","picocolors":"^1.0.0","typescript":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^2.0.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/testpilot-ai_0.1.0_1775389505656_0.5848176092354698","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@amit641/testpilot-ai","version":"0.2.0","keywords":["test","testing","ai","llm","test-generation","vitest","jest","mocha","typescript","unit-test","automation","openai","anthropic","claude","gpt","coverage","self-healing","auto-fix","verify"],"author":"","license":"MIT","_id":"@amit641/testpilot-ai@0.2.0","maintainers":[{"name":"amit641","email":"amit.chowdhary2111@gmail.com"}],"homepage":"https://amit641.github.io/autotest/","bugs":{"url":"https://github.com/amit641/autotest/issues"},"bin":{"testpilot":"dist/cli.js"},"dist":{"shasum":"0302b717c602e3ae8c6f89a28084b69a0008bcd5","tarball":"https://registry.npmjs.org/@amit641/testpilot-ai/-/testpilot-ai-0.2.0.tgz","fileCount":8,"integrity":"sha512-kHPy42+3Ddr9m17KiblZ1hQEeuZhoU/k1gKBYJxZm4RhjUhT47VkypSXE/tSvY4k2D5wP3JB+7LUy8Ani40rBA==","signatures":[{"sig":"MEUCIFmq6BD7f9xSYAoQEKi/SoFmUPlv1WBziAYi7uQDbdZjAiEAlpDffSjUiPmtzthYtIfwz3LgqqcdFUwmEOKg7EQ0oJw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":297707},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"gitHead":"0a55f1e144bd6ec5e4e24923f2a1c8d230a465cd","scripts":{"dev":"tsup --watch","lint":"tsc --noEmit","test":"vitest run","build":"tsup","test:watch":"vitest","prepublishOnly":"npm run build"},"_npmUser":{"name":"amit641","email":"amit.chowdhary2111@gmail.com"},"repository":{"url":"git+https://github.com/amit641/autotest.git","type":"git"},"_npmVersion":"9.8.1","description":"AI-powered test generation that actually works. Generate, verify, and auto-fix tests with any LLM.","directories":{},"_nodeVersion":"18.18.1","dependencies":{"commander":"^12.0.0","aiclientjs":"^0.1.4","picocolors":"^1.0.0","typescript":"^5.5.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^2.0.0","@types/node":"^22.0.0"},"_npmOperationalInternal":{"tmp":"tmp/testpilot-ai_0.2.0_1775390052340_0.6249764566597102","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@amit641/testpilot-ai","version":"1.0.0","description":"AI-powered test generation that actually works. Generate, verify, and auto-fix tests with any LLM.","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","bin":{"testpilot":"dist/cli.js"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}}},"scripts":{"build":"tsup","dev":"tsup --watch","test":"vitest run","test:watch":"vitest","lint":"tsc --noEmit","prepublishOnly":"npm run build"},"keywords":["test","testing","ai","llm","test-generation","vitest","jest","mocha","typescript","unit-test","automation","openai","anthropic","claude","gpt","coverage","self-healing","auto-fix","verify"],"author":"","license":"MIT","homepage":"https://amit641.github.io/autotest/","repository":{"type":"git","url":"git+https://github.com/amit641/autotest.git"},"bugs":{"url":"https://github.com/amit641/autotest/issues"},"engines":{"node":">=18.0.0"},"dependencies":{"aiclientjs":"^0.1.4","commander":"^12.0.0","picocolors":"^1.0.0","typescript":"^5.5.0"},"devDependencies":{"@types/node":"^22.0.0","tsup":"^8.0.0","vitest":"^2.0.0"},"_id":"@amit641/testpilot-ai@1.0.0","gitHead":"a1e7819ec92b2ebb14df55c767b631a9c4a52b63","_nodeVersion":"18.18.1","_npmVersion":"9.8.1","dist":{"integrity":"sha512-mrvglzvjs8ubs42WAnqGLtCjyPVGkOG8cKj1xQwhrln1TCVtU2euqf46C/Gno91MOLl4bZwV4i+O/CQboxyRyQ==","shasum":"8420c12f8f4a02d3fada109977023f119d62d885","tarball":"https://registry.npmjs.org/@amit641/testpilot-ai/-/testpilot-ai-1.0.0.tgz","fileCount":8,"unpackedSize":363370,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBtI9sK82Bg38IaZAuDaToyfaoiFcyVReWy5q2TC59c/AiEAk4/ulr/nrmyhCFj3oBwBSlO7V4jtJ1js87M4/vRinjI="}]},"_npmUser":{"name":"amit641","email":"amit.chowdhary2111@gmail.com"},"directories":{},"maintainers":[{"name":"amit641","email":"amit.chowdhary2111@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/testpilot-ai_1.0.0_1778589005031_0.42536798793891384"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-05T11:45:05.565Z","modified":"2026-05-12T12:30:05.267Z","0.1.0":"2026-04-05T11:45:05.806Z","0.2.0":"2026-04-05T11:54:12.479Z","1.0.0":"2026-05-12T12:30:05.170Z"},"bugs":{"url":"https://github.com/amit641/autotest/issues"},"license":"MIT","homepage":"https://amit641.github.io/autotest/","keywords":["test","testing","ai","llm","test-generation","vitest","jest","mocha","typescript","unit-test","automation","openai","anthropic","claude","gpt","coverage","self-healing","auto-fix","verify"],"repository":{"type":"git","url":"git+https://github.com/amit641/autotest.git"},"description":"AI-powered test generation that actually works. Generate, verify, and auto-fix tests with any LLM.","maintainers":[{"name":"amit641","email":"amit.chowdhary2111@gmail.com"}],"readme":"<p align=\"center\">\n  <h1 align=\"center\">testpilot-ai</h1>\n  <p align=\"center\">AI-powered test generation that actually works.<br/>Generate, verify, and auto-fix tests with any LLM.</p>\n</p>\n\n<p align=\"center\">\n  <a href=\"https://www.npmjs.com/package/@amit641/testpilot-ai\"><img src=\"https://img.shields.io/npm/v/@amit641/testpilot-ai.svg\" alt=\"npm version\" /></a>\n  <a href=\"https://www.npmjs.com/package/@amit641/testpilot-ai\"><img src=\"https://img.shields.io/npm/dm/@amit641/testpilot-ai.svg\" alt=\"npm downloads\" /></a>\n  <a href=\"https://github.com/amit641/autotest/blob/main/LICENSE\"><img src=\"https://img.shields.io/npm/l/testpilot-ai.svg\" alt=\"license\" /></a>\n</p>\n\n<p align=\"center\">\n  <a href=\"https://amit641.github.io/autotest/\">Docs</a> · <a href=\"#install\">Install</a> · <a href=\"#quick-start\">Quick Start</a> · <a href=\"https://github.com/amit641/autotest\">GitHub</a>\n</p>\n\n---\n\n## Why testpilot-ai?\n\nMost AI test generators write tests that **don't pass**. testpilot-ai generates, runs, and auto-fixes tests in a loop until they actually work — and never lets the test file regress beyond the best version it has seen.\n\n- **Self-healing tests** — Verify & auto-fix loop with best-version persistence and oscillation detection\n- **AST analysis** — TypeScript compiler API extracts functions, classes, types, JSDoc\n- **Bounded import context** — Follows relative imports *and* tsconfig path aliases (`@/foo`, `~lib/*`) back into your project, capped at 5 files × 3 KB\n- **Coverage-gap filling** — Parse lcov/cobertura, generate tests for uncovered code\n- **Any LLM** — OpenAI, Anthropic, Google, Ollama (local models)\n- **4 frameworks** — Vitest, Jest, Mocha, Node test runner\n- **Cost & concurrency controls** — `--max-cost <usd>` and `--concurrency <n>` for safe parallel runs\n- **Analyze command** — Find files that need tests\n\n## Install\n\n```bash\nnpm install -D @amit641/testpilot-ai\n```\n\n## Quick Start\n\n```bash\n# Generate tests for a file\nnpx testpilot src/utils.ts\n\n# Generate AND verify — auto-fix until all tests pass\nnpx testpilot src/utils.ts --verify\n\n# Use a specific provider\nnpx testpilot src/utils.ts --provider anthropic --model claude-sonnet-4-20250514\n\n# Analyze your project for untested files\nnpx testpilot analyze\n\n# Use local models with Ollama (no API key needed)\nnpx testpilot src/utils.ts --provider ollama --model llama3\n```\n\n## The Verify & Auto-Fix Loop\n\nThe killer feature. With `--verify`, testpilot-ai doesn't just generate tests — it **runs them and fixes failures automatically**:\n\n```bash\nnpx testpilot src/utils.ts --verify\n```\n\n```\n⚡ testpilot — AI-powered test generation\n\n  Provider: openai (gpt-4o)\n  Framework: vitest\n  Verify & fix: enabled\n\n● Generating tests for utils.ts...\n\n✔ wrote src/utils.test.ts\n▶ Verify iteration 1/3...\n⚠ 3/12 tests failed — sending to LLM for auto-fix...\n▶ Verify iteration 2/3...\n✔ All 12 tests pass!\n\nDone! Generated 12 tests across 1 file(s)\n✔ All tests verified and passing\n```\n\nThe loop:\n1. **Generate** tests using AST analysis + LLM\n2. **Run** them with your test framework\n3. **Collect** failures with error messages and stack traces\n4. **Send** failures back to the LLM: \"here's the source code, here's the failing test, here's the error — fix it\"\n5. **Write** the fixed tests and **repeat** (up to 3 iterations by default)\n\n## Analyze Your Project\n\nFind files that need tests, optionally using coverage data:\n\n```bash\nnpx testpilot analyze\n```\n\n```\n⚡ testpilot analyze\n\n  Coverage: 67.3% (1240/1842 lines)\n  Target: 80%\n  Files: 23\n\nFiles below target:\n\n  File                                 Coverage   Tests?\n  ──────────────────────────────────────────────────────\n  src/utils/parser.ts                  12.5%      no\n  src/services/auth.ts                 34.2%      yes\n  src/handlers/webhook.ts              45.0%      no\n  src/middleware/cors.ts               61.8%      yes\n\nGenerate tests: testpilot generate <file> --verify\n```\n\nIf no coverage data exists, it scans for source files without corresponding test files.\n\n## CLI Reference\n\n```\nUsage: testpilot [options] [command]\n\nCommands:\n  generate <target>  Generate tests for a file or directory (default)\n  analyze            Analyze project for files needing tests\n  help [command]     Display help\n\nGenerate Options:\n  -p, --provider <provider>   LLM provider (openai, anthropic, google, ollama)\n  -m, --model <model>         Model to use\n  -k, --api-key <key>         API key (or use env var)\n  -f, --framework <framework> Test framework: vitest, jest, mocha, node\n  -o, --out-dir <dir>         Output directory for test files\n  --overwrite                 Overwrite existing test files\n  --verify                    Run tests and auto-fix failures\n  --fix-iterations <n>        Max auto-fix iterations (default: 3)\n  -c, --concurrency <n>       Process N files in parallel (default: 1)\n  --max-cost <usd>            Abort the run if estimated cost exceeds this USD amount\n  --no-edge-cases             Skip edge case tests\n  --no-error-handling         Skip error handling tests\n  --instructions <text>       Additional instructions for the LLM\n  --dry-run                   Preview without writing files\n  -V, --version               Output the version number\n\nAnalyze Options:\n  -t, --target <rate>         Coverage target (0-1, default: 0.8)\n  -l, --limit <n>             Max files to show (default: 15)\n```\n\n## How It Works\n\n```\nSource File → TS Analyzer → Import Context → Prompt Engine → LLM → Test Writer\n                                                                        ↓\n                                                          ┌──── Verify Loop ────┐\n                                                          │  Run → Fix → Run    │\n                                                          │  (best-version kept)│\n                                                          └─────────────────────┘\n```\n\n1. **Analyze** — TypeScript compiler API extracts functions, classes, parameters, types, JSDoc\n2. **Context** — Follows relative imports *and* tsconfig path aliases (`@/foo`, `~lib/*`) back into the project; capped at 5 files × 3 KB; deduped; `node_modules` skipped\n3. **Prompt** — Builds rich prompts with exact import lines, parameter types, source code, and labeled \"for context only\" related files\n4. **Generate** — Streams output from any LLM provider via [aiclientjs](https://www.npmjs.com/package/aiclientjs); aborts up-front if `--max-cost` would be exceeded\n5. **Write** — Line-based fence state machine strips markdown wrappers without breaking triple-backtick string literals inside the test code\n6. **Verify** *(optional)* — Runs tests; trusts the runner's exit code as the only authoritative pass/fail signal; consolidates per-failure markers across reporters; sends only the failure deltas back to the LLM; **rolls back if a fix iteration regresses**; stops early if the same failures repeat (oscillation)\n\n## Configuration\n\n```json\n{\n  \"provider\": \"anthropic\",\n  \"model\": \"claude-sonnet-4-20250514\",\n  \"framework\": \"vitest\",\n  \"edgeCases\": true,\n  \"errorHandling\": true,\n  \"maxTokens\": 4096,\n  \"temperature\": 0.2\n}\n```\n\nSave as `autotest.config.json`, `.autotestrc`, or add to `package.json` under `\"autotest\"`.\n\n**Priority:** CLI flags > Config file > package.json > Auto-detected framework > Defaults\n\n## Supported Providers\n\n| Provider | Models | Env Variable |\n|----------|--------|-------------|\n| **OpenAI** | gpt-4o, gpt-4o-mini, o1 | `OPENAI_API_KEY` |\n| **Anthropic** | claude-sonnet-4-20250514, claude-haiku | `ANTHROPIC_API_KEY` |\n| **Google** | gemini-pro, gemini-1.5-pro | `GOOGLE_API_KEY` |\n| **Ollama** | llama3, codellama, mistral | None (local) |\n\n## Programmatic API\n\n```typescript\nimport { generateTests, analyzeFile, resolveConfig } from '@amit641/testpilot-ai';\n\nconst config = resolveConfig({ provider: 'openai', model: 'gpt-4o' });\n\n// Generate with verify & auto-fix\nconst result = await generateTests('src/utils.ts', config, {\n  verify: true,\n  maxFixIterations: 3,\n  onStatus: (msg) => console.log(msg),\n});\n\nconsole.log(`${result.testCount} tests, verified: ${result.verified}`);\n```\n\n## Architecture\n\n```\nsrc/\n├── analyzer/      # TS AST analysis + import context gathering\n├── prompt/        # Framework-aware prompt generation\n├── llm/           # LLM client (via aiclientjs)\n├── writer/        # Output parser & file writer\n├── verify/        # Test runner + auto-fix loop\n├── coverage/      # LCOV & Cobertura coverage parsing\n├── frameworks/    # Vitest, Jest, Mocha, Node adapters\n├── config/        # Config resolution & merging\n├── generate.ts    # Main orchestrator\n├── cli.ts         # Commander-based CLI\n├── types.ts       # Core types\n└── index.ts       # Public API\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}