| 193 | * Subordinate to {{TELEMETRY}} — runs after. Doesn't block the user. |
| 194 | */ |
| 195 | export function generateBrainCacheRefresh(ctx: TemplateContext): string { |
| 196 | if (!isPreflightSkill(ctx.skillName)) return ''; |
| 197 | const binDir = ctx.paths.binDir; |
| 198 | return `## Brain Cache Background Refresh |
| 199 | |
| 200 | After the skill's work completes (and telemetry has logged), kick a |
| 201 | background refresh of any cache digest that's getting close to its TTL. |
| 202 | This is non-blocking — the user doesn't wait. Next invocation benefits |
| 203 | from the warm cache. |
| 204 | |
| 205 | \`\`\`bash |
| 206 | eval "$(${binDir}/gstack-slug 2>/dev/null)" 2>/dev/null || true |
| 207 | (${binDir}/gstack-brain-cache refresh --project "$SLUG" 2>/dev/null &) || true |
| 208 | \`\`\` |
| 209 | `; |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Renders the calibration write-back block. ONLY emits when the skill makes |