using System.Collections.Generic;

using AIRuntime.Runtime.Capabilities.Attributes;


namespace AIRuntime.Runtime.Filesystem.Models
{
    /// <summary>
    /// Arguments for recursively inspecting a workspace directory.
    /// </summary>
    public sealed class ListDirectoryTreeArguments
    {
        private string _path =
            ".";


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

            set
            {
                _path =
                    value;
            }
        }

        [Range(1, 10)]
        [DefaultValue(10)]
        [Description("Maximum directory depth to inspect. Defaults to the full supported depth; direct children are depth 1.")]
        public int MaxDepth { get; set; } =
            10;

        [Range(1, 10000)]
        [DefaultValue(10000)]
        [Description("Maximum number of matching entries to return before truncating the result.")]
        public int MaxEntries { get; set; } =
            10000;

        [DefaultValue(true)]
        [Description("When true (the default), return directories only. Set false only when files are also requested.")]
        public bool DirectoriesOnly { get; set; } =
            true;

        [DefaultValue(false)]
        [Description("When false (the default), omit generated workspace folders such as Library, Temp, Logs, obj, .git, and .idea from a project-root traversal. Set true only for a literal full workspace tree.")]
        public bool IncludeGenerated { get; set; } =
            false;

        [DefaultValue(false)]
        [Description("Whether Unity .meta sidecar files should be included when directoriesOnly is false. Leave false for normal project trees; set true only for explicit metadata diagnostics.")]
        public bool IncludeMetaFiles { get; set; } =
            false;

        [Description("Optional file or directory names, or workspace-relative paths, to exclude from traversal.")]
        public List<string> Exclude { get; set; } =
            new List<string>();
    }


    /// <summary>
    /// Structured result returned by the directory-tree capability.
    /// </summary>
    public sealed class DirectoryTreeResult
    {
        public string Root { get; set; }

        public int MaxDepth { get; set; }

        public int InspectedEntries { get; set; }

        public bool Truncated { get; set; }

        public List<DirectoryTreeEntry> Entries { get; set; } =
            new List<DirectoryTreeEntry>();
    }


    /// <summary>
    /// One workspace entry discovered during directory traversal.
    /// </summary>
    public sealed class DirectoryTreeEntry
    {
        public string Path { get; set; }

        public string Name { get; set; }

        public bool IsDirectory { get; set; }

        public bool IsSymbolicLink { get; set; }

        public int Depth { get; set; }
    }
}
