Skip to content

Commit cb2ce5e

Browse files
committed
tasks
1 parent e45e9b0 commit cb2ce5e

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

.taskmaster/tasks/tasks.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3451,13 +3451,27 @@
34513451
"priority": "medium",
34523452
"subtasks": [],
34533453
"updatedAt": "2026-01-24T17:35:08.350Z"
3454+
},
3455+
{
3456+
"id": "56",
3457+
"title": "Modify Tree Command to Filter Members by Visibility",
3458+
"description": "Add visibility filtering to the tree command that shows only public members by default, with an optional --include-private flag to show private methods, and always excludes constructors regardless of visibility settings.",
3459+
"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",
3460+
"testStrategy": "### Unit Tests (AiCodeGraph.Tests/QueryCommandsTests.cs)\n\n1. **Test default visibility filter** - Verify `GetTreeAsync()` with no parameters excludes private methods:\n - Seed database with public method `CreateUser` and private method `ValidateUser`\n - Call `GetTreeAsync()` with defaults\n - Assert only public methods are returned\n\n2. **Test includePrivate=true** - Verify private methods are included:\n - Seed database with mix of public/private methods\n - Call `GetTreeAsync(includePrivate: true)`\n - Assert both public and private methods are returned\n\n3. **Test constructor exclusion** - Verify constructors are always excluded:\n - Add `.ctor` method to test fixture\n - Call `GetTreeAsync()` and `GetTreeAsync(includePrivate: true)`\n - Assert `.ctor` is not in results for either case\n\n4. **Test combined filters** - Verify namespace/type filters work with visibility filter:\n - Call `GetTreeAsync(namespaceFilter: \"MyApp\", includePrivate: false)`\n - Verify correct filtering on both criteria\n\n### Integration Tests (AiCodeGraph.Tests/CliCommandTests.cs)\n\n1. **Test CLI default behavior** - Run `tree` command, verify only public methods appear\n2. **Test CLI with --include-private** - Run `tree --include-private`, verify private methods appear\n3. **Test JSON output with visibility** - Run `tree --format json --include-private`, verify accessibility field in JSON\n\n### Manual Testing\n\n1. Run `ai-code-graph analyze AiCodeGraph.sln` to rebuild database with new schema\n2. Run `ai-code-graph tree` and verify:\n - No constructors shown\n - Only public methods shown\n3. Run `ai-code-graph tree --include-private` and verify:\n - No constructors shown\n - Private/internal methods now visible\n - Visibility annotation appears for non-public methods\n4. Run `ai-code-graph tree --format json --include-private` and verify JSON includes accessibility field",
3461+
"status": "done",
3462+
"dependencies": [
3463+
"8"
3464+
],
3465+
"priority": "medium",
3466+
"subtasks": [],
3467+
"updatedAt": "2026-01-26T08:17:37.417Z"
34543468
}
34553469
],
34563470
"metadata": {
34573471
"version": "1.0.0",
3458-
"lastModified": "2026-01-24T17:41:18.718Z",
3459-
"taskCount": 55,
3460-
"completedCount": 55,
3472+
"lastModified": "2026-01-26T08:17:37.417Z",
3473+
"taskCount": 56,
3474+
"completedCount": 56,
34613475
"tags": [
34623476
"master"
34633477
]

0 commit comments

Comments
 (0)