generate-context-recovery.ts
21 lines · scripts/resolvers/preamble/generate-context-recovery.ts at 3f79d81
1import type { TemplateContext } from '../types';
3export function generateContextRecovery(ctx: TemplateContext): string {
4 const binDir = ctx.paths.binDir; // env-var hosts already resolve to $GSTACK_BIN via types.ts
6 // The listing lives in bin/gstack-context-recovery (#2763): worktree-isolated
7 // Claude Code sessions refuse the eval and git-in-a-pipe forms the inline
8 // fence used, but run one literal command. Branch-form discipline
9 // (#2550/#1851) moved with it.
10 return `## Context Recovery
12At session start or after compaction, recover recent project context.
14\`\`\`bash
15${binDir}/gstack-context-recovery
16\`\`\`
18If artifacts are listed, read the newest useful one. If \`LAST_SESSION\` or \`LATEST_CHECKPOINT\` appears, give a 2-sentence welcome back summary. If \`RECENT_PATTERN\` clearly implies a next skill, suggest it once.
20**Cross-session decisions.** Honor listed \`ACTIVE DECISIONS\` and their rationale; do not silently re-litigate them, and announce planned reversals. Use \`${binDir}/gstack-decision-search\` for past-decision questions. Log DURABLE decisions by you or the user (architecture, scope, tool/vendor choice, reversal; not trivial or turn-level choices) with \`${binDir}/gstack-decision-log\` (\`--supersede <id>\` for reversals). Reliable and local; gbrain not required.`;
21}