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

Function TruncateAttachmentText

agentContext/builder.go:528–560  ·  view source on GitHub ↗
(text string, budget PromptAttachmentBudget, preserveSeparator *string)

Source from the content-addressed store, hash-verified

526 shell = "unknown"
527 }
528 return map[string]string{
529 "cwd": cwd,
530 "platform": runtime.GOOS + "/" + runtime.GOARCH,
531 "shell": shell,
532 "go_version": runtime.Version(),
533 }
534}
535
536func BuildAttachmentBlock(name, heading, content string) string {
537 body := strings.TrimSpace(content)
538 return fmt.Sprintf("## %s\n\n[BEGIN: %s]\n%s\n[END: %s]", heading, name, body, name)
539}
540
541func GetPromptBudgetProfile(role string) PromptBudgetProfile {
542 if role == "subagent" {
543 return PromptBudgetProfile{
544 Git: PromptAttachmentBudget{400, new(12)},
545 ProjectInstructions: PromptAttachmentBudget{0, new(0)},
546 }
547 }
548 return PromptBudgetProfile{
549 Git: PromptAttachmentBudget{1200, new(24)},
550 ProjectInstructions: PromptAttachmentBudget{4000, new(120)},
551 }
552}
553
554func TruncateAttachmentText(text string, budget PromptAttachmentBudget, preserveSeparator *string) (string, bool) {
555 lines := pythonSplitLines(text)
556 truncated := false
557 if budget.MaxLines != nil && len(lines) > *budget.MaxLines {
558 lines = lines[:*budget.MaxLines]
559 truncated = true
560 }
561 candidate := strings.Join(lines, "\n")
562 if budget.MaxChars <= 0 {
563 return "", strings.TrimSpace(candidate) != ""

Calls 2

pythonSplitLinesFunction · 0.85
firstRunesFunction · 0.85