94 references to AgentInstructionsFile
aspire (12)
Agents\AgentInstructionsFile.cs (1)
18/// How <see cref="AgentInstructionsFile.WriteAsync"/> changed the agent instructions file.
Commands\AgentInitCommand.cs (8)
847? AgentInstructionsFile.GetConfiguredAppHostPath(appConfigurationDirectory) ?? 848AgentInstructionsFile.GetConfiguredAppHostPath(workspaceRoot) ?? 849await AgentInstructionsFile.FindSingleAppHostPathAsync(_projectLocator, workspaceRoot, cancellationToken) 850: AgentInstructionsFile.GetConfiguredAppHostPath(workspaceRoot) ?? (await FindWorkspaceAppHostAsync(workspaceRoot, discoverAppHostAsync, cancellationToken))?.FullName; 858return await AgentInstructionsFile.WriteAndReportAsync(InteractionService, workspaceRoot, appHostPath, aspireSkillsRegistered, cancellationToken); 868if (AgentInstructionsFile.IsInDirectory(workingDirectory.FullName, workspaceRoot)) 874if (appHost is not null && AgentInstructionsFile.IsInDirectory(appHost.FullName, workspaceRoot)) 891return workspaceAppHost is not null && AgentInstructionsFile.IsInDirectory(workspaceAppHost.FullName, workspaceRoot)
Commands\NewCommand.cs (3)
849(AgentInstructionsFile.GetConfiguredAppHostPath(workspaceRoot) ?? 850await AgentInstructionsFile.FindSingleAppHostPathAsync(_projectLocator, workspaceRoot, cancellationToken)) is { } appHostPath) 852await AgentInstructionsFile.WriteAndReportAsync(InteractionService, workspaceRoot, appHostPath, aspireSkillsPluginRegistered: false, cancellationToken);
Aspire.Cli.Tests (82)
Agents\AgentInstructionsFileTests.cs (60)
22var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, aspireSkillsPluginRegistered: true, CancellationToken.None); 36var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 40existing + "\r\n\r\n" + AgentInstructionsFile.CreateSection("apphost.cs", false, "\r\n") + "\r\n", 49var oldSection = AgentInstructionsFile.CreateSection("old.cs", false, "\n"); 52var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, aspireSkillsPluginRegistered: true, CancellationToken.None); 53var unchanged = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, aspireSkillsPluginRegistered: true, CancellationToken.None); 58$"# Rules\n\n{AgentInstructionsFile.CreateSection("apphost.cs", aspireSkillsPluginRegistered: true, "\n")}\n\n## More rules\nKeep tests green.\n", 71var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 75Assert.Equal($"# Team rules\n\n{AgentInstructionsFile.CreateSection("apphost.cs", false, "\n")}\n", await File.ReadAllTextAsync(target)); 91var change = await AgentInstructionsFile.WriteAsync(new DirectoryInfo(link), appHost, false, CancellationToken.None); 96$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection("App/apphost.cs", false, newLine)}{newLine}", 97await File.ReadAllTextAsync(Path.Combine(link, AgentInstructionsFile.FileName))); 108var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, Path.Combine(link, "apphost.cs"), false, CancellationToken.None); 113$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection("app/apphost.cs", false, newLine)}{newLine}", 125var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 131$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection("apphost.cs", false, newLine)}{newLine}", 140var existing = $"# Rules\n\n<!-- aspire:begin -->\nAn unterminated section.\n\nKeep this team rule.\n\n{AgentInstructionsFile.CreateSection("old.cs", false, "\n")}\n"; 143var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 157await File.WriteAllTextAsync(GetFilePath(workspace), $"# Rules\n\n{earlierText}\nKeep this team rule.\n\n{AgentInstructionsFile.CreateSection("old.cs", false, "\n")}\n"); 159var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 163$"# Rules\n\n{earlierText}\nKeep this team rule.\n\n{AgentInstructionsFile.CreateSection("apphost.cs", false, "\n")}\n", 179var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 180var unchanged = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 185$"{existing}\n{AgentInstructionsFile.CreateSection("apphost.cs", false, "\n")}\n", 200var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 210var existing = $"# Rules\n\n```\nAn unclosed code block.\n\n{AgentInstructionsFile.CreateSection("old.cs", false, "\n")}\n"; 213var change = await AgentInstructionsFile.WriteAsync( 226await File.WriteAllTextAsync(GetFilePath(workspace), $"# Rules\n\n{AgentInstructionsFile.CreateSection("old.cs", false, "\n")}\n{after}"); 228var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 232$"# Rules\n\n{AgentInstructionsFile.CreateSection("apphost.cs", false, "\n")}\n{after}", 241var existing = $"# Rules\n\n{AgentInstructionsFile.SectionStartMarkerPrefix} -->\nMy own notes.\n"; 244var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 255var oldSection = AgentInstructionsFile.CreateSection("old.cs", false, "\n"); 258var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 262$"# Rules\n\n{AgentInstructionsFile.CreateSection("apphost.cs", false, "\n")} Keep this team rule.\nMore rules.\n", 271var existing = $"# Rules\n\n{AgentInstructionsFile.SectionStartMarkerPrefix} -->\nOld section.\n{AgentInstructionsFile.SectionEndMarkerPrefix}\nMy own notes.\n"; 274var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 285var existing = $"# Rules\n\n{AgentInstructionsFile.SectionStartMarkerPrefix} -->\nOld section.\n{AgentInstructionsFile.SectionEndMarkerPrefix}\nKeep this team rule.\n<!-- unrelated note -->\n"; 288var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 299var existing = $"# Rules\n\n{AgentInstructionsFile.SectionStartMarkerPrefix}\nKeep this team rule.\n{AgentInstructionsFile.SectionEndMarkerPrefix} -->\n"; 302var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 316var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 320existing + "\n" + AgentInstructionsFile.CreateSection("apphost.cs", false, "\n") + "\n", 331var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 335$"# Rules\n\n{AgentInstructionsFile.CreateSection("apphost.cs", false, "\n")}\nMore rules.\n", 348var section = AgentInstructionsFile.CreateSection(appHostPath, false, "\n"); 361Assert.Null(AgentInstructionsFile.GetConfiguredAppHostPath(workspace.WorkspaceRoot)); 372var link = Path.Combine(repository.FullName, AgentInstructionsFile.FileName); 376var succeeded = await AgentInstructionsFile.WriteAndReportAsync( 381await AgentInstructionsFile.WriteAsync(repository, Path.Combine(repository.FullName, "apphost.cs"), false, CancellationToken.None)); 399var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 402byte[] expected = [.. encoding.Preamble, .. encoding.GetBytes($"# R\u00E8gles\n\n{AgentInstructionsFile.CreateSection("apphost.cs", false, "\n")}\n")]; 414var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 417byte[] expected = [.. encoding.Preamble, .. encoding.GetBytes($"# R\u00E8gles\r\n\r\n{AgentInstructionsFile.CreateSection("apphost.cs", false, "\r\n")}\r\n")]; 430var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 448var change = await AgentInstructionsFile.WriteAsync(workspace.WorkspaceRoot, appHost, false, CancellationToken.None); 455Path.Combine(workspace.WorkspaceRoot.FullName, AgentInstructionsFile.FileName);
Commands\AgentInitCommandTests.cs (17)
179$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection("src/AppHost/apphost.cs", aspireSkillsPluginRegistered: false, newLine)}{newLine}", 180await File.ReadAllTextAsync(Path.Combine(context.Project.FullName, AgentInstructionsFile.FileName))); 201var agentInstructionsPath = Path.Combine(context.Project.FullName, AgentInstructionsFile.FileName); 210$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection("src/AppHost/apphost.cs", aspireSkillsPluginRegistered: false, newLine)}{newLine}", 231var agentInstructionsPath = Path.Combine(context.Project.FullName, AgentInstructionsFile.FileName); 240$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection("src/AppHost/apphost.cs", aspireSkillsPluginRegistered: true, newLine)}{newLine}", 263$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection("src/AppHost/apphost.cs", aspireSkillsPluginRegistered, newLine)}{newLine}", 264await File.ReadAllTextAsync(Path.Combine(context.Project.FullName, AgentInstructionsFile.FileName))); 286$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection("App.AppHost/App.AppHost.csproj", aspireSkillsPluginRegistered: false, newLine)}{newLine}", 287await File.ReadAllTextAsync(Path.Combine(context.Project.FullName, AgentInstructionsFile.FileName))); 320$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection("B.AppHost/B.AppHost.csproj", aspireSkillsPluginRegistered: false, newLine)}{newLine}", 321await File.ReadAllTextAsync(Path.Combine(otherRepository.FullName, AgentInstructionsFile.FileName))); 322Assert.False(File.Exists(Path.Combine(context.Project.FullName, AgentInstructionsFile.FileName))); 355$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection("src/AppHost/AppHost.csproj", aspireSkillsPluginRegistered: false, newLine)}{newLine}", 356await File.ReadAllTextAsync(Path.Combine(context.Project.FullName, AgentInstructionsFile.FileName))); 387$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection("App.AppHost/App.AppHost.csproj", aspireSkillsPluginRegistered: false, newLine)}{newLine}", 388await File.ReadAllTextAsync(Path.Combine(context.Project.FullName, AgentInstructionsFile.FileName)));
Commands\NewCommandLocalTemplateTests.cs (2)
1416var agentInstructionsPath = Path.Combine(outputDirectory, AgentInstructionsFile.FileName); 1425$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection(expectedAppHost, aspireSkillsPluginRegistered: false, newLine)}{newLine}",
Commands\NewCommandTests.cs (3)
1498$"# Agent instructions{newLine}{newLine}{AgentInstructionsFile.CreateSection("apphost.cs", aspireSkillsPluginRegistered: false, newLine)}{newLine}", 1499await File.ReadAllTextAsync(Path.Combine(workspace.WorkspaceRoot.FullName, "output", AgentInstructionsFile.FileName))); 1513Assert.False(File.Exists(Path.Combine(outputDirectory, AgentInstructionsFile.FileName)));