MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / BuildInitialContext

Function BuildInitialContext

agentContext/builder.go:790–830  ·  view source on GitHub ↗
(cfg config.Config, memorySection string)

Source from the content-addressed store, hash-verified

788 nil,
789 GetPromptBudgetProfile("subagent").Git,
790 ))
791 }
792 if strings.TrimSpace(agentMemory) != "" {
793 sections = append(sections, PromptSection{"role-memory", strings.TrimSpace(agentMemory), true})
794 }
795 sections = append(sections, BuildSubagentExecutionConstraintsSection(maxTurns))
796 return sections, nil
797}
798
799func BuildSystemPromptSection(cwd, memorySection string) ([]PromptSection, error) {
800 cfg := config.NewConfigForCWD(cwd)
801 ctx, err := BuildInitialContext(cfg, memorySection)
802 if err != nil {
803 return nil, err
804 }
805 return ctx.Sections, nil
806}
807
808func BuildSystemPromptSectionWithConfig(cfg config.Config, memorySection string) ([]PromptSection, error) {
809 ctx, err := BuildInitialContext(cfg, memorySection)
810 if err != nil {
811 return nil, err
812 }
813 return ctx.Sections, nil
814}
815
816func BuildInitialContext(cfg config.Config, memorySection string) (InitialContext, error) {
817 cwd := cfg.CWD
818 if cwd == "" {
819 newCwd, err := os.Getwd()
820 if err != nil {
821 return InitialContext{}, err
822 }
823 cwd = newCwd
824 cfg.CWD = cwd
825 }
826 sections, systemPromptPath, err := loadSystemPromptTemplateSectionsWithConfig(cwd, cfg)
827 if err != nil {
828 return InitialContext{}, err
829 }
830 projectDocs, projectErr := DiscoverProjectDocs(cwd, cfg)
831
832 sections = append(sections, BuildEnvSection(cwd))
833 gitSection, err := BuildBudgetGitSection(cwd, "main")

Tested by 1