PromptFileRecovery's orphan-quarantine log only reported a bare count, so a customized merge-helper-execute.md silently stopped applying with no pointer to where it went. Log each quarantined file's destination path, and for merge-helper-execute.md specifically call out that it was split into merge-helper-wait.md and merge-helper-merge.md with no content migration.
48 lines
1.8 KiB
C#
48 lines
1.8 KiB
C#
using ClaudeDo.Data;
|
|
|
|
namespace ClaudeDo.Worker.Lifecycle;
|
|
|
|
/// <summary>
|
|
/// Startup-only sweep: drops any prompt override file that only matched a now-superseded
|
|
/// bundled default and was never actually edited (see <see cref="PromptFiles.ReconcileStaleDefaults"/>),
|
|
/// and quarantines any *.md file under the prompts root that no longer maps to a known
|
|
/// <see cref="PromptKind"/> (leftovers from a retired naming scheme).
|
|
/// </summary>
|
|
public sealed class PromptFileRecovery : IHostedService
|
|
{
|
|
private readonly ILogger<PromptFileRecovery> _logger;
|
|
private readonly string? _root;
|
|
|
|
public PromptFileRecovery(ILogger<PromptFileRecovery> logger, string? root = null)
|
|
{
|
|
_logger = logger;
|
|
_root = root;
|
|
}
|
|
|
|
public Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
PromptFiles.ReconcileStaleDefaults(_root);
|
|
|
|
var orphans = PromptFiles.QuarantineOrphans(_root);
|
|
if (orphans.Count == 0)
|
|
{
|
|
_logger.LogInformation("Prompt file recovery: no orphaned prompt files found");
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
foreach (var orphan_path in orphans)
|
|
{
|
|
_logger.LogWarning("Prompt file recovery: quarantined orphaned prompt file {orphan_path}", orphan_path);
|
|
if (Path.GetFileNameWithoutExtension(orphan_path)
|
|
.StartsWith("merge-helper-execute", StringComparison.OrdinalIgnoreCase))
|
|
_logger.LogWarning(
|
|
"Prompt file recovery: {orphan_path} was a customization of the retired merge-helper-execute.md prompt, which was split into merge-helper-wait.md and merge-helper-merge.md; its content was not migrated to either",
|
|
orphan_path);
|
|
}
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
|
}
|