mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-06 05:35:46 +02:00
9b0bf2e86c
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>
43 lines
2.1 KiB
TypeScript
43 lines
2.1 KiB
TypeScript
/**
|
|
* 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.`;
|
|
}
|