import { URI } from "../../../../../../base/common/uri.js";
import { IFileService } from "../../../../../../platform/files/common/files.service.js";
import { IWorkspaceFolder } from "../../../../../../platform/workspace/common/workspace.js";
import { IWorkspaceContextService } from "../../../../../../platform/workspace/common/workspace.service.js";
import { IConfigurationService } from "../../../../../../platform/configuration/common/configuration.service.js";
import { IPromptSourceFolder, IResolvedPromptSourceFolder } from "../config/promptFileLocations.js";
import { PromptsType } from "../promptTypes.js";
import { IWorkbenchEnvironmentService } from "../../../../../services/environment/common/environmentService.service.js";
import { ISearchService } from "../../../../../services/search/common/search.service.js";
import { CancellationToken } from "../../../../../../base/common/cancellation.js";
import { AgentInstructionFileType, IPromptPath, IAgentInstructionFile, Logger, PromptsStorage } from "../service/promptsService.js";
import { IUserDataProfileService } from "../../../../../services/userDataProfile/common/userDataProfile.service.js";
import { Event } from "../../../../../../base/common/event.js";
import { ILogService } from "../../../../../../platform/log/common/log.service.js";
import { IPathService } from "../../../../../services/path/common/pathService.service.js";
import { IWorkspaceTrustManagementService } from "../../../../../../platform/workspace/common/workspaceTrust.service.js";
export interface IWorkspaceInstructionFile {
    readonly fileName: string;
    readonly type: AgentInstructionFileType;
}
/**
 * Utility class to locate prompt files.
 */
