Files
gstack/scripts/resolvers/preamble/generate-brain-sync-block.ts
T
Garry TanandClaude Fable 5 49321ce71f fix(resolvers): question-log session_id becomes a substitution placeholder + stale-comment sweep
The question-log block bound $_SESSION_ID, a shell variable the
consolidated fence never sets — hook-less hosts logged empty session_id,
breaking /plan-tune per-session grouping. It now uses the same
substitute-from-the-skill-start-echoes contract as the telemetry block.
Also: retired the pre-Phase-2 stop-gate docstring, repointed the
gbrain-local-status cross-reference at the script's inline jq, dropped an
orphaned section comment, documented retro-metrics' suffix-only census.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 20:50:15 +00:00

34 lines
1.8 KiB
TypeScript

/**
* Artifacts-sync interpretation rules (token-reduction Phase 1).
*
* The ~6.8KB of artifacts-sync bash this generator used to inline (gbrain
* availability hints, remote-MCP detection via claude.json, restore hint,
* daily pull, queue-depth status) now runs inside `bin/gstack-skill-start`
* (invoked by the Preamble fence above) and reports through the same STATUS
* lines it always emitted: the GBrain hint text and the `ARTIFACTS_SYNC:`
* line. What remains here is the prose the model acts on. The one-time
* privacy stop-gate moved behind its runtime gate in Phase 2: it now arrives
* as a GSTACK_INSTRUCTION block from gstack-skill-start when consent is
* actually pending; this generator only carries the interpretation prose.
*
* Skill-END sync is no longer a separate fence: `bin/gstack-skill-end`
* (invoked by the Telemetry step) drains the queue before logging.
*/
import type { TemplateContext } from '../types';
export function generateBrainSyncBlock(ctx: TemplateContext): string {
const isBrainHost = ctx.host === 'gbrain' || ctx.host === 'hermes';
return `## Artifacts Sync (skill start)
The skill-start output above already ran artifacts sync. Act on its lines:
GBrain hint text (if present) tells you when to prefer \`gbrain\` over Grep;
\`ARTIFACTS_SYNC:\` reports sync health (\`off\`, \`mode=... | queue=N\`,
\`remote-mode\`, or a restore hint naming \`gstack-brain-restore\`).
${isBrainHost ? `If output shows \`ARTIFACTS_SYNC: artifacts repo detected\`, offer \`gstack-brain-restore\` via AskUserQuestion; otherwise continue.
` : ''}The one-time privacy stop-gate (artifacts-sync consent) arrives as a
\`GSTACK_INSTRUCTION\` block from skill-start when consent is actually pending
— fire it via AskUserQuestion exactly as the block instructs.`;
}