feat: GBrain resolver — brain-first lookup and save-to-brain

New scripts/resolvers/gbrain.ts with two resolver functions:
- GBRAIN_CONTEXT_LOAD: search brain for context before skill starts
- GBRAIN_SAVE_RESULTS: save skill output to brain after completion

Placeholders added to 4 thinking skill templates (office-hours,
investigate, plan-ceo-review, retro). Resolves to empty string on
all hosts except gbrain via suppressedResolvers.

GBRAIN suppression added to all 9 non-gbrain host configs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-04-14 10:52:25 -07:00
parent cad96d086d
commit 9b0bf2e86c
14 changed files with 110 additions and 4 deletions
+42
View File
@@ -0,0 +1,42 @@
/**
* GBrain resolver — brain-first lookup and save-to-brain for thinking skills.
*
* GBrain is a "mod" for gstack. When installed, coding skills become brain-aware:
* they search the brain for context before starting and save results after finishing.
*
* These resolvers are suppressed on ALL hosts except gbrain (via suppressedResolvers
* in each host config). For non-gbrain hosts, {{GBRAIN_CONTEXT_LOAD}} and
* {{GBRAIN_SAVE_RESULTS}} resolve to empty string and vanish from the output.
*/
import type { TemplateContext } from './types';
export function generateGBrainContextLoad(_ctx: TemplateContext): string {
return `## Brain Context Load
Before starting this skill, search your brain for relevant context:
1. Search GBrain: \`gbrain query "<topic from user request>"\`
2. If results found, read the top 3 pages for context
3. Use this brain context to inform your analysis
If GBrain is not available or returns no results, proceed without brain context.`;
}
export function generateGBrainSaveResults(ctx: TemplateContext): string {
const skillSaveMap: Record<string, string> = {
'office-hours': 'Save the design document as a brain page: `gbrain put_page` with the design doc content, tagged with the project slug and "design-doc".',
'investigate': 'Save the root cause analysis as a brain page: `gbrain put_page` with the investigation findings, tagged with affected files and "investigation".',
'plan-ceo-review': 'Save the CEO plan as a brain page: `gbrain put_page` with the scope decisions and vision, tagged with the feature slug and "ceo-plan".',
'retro': 'Save the retrospective as a brain page: `gbrain put_page` with the retro output, tagged with the date range and "retro".',
};
const saveInstruction = skillSaveMap[ctx.skillName] || 'Save the skill output as a brain page if the results are worth preserving.';
return `## Save Results to Brain
After completing this skill, persist the results to your brain for future reference:
${saveInstruction}
Add backlinks to related brain pages if they exist. If GBrain is not available, skip this step.`;
}
+3
View File
@@ -18,6 +18,7 @@ import { generateConfidenceCalibration } from './confidence';
import { generateInvokeSkill } from './composition';
import { generateReviewArmy } from './review-army';
import { generateDxFramework } from './dx';
import { generateGBrainContextLoad, generateGBrainSaveResults } from './gbrain';
export const RESOLVERS: Record<string, ResolverFn> = {
SLUG_EVAL: generateSlugEval,
@@ -62,4 +63,6 @@ export const RESOLVERS: Record<string, ResolverFn> = {
REVIEW_ARMY: generateReviewArmy,
CROSS_REVIEW_DEDUP: generateCrossReviewDedup,
DX_FRAMEWORK: generateDxFramework,
GBRAIN_CONTEXT_LOAD: generateGBrainContextLoad,
GBRAIN_SAVE_RESULTS: generateGBrainSaveResults,
};