export declare class PromptFilesLocator {
    private readonly fileService;
    private readonly configService;
    private readonly workspaceService;
    private readonly environmentService;
    private readonly searchService;
    private readonly userDataService;
    private readonly logService;
    private readonly pathService;
    private readonly workspaceTrustManagementService;
    private readonly userDataFolder;
    constructor(fileService: IFileService, configService: IConfigurationService, workspaceService: IWorkspaceContextService, environmentService: IWorkbenchEnvironmentService, searchService: ISearchService, userDataService: IUserDataProfileService, logService: ILogService, pathService: IPathService, workspaceTrustManagementService: IWorkspaceTrustManagementService);
    protected getWorkspaceFolders(): readonly IWorkspaceFolder[];
    protected getWorkspaceFolder(resource: URI): IWorkspaceFolder | undefined;
    protected onDidChangeWorkspaceFolders(): Event<void>;
    /**
     * Returns the configured prompt source folders for the given type.
     * Subclasses can override to filter out unsupported sources.
     */
    protected getPromptSourceFolders(type: PromptsType): IPromptSourceFolder[];
    /**
     * Returns the default prompt source folders for the given type.
     * Subclasses can override to filter out unsupported sources.
     */
    protected getDefaultSourceFolders(type: PromptsType): readonly IPromptSourceFolder[];
    getWorkspaceFolderRoots(includeParents: boolean, logger?: Logger): Promise<URI[]>;
    /**
     * Walks up from {@link folderUri} collecting parent folders until a
     * repository root (a folder containing `.git`) is found.  Returns the
     * intermediate parent folders only when a repo root is found; returns
     * an empty array when the walk reaches the filesystem root, the user
     * home directory, or a folder already present in {@link seen}.
     */
    private findParentRepoFolders;
    /**
     * List all prompt files from the filesystem.
     *
     * @returns List of prompt files found in the workspace.
     */
    listFiles(type: PromptsType, storage: PromptsStorage, token: CancellationToken): Promise<readonly URI[]>;
    createFilesUpdatedEvent(type: PromptsType): {
        readonly event: Event<void>;
        dispose: () => void;
    };
    /**
     * Gets the hook source folders for creating new hooks.
     * Returns configured hook folders, excluding Claude paths (which are read-only).
     */
    getHookSourceFolders(): Promise<readonly IResolvedPromptSourceFolder[]>;
    /**
     * Get all possible unambiguous prompt file source folders based on
     * the current workspace folder structure.
     *
     * This method is currently primarily used by the `> Create Prompt`
     * command that providers users with the list of destination folders
     * for a newly created prompt file. Because such a list cannot contain
     * paths that include `glob pattern` in them, we need to process config
     * values and try to create a list of clear and unambiguous locations.
     *
     * @returns List of possible unambiguous prompt file folders.
     */
    getConfigBasedSourceFolders(type: PromptsType): Promise<readonly URI[]>;
    /**
     * Gets all resolved source folders for the given prompt type with metadata.
     * This method merges configured locations with default locations and resolves them
     * to absolute paths, including displayPath and isDefault information.
     *
     * The returned order prefers workspace (local) folders first, then user folders.
     * This is used for UX like the "Create Prompt" command where workspace is preferred.
     *
     * @param type The type of prompt files.
     * @returns List of resolved source folders with metadata.
     */
    getResolvedSourceFolders(type: PromptsType): Promise<readonly IResolvedPromptSourceFolder[]>;
    /**
     * Gets all resolved source folders in the same order that file discovery
     * searches them (user folders first, then local/workspace folders).
     * This matches the order used by {@link listFiles} and should be used
     * for debug/diagnostic output so the displayed order is accurate.
     */
    getSourceFoldersInDiscoveryOrder(type: PromptsType): Promise<readonly IResolvedPromptSourceFolder[]>;
    /**
     * Gets all local (workspace) storage folders for the given prompt type.
     * This merges default folders with configured locations.
     */
    private getLocalStorageFolders;
    /**
     * Deduplicates source folders by URI.
     */
    private dedupeSourceFolders;
    /**
     * Converts locations defined in `settings` to absolute filesystem path URIs with metadata.
     * This conversion is needed because locations in settings can be relative,
     * hence we need to resolve them based on the current workspace folders.
     * If userHome is provided, paths starting with `~` will be expanded. Otherwise these paths are ignored.
     * Preserves the type and location properties from the source folder definitions.
     */
    private toAbsoluteLocations;
    /**
     * Uses the file service to resolve the provided location and return either the file at the location of files in the directory.
     * For instruction folders, this searches recursively (up to {@link MAX_INSTRUCTIONS_RECURSION_DEPTH} levels deep) provided
     * the location is not a workspace folder root and does not contain wildcards, to support subdirectories while avoiding
     * accidentally broad traversal.
     */
    private resolveFilesAtLocation;
    /**
     * Uses the search service to find all files at the provided location.
     * Requires a FileSearchProvider to be available for the folder's scheme.
     */
    private searchFilesInLocation;
    /**
     * Gets list of `AGENTS.md` files anywhere in the workspace.
     */
    findAgentMDsInWorkspace(token: CancellationToken): Promise<IAgentInstructionFile[]>;
    private findAgentMDsInFolder;
    /**
     * Recursively traverses a folder using the file service to find AGENTS.md files.
     * This is used as a fallback when no FileSearchProvider is available for the scheme.
     */
    private findAgentMDsUsingFileService;
    findFilesInRoots(roots: URI[], folder: string | undefined, paths: IWorkspaceInstructionFile[], token: CancellationToken, result?: IAgentInstructionFile[]): Promise<IAgentInstructionFile[]>;
    getAgentFileURIFromModeFile(oldURI: URI): URI | undefined;
    private findAgentSkillsInFolder;
    /**
     * Searches for skills in all configured locations.
     */
    findAgentSkills(token: CancellationToken): Promise<IPromptPath[]>;
}
/**
 * Checks if the provided path contains a glob pattern (* or **).
 * Used to detect deprecated glob usage in prompt file locations.
 *
 * @param path - path to check
 * @returns `true` if the path contains `*` or `**`, `false` otherwise
 */
export declare function hasGlobPattern(path: string): boolean;
/**
 * Checks if the provided `pattern` could be a valid glob pattern.
 */
export declare function isValidGlob(pattern: string): boolean;
/**
 * Regex pattern string for validating paths for all prompt files.
 * Paths only support:
 * - Relative paths: someFolder, ./someFolder
 * - User home paths: ~/folder (only forward slash, not backslash for cross-platform sharing)
 * - Parent relative paths for monorepos: ../folder
 *
 * NOT supported:
 * - Absolute paths (portability issue)
 * - Glob patterns with * or ** (performance issue)
 * - Backslashes (paths should be shareable in repos across platforms)
 * - Tilde without forward slash (e.g., ~abc, ~\folder)
 * - Empty or whitespace-only paths
 *
 * The regex validates:
 * - Not a Windows absolute path (e.g., C:\, C:/)
 * - Not starting with / (Unix absolute path)
 * - No backslashes anywhere (use forward slashes only)
 * - If starts with ~, must be followed by /
 * - No glob pattern characters: * ? [ ] { }
 * - At least one non-whitespace character
 */
export declare const VALID_PROMPT_FOLDER_PATTERN = "^(?![A-Za-z]:[\\\\/])(?!/)(?!~(?!/))(?!.*\\\\)(?!.*[*?\\[\\]{}]).*\\S.*$";
/**
 * Validates if a path is allowed for simplified path configurations.
 * Only forward slashes are supported to ensure paths are shareable across platforms.
 */
export declare function isValidPromptFolderPath(path: string): boolean;
