generate-brain-sync-block.ts
34 lines · scripts/resolvers/preamble/generate-brain-sync-block.ts at 3f79d81
1/**
2 * Artifacts-sync interpretation rules (token-reduction Phase 1).
3 *
4 * The ~6.8KB of artifacts-sync bash this generator used to inline (gbrain
5 * availability hints, remote-MCP detection via claude.json, restore hint,
6 * daily pull, queue-depth status) now runs inside `bin/gstack-skill-start`
7 * (invoked by the Preamble fence above) and reports through the same STATUS
8 * lines it always emitted: the GBrain hint text and the `ARTIFACTS_SYNC:`
9 * line. What remains here is the prose the model acts on. The one-time
10 * privacy stop-gate moved behind its runtime gate in Phase 2: it now arrives
11 * as a GSTACK_INSTRUCTION block from gstack-skill-start when consent is
12 * actually pending; this generator only carries the interpretation prose.
13 *
14 * Skill-END sync is no longer a separate fence: `bin/gstack-skill-end`
15 * (invoked by the Telemetry step) drains the queue before logging.
16 */
17import type { TemplateContext } from '../types';
19export function generateBrainSyncBlock(ctx: TemplateContext): string {
20 const isBrainHost = ctx.host === 'gbrain' || ctx.host === 'hermes';
21 return `## Artifacts Sync (skill start)
23Skill-start already ran artifacts sync. GBrain hint text (if any) says
24when to prefer \`gbrain\` over Grep. \`ARTIFACTS_SYNC:\` reports sync health
25(\`off\`, \`mode=... | queue=N\`, \`remote-mode\`, or a \`gstack-brain-restore\`
26hint). On an \`attention:\` line, tell the user in one sentence what
27it says and the command it names, then continue.
29${isBrainHost ? `If output shows \`ARTIFACTS_SYNC: artifacts repo detected\`, offer \`gstack-brain-restore\` via AskUserQuestion; otherwise continue.
31` : ''}The one-time privacy stop-gate arrives as a \`GSTACK_INSTRUCTION\` block
32from skill-start when consent is pending; fire it via AskUserQuestion
33exactly as instructed.`;
34}