Documentation
¶
Overview ¶
Package contextpack builds the bounded context MemSpace hands to agents: at session start, a card for recent unfinished work in the project; on each prompt, history related to what the user asked.
Everything is wrapped in <memspace_context> with an explicit statement that it is historical, possibly stale, and not instructions, and fitted to a character budget by dropping whole items, lowest priority first (Claude Code replaces hook output over 10,000 characters with a stub, so overflowing is worse than omitting).
Index ¶
Constants ¶
const ( ModeSessionStart = "session_start" ModePrompt = "prompt" ModeExplicit = "explicit" // MCP memspace_project_context )
Modes.
const ( SessionStartBudget = 4000 PromptBudget = 6000 ExplicitBudget = 8000 // HardLimit stays below Claude Code's 10,000-character hook limit. HardLimit = 9500 )
Default character budgets (~1000 / ~2000 tokens).
Variables ¶
var RecentWindow = 72 * time.Hour
RecentWindow bounds how old an unfinished session may be to be offered at session start.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct {
Key string `json:"key"`
Kind string `json:"kind"` // session | history
Ref string `json:"ref"`
ProjectID string `json:"project_id"`
Device string `json:"device,omitempty"`
Agent string `json:"agent,omitempty"`
At time.Time `json:"at"`
}
Item is one delivered piece, for provenance and de-duplication.
type Pack ¶
type Pack struct {
Text string `json:"text"`
Items []Item `json:"items"`
Truncated bool `json:"truncated"`
ProjectID string `json:"project_id,omitempty"`
Note string `json:"note,omitempty"`
}
Pack is the result. Text is empty when there is nothing worth injecting.
type Request ¶
type Request struct {
Mode string `json:"mode"`
Project search.ProjectRef `json:"project"`
// The calling agent's own session, excluded from results.
AgentType string `json:"agent_type,omitempty"`
NativeSessionID string `json:"native_session_id,omitempty"`
Query string `json:"query,omitempty"`
// Budget in characters; 0 means the mode's default.
Budget int `json:"budget,omitempty"`
// Item keys already delivered to this session (not repeated).
Exclude []string `json:"exclude,omitempty"`
}
Request asks for a context pack.