feat: /sessions recommend subcommand for cross-session learning #9
Notifications
Due Date
No due date set.
Depends on
Reference: terraphim/agent-tasks#9
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
Phase 3 F5.3 of the session-search spec mandates a "past-solution discovery" surface: given a user query, the agent should recommend past sessions whose outcomes solved a similar problem, so successful solutions become reusable lessons learned. The
SessionsSubcommandenum hasSearch,Concepts,Related,Timeline,Enrich,Files,ByFile,Index, etc., but noRecommendvariant. F5.3 bullet two — cross-session recommendation by concept overlap and recency — remains unchecked.Current State
SessionsSubcommand::Related { session_id }exists (crates/terraphim_agent/src/repl/commands.rsaround ~1100) and finds sessions related to a known session, but there is no query-driven recommender.grepforRecommend/recommendinrepl/returns zero hits.SessionIndex::concepts, recency weight, outcome-success flag) exist interraphim_sessions::service.Acceptance Criteria
SessionsSubcommand::Recommend { query: String, top_k: Option<usize>, min_score: Option<f32> }with help text in the/sessionscommand tree.crates/terraphim_agent/src/repl/handler.rsimplementinghandle_sessions_recommend.score = 0.55 * concept_overlap + 0.25 * recency_decay + 0.20 * outcome_success_bonus, clamped to[0.0, 1.0].min_scoredefault = 0.15.{ session_id, title, source, score, matched_concepts, solution_snippet }wheresolution_snippetis the last assistant message body truncated to 240 chars.--robot --format json) emits arecommendations: [...]array matching the shape above.service.rsfor the scoring function; integration test inrepl_integration_testsasserting non-empty recommendations on a seeded index.cargo test -p terraphim_agent --features repl-full,repl-sessionspasses.cargo clippy -p terraphim_agent --features repl-full,repl-sessions -- -D warningspasses.Proposed Approach
SessionsSubcommandinrepl/commands.rswith the newRecommendvariant and clap derive attributes.SessionService::recommend(query, top_k, min_score)incrates/terraphim_sessions/src/service.rsthat:repl/handler.rs(handle_sessions_recommend) that formats the output for both interactive and robot modes./sessionshelp text incommands.rsand the corresponding section indocs/src/claude-code-skills.md.Dependencies
None blocking — concept extraction and the session index are already available. (Benefits from #5 Tantivy index when merged, but not required.)
Verification
Scope
~250 LOC: ~60 in
commands.rs, ~120 inservice.rs(scorer + orchestration), ~70 inhandler.rs(formatters). Single PR.Upstream: Implements Phase 3 F5.3 bullet 2 of
docs/specifications/terraphim-agent-session-search-spec.mdfor terraphim/terraphim-ai.