using AIRuntime.Runtime.Capabilities.Attributes;


namespace AIRuntime.Runtime.Filesystem.Models
{
    /// <summary>
    /// Selects which immediate directory entries should be returned.
    /// </summary>
    public enum DirectoryEntryFilter
    {
        All,

        Files,

        Directories
    }

    /// <summary>
    /// Selects the representation returned for directory entries.
    /// </summary>
    public enum DirectoryEntryOutputFormat
    {
        Metadata,

        PathsOnly
    }


    /// <summary>
    /// Arguments for listing one workspace directory.
    /// Empty or omitted paths refer to the workspace root.
    /// </summary>
    public sealed class ListDirectoryArguments
    {
        private string _path =
            ".";


        [Required]
        [WorkspacePath]
        [DefaultValue(".")]
        [Description("Directory path relative to the current workspace. Use '.' for the workspace root.")]
        public string Path
        {
            get
            {
                return string.IsNullOrWhiteSpace(
                    _path)
                    ? "."
                    : _path;
            }

            set
            {
                _path =
                    value;
            }
        }

        [DefaultValue("All")]
        [Description("Entry type to return. Use Files for file-only requests and Directories for folder-only requests.")]
        public DirectoryEntryFilter EntryType { get; set; } =
            DirectoryEntryFilter.All;

        [DefaultValue("Metadata")]
        [Description("Result representation. Use PathsOnly for exact path-list requests to avoid unnecessary metadata and reduce token usage.")]
        public DirectoryEntryOutputFormat OutputFormat { get; set; } =
            DirectoryEntryOutputFormat.Metadata;

        [DefaultValue(false)]
        [Description("Whether Unity .meta sidecar files should be included. Leave false for normal user-facing file and asset lists; set true only for explicit metadata diagnostics.")]
        public bool IncludeMetaFiles { get; set; }
    }


    /// <summary>
    /// Arguments for an operation targeting one workspace path.
    /// </summary>
    public sealed class FileSystemPathArguments
    {
        [Required]
        [WorkspacePath]
        [Description("Path relative to the current workspace.")]
        public string Path { get; set; }
    }


    /// <summary>
    /// Arguments for creating one directory inside an exact parent path.
    /// Keeping the two values separate prevents models from dropping the
    /// final parent segment when interpreting "create NAME in PARENT".
    /// </summary>
    public sealed class CreateDirectoryArguments
    {
        [Required]
        [WorkspacePath]
        [Description("Complete parent directory path relative to the workspace. Preserve every parent segment. Use '.' for the workspace root.")]
        public string ParentPath { get; set; }

        [Required]
        [Description("Exact name of the new directory. When createParents=true, a relative nested chain is also accepted and created safely; do not repeat parentPath.")]
        public string DirectoryName { get; set; }

        [DefaultValue(false)]
        [Description("Whether missing parent directories may be created. Use true when the user asks to create a complete path. Use false when the user asks to add a child to a named parent.")]
        public bool CreateParents { get; set; }
    }


    /// <summary>
    /// Arguments for copying or moving a workspace file.
    /// </summary>
    public sealed class FileTransferArguments
    {
        [Required]
        [ExistingFile]
        [Description("Existing source file path relative to the current workspace.")]
        public string SourcePath { get; set; }

        [Required]
        [WorkspacePath]
        [Description("Destination file path relative to the current workspace.")]
        public string DestinationPath { get; set; }
    }


    /// <summary>
    /// Arguments for deleting a workspace directory.
    /// </summary>
    public sealed class DeleteDirectoryArguments
    {
        [Required]
        [WorkspacePath]
        [Description("Directory path relative to the current workspace.")]
        public string Path { get; set; }

        [DefaultValue(false)]
        [Description("Whether to delete all nested files and directories.")]
        public bool Recursive { get; set; }
    }


    /// <summary>
    /// Structured confirmation returned by filesystem mutations.
    /// </summary>
    public sealed class FileSystemMutationResult
    {
        public bool Succeeded { get; set; }

        public string Path { get; set; }

        public string Message { get; set; }

        public string ResponseInstruction { get; set; }
    }
}
