fix(prompts): stop on-disk prompt overrides from freezing forever
EnsureExists blindly seeded ~/.todo-app/prompts/*.md with the bundled default and never revisited it, so any file created by opening the Files settings tab shadowed every later default change permanently (SuggestImprovement/AskUser sections never reached real runs since 2026-06-04). PromptFiles now hashes what a file was seeded/saved with in prompts/.defaults.json: Classify() tells missing/current-default/ known-past-default/edited apart, ReconcileStaleDefaults() drops files that only ever matched a superseded default, and real edits are left alone and surfaced in the Files tab with a diff + reset-to-default action. QuarantineOrphans() moves stale-named leftovers (agent.md, planning.md) into prompts/_orphans instead of silently deleting them. Wired as a Worker startup sweep (PromptFileRecovery) alongside the existing OrphanRecovery/AttachmentOrphanRecovery services.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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.LogWarning("Prompt file recovery: quarantined {Count} orphaned prompt file(s) into _orphans", orphans.Count);
|
||||
else
|
||||
_logger.LogInformation("Prompt file recovery: no orphaned prompt files found");
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
}
|
||||
Reference in New Issue
Block a user