@refactor-ai/ts-extract-variable
v0.1.4
Published
Extract an expression into a named constant.
Readme
@refactor-ai/ts-extract-variable
Extract an expression into a named constant.
Use Node.js 22+ and npm. Bun and a source checkout are unnecessary. This package supports TypeScript and JavaScript and includes only their compiler adapter. npm installs its pinned TypeScript dependency. This package has no install lifecycle scripts.
npx @refactor-ai/ts-extract-variable --help
npx @refactor-ai/ts-extract-variable plan --help
npx @refactor-ai/ts-extract-variable plan --project examples/typescript/tsconfig.json --file examples/typescript/math.ts --at 2:10 --end 2:22 --name totalReplace example paths with your project paths. Planning leaves sources untouched and returns a saved plan path. Preview and validate it, then apply that exact plan:
npx @refactor-ai/ts-extract-variable preview --plan ./path/to/plan.json
npx @refactor-ai/ts-extract-variable validate --plan ./path/to/plan.json
npx @refactor-ai/ts-extract-variable apply --plan ./path/to/plan.jsonOr install with npm install --save-dev @refactor-ai/ts-extract-variable and run npx refactor-ts-extract-variable --help. Only extract-variable can be planned by this tool. Plans use snapshots, compiler diagnostics and journaled writes. Validation does not run project tests. Full options, language support, limitations and examples are available in --help.
Built from refactor-ai 0.1.4. Third-party diff license: licenses/diff.txt.
Programmatic use
Importing the package does not execute the CLI, load a project or build the C# helper. createRefactor() returns an object with plan(options), preview(plan), validate(plan), apply(plan), loadPlan(path) and capabilities(project). Methods return objects and reject with Errors rather than printing CLI output. TypeScript declarations are included.
import { createRefactor } from "@refactor-ai/ts-extract-variable";
const refactor = await createRefactor();
const supported = await refactor.capabilities("./tsconfig.json");This API plans only extract-variable; omit operation in plan options. Read API.md for the complete interface, source-change workflow, coordinate conventions, language requirements and automation examples.
