+ "details": "## Implementation Steps\n\n### 1. Schema Change - Add Accessibility Column (AiCodeGraph.Core/Storage/SchemaDefinition.cs)\n\nAdd a new column to the Methods table definition:\n```csharp\nCREATE TABLE Methods (\n ...\n IsAbstract INTEGER NOT NULL DEFAULT 0,\n Accessibility TEXT NOT NULL DEFAULT 'Public' // NEW COLUMN\n);\n```\n\n### 2. Update InsertMethod to Persist Accessibility (AiCodeGraph.Core/Storage/StorageService.cs:141-162)\n\nModify the INSERT statement and add parameter:\n```csharp\ncmd.CommandText = \"\"\"\n INSERT OR IGNORE INTO Methods (Id, Name, FullName, ReturnType, TypeId, StartLine, EndLine, FilePath, IsStatic, IsAsync, IsVirtual, IsOverride, IsAbstract, Accessibility)\n VALUES (@id, @name, @fullName, @ret, @tid, @start, @end, @path, @isStatic, @isAsync, @isVirtual, @isOverride, @isAbstract, @accessibility)\n \"\"\";\n// Add parameter for Accessibility:\ncmd.Parameters.AddWithValue(\"@accessibility\", method.Accessibility.ToString());\n```\n\n### 3. Update GetTreeAsync Signature and Query (AiCodeGraph.Core/Storage/StorageService.cs:451-490)\n\nChange method signature to accept visibility filter:\n```csharp\npublic async Task<List<(string ProjectName, string NamespaceName, string TypeName, string TypeKind, string MethodName, string ReturnType, string Accessibility)>> GetTreeAsync(\n string? namespaceFilter = null, \n string? typeFilter = null,\n bool includePrivate = false,\n bool includeConstructors = false, // Always false by default\n CancellationToken cancellationToken = default)\n```\n\nUpdate the SQL query:\n```csharp\n// Add constructor filter (always applied unless explicitly requested)\nif (!includeConstructors)\n conditions.Add(\"m.Name NOT IN ('.ctor', '.cctor')\");\n\n// Add visibility filter (public-only by default)\nif (!includePrivate)\n conditions.Add(\"m.Accessibility = 'Public'\");\n\ncmd.CommandText = $\"\"\"\n SELECT p.Name, n.FullName, t.Name, t.Kind, m.Name, m.ReturnType, m.Accessibility\n FROM Projects p\n JOIN Namespaces n ON n.ProjectId = p.Id\n JOIN Types t ON t.NamespaceId = n.Id\n JOIN Methods m ON m.TypeId = t.Id\n {where}\n ORDER BY p.Name, n.FullName, t.Name, m.Name\n \"\"\";\n```\n\n### 4. Update IStorageService Interface (AiCodeGraph.Core/Storage/IStorageService.cs:29)\n\nUpdate the interface to match:\n```csharp\nTask<List<(string ProjectName, string NamespaceName, string TypeName, string TypeKind, string MethodName, string ReturnType, string Accessibility)>> GetTreeAsync(\n string? namespaceFilter = null, \n string? typeFilter = null, \n bool includePrivate = false,\n bool includeConstructors = false,\n CancellationToken cancellationToken = default);\n```\n\n### 5. Update Tree Command in CLI (AiCodeGraph.Cli/Program.cs:289-386)\n\nAdd new option:\n```csharp\nvar includePrivateOption = new Option<bool>(\"--include-private\") { Description = \"Include non-public methods\" };\n\nvar treeCommand = new Command(\"tree\", \"Display code structure tree\")\n{\n nsFilterOption, typeFilterOption, treeFormatOption, treeDbOption, includePrivateOption\n};\n```\n\nUpdate the action to pass the new parameter:\n```csharp\nvar includePrivate = parseResult.GetValue(includePrivateOption);\nvar rows = await storage.GetTreeAsync(nsFilter, typeFilter, includePrivate, false, cancellationToken);\n```\n\nOptionally, update the tree/JSON output to show visibility annotations for non-public methods when `--include-private` is used:\n```csharp\n// In tree format output:\nvar visibilityTag = row.Accessibility != \"Public\" ? $\" [{row.Accessibility.ToLower()}]\" : \"\";\nConsole.WriteLine($\" {row.ReturnType} {row.MethodName}(){visibilityTag}\");\n```\n\n### 6. Update MCP Handler (AiCodeGraph.Cli/Mcp/Handlers/QueryHandler.cs)\n\nUpdate the tree handler in McpServer to support the new parameter, exposing `includePrivate` as an optional tool parameter.\n\n### 7. Important Notes\n\n- The constructor names in Roslyn are `.ctor` (instance constructor) and `.cctor` (static constructor)\n- `Accessibility` enum values from Roslyn: `Public`, `Internal`, `Protected`, `ProtectedOrInternal`, `ProtectedAndInternal`, `Private`, `NotApplicable`\n- The `--include-private` flag includes ALL non-public methods (Internal, Protected, Private, etc.)\n- Constructors are excluded regardless of the visibility filter to match the requirement",
0 commit comments