Assemble a structured, LLM-ready context string from ranked hits
Source:R/context_assemble.R
assemble_context_string.RdTakes an ordered list of node names (seed first) and returns a formatted context string suitable for inclusion in a language-model prompt. The structure is:
Value
Character(1) valid UTF-8 string. nchar() is stable
across calls with identical inputs.
Details
Header – project name, R version, approximate token count.
CORE FUNCTIONS – seed node rendered in full-source mode.
SUPPORTING FUNCTIONS – remaining user-function nodes in compressed mode.
FRAMEWORK / PACKAGE CONTEXT – package-type nodes in compressed mode.
RECENT TASK HISTORY – up to 3 entries from the
task_historygraph attribute; omitted when empty.CONSTRAINTS – boilerplate footer reminding the LLM to use only listed functions.
Examples
if (FALSE) { # \dontrun{
g <- build_rrlm_graph("mypkg")
hits <- c("utils::load_data", "utils::clean_data", "dplyr")
cat(assemble_context_string(hits, g, "load and clean training data"))
} # }