CLI
The CLI package is @optiprune/cli. It is the supported command-line entry point for running the @optiprune/core analyzer. Install the CLI in the project you want to inspect:
npm install --save-dev @optiprune/cliAnalyze a project
Section titled “Analyze a project”Run the command from the project root:
npx @optiprune/cli analyzeanalyze is the default command, so this is equivalent:
npx @optiprune/cliUse explicit entry points when a project does not use conventional entries:
npx @optiprune/cli analyze \ --entry src/index.ts \ --entry src/worker.tsThe CLI discovers configuration, parses supported JavaScript and TypeScript files, builds the dependency graph, runs enabled plugins, and prints a terminal report. The default output is terminal text; use --json or --sarif for integrations.
Commands
Section titled “Commands”| Command | Purpose |
|---|---|
analyze [options] |
Analyze the current project. This is the default command. |
export-cache <targetPath> |
Export the current analysis cache. |
import-cache <sourcePath> |
Import an analysis cache before a run. |
--help |
Print command and option help. |
--version |
Print the CLI and detected Core versions. |
Reports and CI
Section titled “Reports and CI”# Structured JSON for scriptsnpx @optiprune/cli analyze --json
# SARIF for code-scanning toolsnpx @optiprune/cli analyze --sarif > optiprune.sarif
# Fail when high-confidence findings existnpx @optiprune/cli analyze --fail-on highThe terminal reporter begins with Optiprune Analysis Report, followed by the root, a summary, and findings grouped by file. Each finding includes a rule, message, and—when a source location exists—confidence. See Output for the exact format and Reporters for Core-level formatting functions.
Configuration and scope
Section titled “Configuration and scope”The CLI accepts project configuration from optiprune.json, optiprune.jsonc, optiprune.config.ts, optiprune.config.js, optiprune.config.mjs, or the package.json#optiprune field. See Configuration for precedence and examples.
Common options include:
| Option | Meaning |
|---|---|
--rootDir <path> |
Analyze a different project root. |
--entry <patterns...> |
Add entry-point files or globs. |
--extensions <exts...> |
Set source extensions; the default includes .ts, .tsx, .js, .jsx, and .vue. |
--ignore <patterns...> |
Ignore matching paths. |
--no-conventional-entries |
Disable automatic conventional entries such as src/index.ts. |
--cycles |
Include dependency-cycle information in human-readable output. |
--ignore-tests |
Exclude conventional test files. |
--verbose |
Include additional analyzer diagnostics. |
Controlled fixes
Section titled “Controlled fixes”Fixes are explicit and confidence-gated. Begin with a dry run:
npx @optiprune/cli analyze \ --fix files exports dependencies devDependencies conditions json \ --confidence medium+ \ --dry-runSupported fix targets are files, exports, dependencies, devDependencies, conditions, and safely recoverable json changes. Review the proposed diff before running without --dry-run; see Fixes for safety boundaries.
CLI versus Core API
Section titled “CLI versus Core API”Choose the CLI when you need a ready-to-run developer or CI command. Choose the Core API when another program owns orchestration, output, authentication, or user experience. The CLI and Core use the same analysis concepts, but they are separate npm packages and should be installed and documented separately.