Wire the knowledge file adapter and a runtime path selector
main constructs the FileSource (default via ANTIDRIFT_KNOWLEDGE_FILE) and injects it. Adds POST /knowledge/path to repoint the profile file at runtime, and web tests asserting the planning payload carries the knowledge object (status + path, never the text) and that path selection reloads. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -58,6 +58,7 @@ func (s *Server) Router() *gin.Engine {
|
||||
r.POST("/end", s.handleEnd)
|
||||
r.POST("/refocus", s.handleRefocus)
|
||||
r.POST("/ontask", s.handleOnTask)
|
||||
r.POST("/knowledge/path", s.handleKnowledgePath)
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -124,6 +125,24 @@ func (s *Server) handleCommitment(c *gin.Context) {
|
||||
s.respond(c, err)
|
||||
}
|
||||
|
||||
type knowledgePathRequest struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
// handleKnowledgePath repoints the profile file at runtime (session-only). It
|
||||
// mutates config, not commitment state, so it never returns a transition error;
|
||||
// it just sets the path, re-loads, and broadcasts the refreshed state.
|
||||
func (s *Server) handleKnowledgePath(c *gin.Context) {
|
||||
var req knowledgePathRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid json"})
|
||||
return
|
||||
}
|
||||
s.ctrl.SetKnowledgePath(req.Path)
|
||||
s.broadcast()
|
||||
c.Data(http.StatusOK, "application/json", []byte(s.stateJSON()))
|
||||
}
|
||||
|
||||
func (s *Server) handleComplete(c *gin.Context) {
|
||||
s.cancelExpiry()
|
||||
s.respond(c, s.ctrl.Complete())
|
||||
|
||||
Reference in New Issue
Block a user