/** * Upload policy module * * Pure policy for skillset uploads: which conflict-resolution actions are * offered, which one is the default, how versions are suggested and bumped, * how conflicts are auto-resolved or resolved via a `--resolve` strategy, and * how the `--resolve` CLI value is validated. * * This module contains no prompting, no CLI parsing, and no process control. * It must never import from `src/cli/`. */ import type { ExtractedSkillsSummary, ExtractedSubagentsSummary, FileChange, SkillConflict, SkillResolutionAction, SkillResolutionStrategy, SubagentConflict } from "../api/registrar.js"; /** * Result of an upload attempt */ export type UploadResult = { success: true; version: string; extractedSkills?: ExtractedSkillsSummary | null; extractedSubagents?: ExtractedSubagentsSummary | null; } | { success: false; error: string; } | { success: false; conflicts: Array; } | { success: false; subagentConflicts: Array; }; /** * Union type for resolution actions and the local-only "viewDiff" pseudo-action */ export type ConflictSelectAction = SkillResolutionAction | "viewDiff"; /** * Minimal conflict shape shared by skill and subagent conflicts, as needed by * the resolve-strategy application policy. */ type ResolvableConflict = { latestVersion?: string | null; availableActions: Array; }; /** * Count the number of entries in an optional fileChanges list. * * Returns 0 when the list is null, undefined, or empty. Used to pluralize the * "Use Existing" discard-count hint and to decide whether to render a note. * * @param args - The function arguments * @param args.fileChanges - Optional per-file change entries * * @returns The number of changed files (0 when absent or empty) */ export declare const countFileChanges: (args: { fileChanges?: ReadonlyArray | null; }) => number; /** * Build the "Use Existing" discard-clause hint. When `count` is > 0 the clause * is pluralized against the count; otherwise falls back to generic messaging * used for older registrars that did not return `fileChanges`. * * @param args - The function arguments * @param args.count - Number of file changes that would be discarded * * @returns Discard hint string */ export declare const formatDiscardHint: (args: { count: number; }) => string; /** * Build resolution options based on available actions for a conflict * * When content is unchanged, all three options are available (if the API allows them). * When content has changed, only "updateVersion" (if canPublish) and "namespace" are allowed. * * @param args - The function arguments * @param args.conflict - The skill conflict to build options for * @param args.skillsetName - The skillset name for namespace preview * @param args.hasDiffCallback - Whether a local-content reader is available for "View Diff" * * @returns Array of resolution options for the select prompt */ export declare const buildResolutionOptions: (args: { conflict: SkillConflict; skillsetName: string; hasDiffCallback?: boolean | null; }) => Array<{ value: ConflictSelectAction; label: string; hint?: string; }>; /** * Determine the default selection for a conflict * * When content is unchanged and link is available, default to "link". * When content has changed: * - Default to "updateVersion" if user can publish (canPublish === true) * - Otherwise default to "namespace" * * @param args - The function arguments * @param args.conflict - The skill conflict * * @returns The default action to select */ export declare const getDefaultAction: (args: { conflict: SkillConflict; }) => SkillResolutionAction; /** * Get the suggested next version for a skill * @param args - The function arguments * @param args.currentVersion - The current version string * @param args.fallback - Suggestion when no next patch version can be derived * (defaults to "1.0.0") * * @returns The suggested next patch version */ export declare const getSuggestedVersion: (args: { currentVersion?: string | null; fallback?: string | null; }) => string; /** * Check if a conflict can be auto-resolved (unchanged content + link available) * @param args - The function arguments * @param args.conflict - The skill conflict to check * * @returns True if the conflict can be auto-resolved */ export declare const canAutoResolveConflict: (args: { conflict: SkillConflict; }) => boolean; /** * Build auto-resolution strategy for conflicts that can be auto-resolved * @param args - The function arguments * @param args.conflicts - Array of skill conflicts * * @returns Strategy and unresolved conflicts */ export declare const buildAutoResolutionStrategy: (args: { conflicts: Array; }) => { strategy: SkillResolutionStrategy; unresolvedConflicts: Array; }; /** * Apply a `--resolve` action to every conflict that supports it. * * For "updateVersion" each conflict gets its own suggested next patch version. * Conflicts whose availableActions do not include the action are left * untouched and returned as still unresolved. * * @param args - The function arguments * @param args.conflicts - Conflicts not yet covered by another resolution * @param args.resolve - The resolution action to apply * @param args.getConflictId - Extracts the strategy key (skillId / subagentId) * * @returns Per-conflict resolutions and the still-unresolved remainder */ export declare const applyResolveStrategy: (args: { conflicts: Array; resolve: SkillResolutionAction; getConflictId: (args: { conflict: TConflict; }) => string; }) => { resolutions: SkillResolutionStrategy; stillUnresolved: Array; }; /** * Build resolution options common to all unresolved conflicts for batch mode. * Only includes actions available across ALL conflicts. * * @param args - The function arguments * @param args.conflicts - Array of unresolved skill conflicts * @param args.skillsetName - The skillset name for namespace preview * * @returns Array of resolution options available for all conflicts */ export declare const buildCommonResolutionOptions: (args: { conflicts: Array; skillsetName: string; }) => Array<{ value: SkillResolutionAction; label: string; hint?: string; }>; /** * Check if an upload result has conflicts * @param result - The upload result to check * * @returns True if the result contains conflicts */ export declare const hasConflicts: (result: UploadResult) => result is { success: false; conflicts: Array; }; /** * Check if an upload result has subagent conflicts * @param result - The upload result to check * * @returns True if the result contains subagent conflicts */ export declare const hasSubagentConflicts: (result: UploadResult) => result is { success: false; subagentConflicts: Array; }; /** * Determine the version to upload (auto-bump if not specified) * @param args - The function arguments * @param args.skillsetName - The skillset name * @param args.explicitVersion - Explicit version if provided * @param args.registryUrl - The registry URL * @param args.authToken - Auth token for the registry * * @returns The version to upload and whether this is a new package */ export declare const determineUploadVersion: (args: { skillsetName: string; explicitVersion?: string | null; registryUrl: string; authToken?: string | null; }) => Promise<{ version: string; isNewPackage: boolean; }>; /** * Actions accepted by the `--resolve` CLI flag */ export declare const VALID_RESOLVE_ACTIONS: ReadonlyArray; /** * Validate and type a `--resolve` CLI value. * * @param args - The function arguments * @param args.resolve - The raw `--resolve` value (null when the flag is absent) * * @returns The typed action (null when the flag is absent) or an error message */ export declare const parseResolveStrategy: (args: { resolve?: string | null; }) => { action: SkillResolutionAction | null; } | { error: string; }; export {}; //# sourceMappingURL=uploadPolicy.d.ts.map