Forge
csharpdeeb25a2
1#nullable enable
2using System.IO;
3using CascadeIDE.Contracts;
4
5namespace CascadeIDE.Features.HybridIndex.Application;
6
7/// <summary>
8/// Policy: normalize the configured relative index directory for HCI.
9/// Keeps "where index lives under workspace root" decisions out of UI and orchestration code.
10/// </summary>
11[ComputingUnit("policy-hybrid-index-path")]
12public static class HybridIndexIndexDirectoryRelative
13{
14 public static string ResolveOrDefault(string? configuredRelativeDir)
15 {
16 var dir = (configuredRelativeDir ?? "").Trim();
17 if (string.IsNullOrWhiteSpace(dir))
18 return ".hybrid-codebase-index";
19
20 // Security / portability: never allow rooted paths to escape the workspace root.
21 if (Path.IsPathRooted(dir))
22 return ".hybrid-codebase-index";
23
24 dir = dir.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
25 return string.IsNullOrWhiteSpace(dir) ? ".hybrid-codebase-index" : dir;
26 }
27}
28
29
View only · write via MCP/CIDE