feat(polish): add context safeguards, layered prompts, and output validation

Use redacted cursor neighborhood and pause-aware chunks for more natural polish,
validate protected terms with retry/local fallback, and structure bilingual prompts
for consistency and provider prefix caching.
This commit is contained in:
Rocky
2026-07-29 17:45:11 +08:00
parent 2d44423f4c
commit 34be2e8dd1
40 changed files with 1827 additions and 183 deletions
@@ -25,6 +25,7 @@ public enum FlowDebugAppGroupSnapshot {
let snapshot = FlowSessionBridge.readySnapshot(defaults: defaults)
let staleness = FlowSessionBridge.heartbeatStaleness(defaults: defaults)
let generation = FlowSessionBridge.currentHostGeneration(defaults: defaults)
let cacheMetrics = LLMCacheMetricsStore.latest(defaults: defaults)
let shortGen: String = {
guard let generation, generation.count >= 8 else { return generation ?? "nil" }
return String(generation.prefix(8))
@@ -60,6 +61,7 @@ public enum FlowDebugAppGroupSnapshot {
}()),
FlowDebugRow("pendingHost", FlowSessionBridge.pendingHostBundleId(defaults: defaults) ?? "nil"),
FlowDebugRow("recState", FlowSessionBridge.recordingState(defaults: defaults).rawValue),
FlowDebugRow("llmCache", cacheMetrics?.summary ?? "n/a"),
FlowDebugRow("appGroup", AppGroup.isAvailable ? "1" : "0")
]
}