{"_id":"@codeceptjs/reflection","_rev":"3-8432a7193ef56814058f7b4b9e9fcee0","name":"@codeceptjs/reflection","dist-tags":{"latest":"0.5.2"},"versions":{"0.1.0":{"name":"@codeceptjs/reflection","version":"0.1.0","keywords":["codeceptjs","ast","reflection","heal","testing","scenario","refactor"],"license":"MIT","_id":"@codeceptjs/reflection@0.1.0","maintainers":[{"name":"egor_bodnar","email":"maxameron@gmail.com"},{"name":"davert","email":"davert.ua@gmail.com"}],"dist":{"shasum":"c50f89a75177b085097297d2c08c5b58ce952394","tarball":"https://registry.npmjs.org/@codeceptjs/reflection/-/reflection-0.1.0.tgz","fileCount":25,"integrity":"sha512-lBSjhbODQrREFPo0t/hqh116s/Kq1ikebaafpCF7rj5ehuiCXDkGsQcSZNDilSrI2Lw+d1ZLYNbJFQv57zSWKg==","signatures":[{"sig":"MEQCIFvknyzRktdz9YwMcVA6kCpsFwptEEDagD8Jry/RsJ0pAiARpFJTX038viA7dxTdL3vVwfYdQy7TdEsk2uQvwbW5Cg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":88376},"main":"./src/index.js","type":"module","types":"./src/types.d.ts","engines":{"node":">=18"},"exports":{".":"./src/index.js","./errors":"./src/errors.js"},"gitHead":"909c877c5f6314e995b30d039ad722fc75241d8a","scripts":{"test":"vitest run","test:unit":"vitest run test/unit","typecheck":"tsc --noEmit","test:watch":"vitest","test:coverage":"vitest run --coverage","test:integration":"vitest run test/integration"},"_npmUser":{"name":"davert","email":"davert.ua@gmail.com"},"_npmVersion":"10.9.4","description":"AST-based reflection for CodeceptJS tests, suites, and steps. Safely read and edit scenario source without regex.","directories":{},"_nodeVersion":"22.21.1","dependencies":{"diff":"^5.2.0","acorn":"^8.15.0","acorn-walk":"^8.3.0","magic-string":"^0.30.0"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^1.6.0","typescript":"^5.9.0","@vitest/coverage-v8":"^1.6.0"},"peerDependencies":{"codeceptjs":">=3.0.0","typescript":">=4.0.0"},"peerDependenciesMeta":{"codeceptjs":{"optional":true},"typescript":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/reflection_0.1.0_1776084255798_0.8321364931049537","host":"s3://npm-registry-packages-npm-production"}},"0.5.2":{"name":"@codeceptjs/reflection","version":"0.5.2","description":"AST-based reflection for CodeceptJS tests, suites, and steps. Safely read and edit scenario source without regex.","type":"module","main":"./src/index.js","exports":{".":"./src/index.js","./errors":"./src/errors.js"},"types":"./src/types.d.ts","scripts":{"test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage","test:integration":"vitest run test/integration","test:unit":"vitest run test/unit","typecheck":"tsc --noEmit"},"dependencies":{"acorn":"^8.15.0","acorn-walk":"^8.3.0","diff":"^5.2.0","glob":"^10.5.0","magic-string":"^0.30.0"},"peerDependencies":{"codeceptjs":">=3.0.0","typescript":">=4.0.0"},"peerDependenciesMeta":{"codeceptjs":{"optional":true},"typescript":{"optional":true}},"devDependencies":{"@vitest/coverage-v8":"^1.6.0","typescript":"^5.9.0","vitest":"^1.6.0"},"engines":{"node":">=18"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/codeceptjs/reflection.git"},"homepage":"https://github.com/codeceptjs/reflection#readme","bugs":{"url":"https://github.com/codeceptjs/reflection/issues"},"publishConfig":{"access":"public","provenance":true},"keywords":["codeceptjs","ast","reflection","heal","testing","scenario","refactor"],"gitHead":"9fdc79cc6965da1a8dc08b1451b8cc7d64297540","_id":"@codeceptjs/reflection@0.5.2","_nodeVersion":"24.14.1","_npmVersion":"11.12.1","dist":{"integrity":"sha512-PfoPmbrRLeUBgeqXrULylPeqtpNRAO0ra26yEusrwiGwhYp5uNFqSgrTP8jVk2qW2mRScKQF51nJX2DOiw5iaA==","shasum":"ccc921a8d30a10b0c357476c05ca073c30f8e13b","tarball":"https://registry.npmjs.org/@codeceptjs/reflection/-/reflection-0.5.2.tgz","fileCount":29,"unpackedSize":116397,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@codeceptjs%2freflection@0.5.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDjnyETb5nEbE+ym7pQFBNH2bN2zE3W5DP/JAFIwyMFNwIhAJgv+KdzOuzsIkQrMUGmRVrs13SIftRuAFkx0dDYqG3G"}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:98cb1abe-77f2-4f47-9182-71b8591d00ea"}},"directories":{},"maintainers":[{"name":"davert","email":"davert.ua@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/reflection_0.5.2_1776157922607_0.8218993200446087"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-13T12:44:15.724Z","modified":"2026-04-14T09:12:03.093Z","0.1.0":"2026-04-13T12:44:15.938Z","0.5.2":"2026-04-14T09:12:02.754Z"},"license":"MIT","keywords":["codeceptjs","ast","reflection","heal","testing","scenario","refactor"],"description":"AST-based reflection for CodeceptJS tests, suites, and steps. Safely read and edit scenario source without regex.","maintainers":[{"name":"davert","email":"davert.ua@gmail.com"}],"readme":"# @codeceptjs/reflection\n\n[![Test](https://github.com/codeceptjs/reflection/actions/workflows/test.yml/badge.svg)](https://github.com/codeceptjs/reflection/actions/workflows/test.yml)\n[![npm](https://img.shields.io/npm/v/@codeceptjs/reflection.svg)](https://www.npmjs.com/package/@codeceptjs/reflection)\n\nAST-based reflection for CodeceptJS tests, suites, and steps. Safely read and edit scenario source without regex.\n\n## Install\n\n```bash\nnpm install @codeceptjs/reflection\n```\n\n## Why\n\nCodeceptJS test runners, healers, AI agents, and MCP servers need to read and rewrite scenario source code. Doing that with regex is fragile and unsafe. This package gives you a principled, AST-driven API to locate a step, test, or suite in its source file, read the exact range, and replace it while preserving formatting, comments, and metadata.\n\n## Quick start\n\n```js\nimport { Reflection } from '@codeceptjs/reflection'\n\n// You have a live CodeceptJS test object (from event.test.before, event.test.after, etc.)\nconst tr = Reflection.forTest(test)\n\nconsole.log(tr.read())              // full Scenario(...) source\nconsole.log(tr.fileName)            // path to the source file\n\n// Build an edit — nothing is written yet\nconst edit = tr.replace(`Scenario('login works', async ({ I }) => { I.amOnPage('/') })`)\n\nconsole.log(edit.diff())            // unified diff preview\nconsole.log(edit.preview())         // full new source\nedit.apply()                        // atomic write to disk\n```\n\n## Reflection classes\n\n```js\nReflection.forStep(step, { test })           // StepReflection\nReflection.forTest(test)                     // TestReflection\nReflection.forSuite(suite)                   // SuiteReflection — addTest/removeTest\nReflection.forPageObject(filePath, { name }) // PageObjectReflection — add/replace/remove members\nReflection.project('./codecept.conf.js')     // ProjectReflection — enumerate suites, tests, steps, page objects\n```\n\nEach `forX` reflector exposes the same shape: `fileName`, `read()`, `replace()`, plus type-specific accessors. `SuiteReflection` and `PageObjectReflection` also support programmatic add/remove of children.\n\n`Reflection.project(...)` reads a CodeceptJS config and gives you the map of the whole project — then hands off individual targets to the specialized reflectors.\n\n## Batching\n\nReplace multiple things in one file, one write:\n\n```js\nconst batch = Reflection.batch(filePath)\nbatch.add(sr1.replace('I.click(\"a\")'))\nbatch.add(sr2.replace('I.click(\"b\")'))\nbatch.apply()\n```\n\n## Documentation\n\n- [Getting started](./docs/getting-started.md)\n- [API reference](./docs/api/)\n- [Heal plugin integration](./docs/guides/heal-plugin-integration.md)\n- [AI-assisted editing](./docs/guides/ai-assisted-editing.md)\n- [Limitations](./docs/limitations.md)\n\n## Requirements\n\n- Node.js 18+\n- CodeceptJS 3.x or 4.x (optional peer — only needed at runtime by consumers)\n- `typescript` package (optional peer — only needed if you reflect `.ts` / `.tsx` files)\n\n## License\n\nMIT\n","readmeFilename":"README.md","homepage":"https://github.com/codeceptjs/reflection#readme","repository":{"type":"git","url":"git+https://github.com/codeceptjs/reflection.git"},"bugs":{"url":"https://github.com/codeceptjs/reflection/issues"}}