import type { Workspace } from '../../pm/index.ts';
export interface PeerDependencyMeta {
    optional?: boolean;
}
export interface PackageJson {
    [key: string]: unknown;
    dependencies?: Record<string, string>;
    devDependencies?: Record<string, string>;
    peerDependencies?: Record<string, string>;
    peerDependenciesMeta?: Record<string, PeerDependencyMeta>;
}
export declare function readPackageJson(location: string): PackageJson;
export declare function writePackageJson(location: string, pkg: PackageJson): void;
/**
 * Move a dependency from one section to another (e.g. dependencies → devDependencies).
 * When moving out of `peerDependencies`, the corresponding
 * `peerDependenciesMeta` entry is cleared so it does not dangle.
 */
export declare function moveDep(pkg: PackageJson, dep: string, from: string, to: string): void;
/**
 * Remove a dependency from a section. When the section is `peerDependencies`,
 * also strip any matching `peerDependenciesMeta` entry so meta does not
 * dangle for a peer that is no longer declared.
 */
export declare function removeDep(pkg: PackageJson, dep: string, section: string): void;
/**
 * Add a dependency to a section with a resolved version.
 */
export declare function addDep(pkg: PackageJson, dep: string, version: string, section: string): void;
/**
 * Set or clear `peerDependenciesMeta[dep].optional`. Only meaningful for
 * peers declared in `peerDependencies`.
 *
 * - `optional === true`  → ensure `{ optional: true }` is set.
 * - `optional === false` → clear any optional flag (and the entry itself if
 *                          it would otherwise be `{}`).
 * - `optional === undefined` → no-op; existing meta is preserved.
 */
export declare function setPeerOptional(pkg: PackageJson, dep: string, optional: boolean | undefined): void;
export type PeerBoundType = 'major' | 'minor';
export declare function isOpaqueVersionSpec(version: string | undefined): boolean;
/**
 * Format an installed version as a broad peerDependency range. The upper
 * bound is the next major (`'major'`, default) or next minor (`'minor'`):
 *   5.5.1, 'major'        -> '>=5.5.1 <6'
 *   0.5.1, 'major'        -> '>=0.5.1 <1'
 *   7.11.5, 'minor'       -> '>=7.11.5 <7.12'
 *   5.5.1-beta.0, 'major' -> '>=5.5.1-beta.0 <6'
 * Falls back to `~<version>` if the version cannot be parsed.
 */
export declare function formatPeerRange(version: string, boundType?: PeerBoundType): string;
/**
 * Compute the expected dependency/devDependency range. External package
 * entries use a tilde range pinned to a full three-part lower bound.
 */
export declare function resolveExpectedDependencyVersion(location: string, dep: string, range?: string): string;
/**
 * Resolve the version for a missing devDependency or dependency.
 * Looks in node_modules first, then falls back to '*'.
 */
export declare function resolveDepVersion(location: string, dep: string): string;
/**
 * Resolve the version for a missing peerDependency. Returns full-patch caret
 * form anchored at the devDependency lower bound when known, or the installed
 * version otherwise.
 */
export declare function resolvePeerDepVersion(location: string, dep: string, devRange?: string): string;
/**
 * Compute the expected peerDependency range for a dep. Anchored at the
 * devDependency's `minVersion` when available (so the peer range is a
 * superset of devDep), otherwise the installed version. Produces
 * `>=<lowerBound> <<major+1>`; falls back to '*' if nothing is known.
 */
export declare function resolveExpectedPeerVersion(location: string, dep: string, devRange?: string, boundType?: PeerBoundType): string;
/**
 * Compute the non-broad peerDependency range for a dep. The result is a
 * caret range anchored at a full three-part lower bound. Prefer the sibling
 * devDependency floor; fall back to the current peer range and then the
 * installed version.
 */
export declare function resolveExpectedPeerShorthandVersion(location: string, dep: string, devRange?: string, peerRange?: string): string;
/**
 * Single entry-point used by every rule that writes a peerDependency range.
 * Produces the form configured for `dep.peerDependencies.range-style`
 * directly, so the range-style rule never has to follow up another rule's
 * fix in a second pass. That removes the 2-pass cascade that could oscillate
 * when an upstream rule re-fired on every pass.
 */
export declare function resolvePeerVersionForFix(location: string, dep: string, devRange: string | undefined, form: 'broad' | 'shorthand', boundType?: PeerBoundType): string;
/**
 * Compute the expected devDependency range for a dep when bumping to match
 * the installed peer. Returns `~<major>.<minor>` (e.g. `~7.6`); falls back to
 * `~<version>` if parsing fails or '*' if no installed version is found.
 */
export declare function resolveExpectedDevVersion(location: string, dep: string): string;
export declare function logFix(workspace: Workspace, action: string, dep: string, detail?: string): void;
//# sourceMappingURL=packageJsonEditor.d.ts.map