feat(server,kernel): bind ProjectProfile per session and inject as L0 context
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package com.correx.core.kernel.orchestration
|
||||
|
||||
// Context-entry builders kept top-level (not orchestrator members) for unit-testability
|
||||
// and to stay under detekt's function-count threshold (same pattern as isBackEdge).
|
||||
|
||||
import com.correx.core.context.model.ContextEntry
|
||||
import com.correx.core.context.model.ContextLayer
|
||||
import com.correx.core.context.model.EntryRole
|
||||
import com.correx.core.events.types.ContextEntryId
|
||||
import com.correx.core.sessions.BoundProjectProfile
|
||||
import java.util.UUID
|
||||
|
||||
fun buildProjectProfileEntry(profile: BoundProjectProfile): ContextEntry {
|
||||
val content = buildString {
|
||||
append("## Project profile\n")
|
||||
if (profile.about.isNotBlank()) append(profile.about).append("\n")
|
||||
if (profile.conventions.isNotEmpty()) {
|
||||
append("### Conventions\n")
|
||||
profile.conventions.forEach { append("- ").append(it).append("\n") }
|
||||
}
|
||||
if (profile.commands.isNotEmpty()) {
|
||||
append("### Commands\n")
|
||||
profile.commands.forEach { (name, cmd) -> append(name).append(": ").append(cmd).append("\n") }
|
||||
}
|
||||
}.trimEnd()
|
||||
return ContextEntry(
|
||||
id = ContextEntryId(UUID.randomUUID().toString()),
|
||||
layer = ContextLayer.L0,
|
||||
content = content,
|
||||
sourceType = "projectProfile",
|
||||
sourceId = "project-profile",
|
||||
tokenEstimate = content.length / 4,
|
||||
role = EntryRole.SYSTEM,
|
||||
)
|
||||
}
|
||||
+4
-2
@@ -363,9 +363,11 @@ abstract class SessionOrchestrator(
|
||||
),
|
||||
)
|
||||
} ?: emptyList()
|
||||
val projectProfileEntries = session.state.boundProjectProfile
|
||||
?.let { listOf(buildProjectProfileEntry(it)) } ?: emptyList()
|
||||
var accumulatedEntries =
|
||||
systemPrompt + profileEntries + journalEntries + repoMapEntries + needsEntries +
|
||||
schemaEntries + promptEntries + steeringEntries
|
||||
systemPrompt + profileEntries + projectProfileEntries + journalEntries + repoMapEntries +
|
||||
needsEntries + schemaEntries + promptEntries + steeringEntries
|
||||
val contextPack = contextPackBuilder.build(
|
||||
id = ContextPackId(UUID.randomUUID().toString()),
|
||||
sessionId = sessionId,
|
||||
|
||||
Reference in New Issue
Block a user