feat: /sessions analyze subcommand with dominant-topic analyser (F4.4, Task 3.1.3) #16
Notifications
Due Date
No due date set.
Depends on
#14 feat: /sessions import subcommand with --source/--since filters (F4.4, Task 2.6.1)
terraphim/agent-tasks
Reference: terraphim/agent-tasks#16
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
The session-search spec (F4.4) lists
/sessions analyze --show conceptsas a primary command, and Phase 3 Task 3.1.3 requires "dominant topic identification" via frequency analysis and concept clustering. Task 3.3.2 (stats) and 3.3.1 (timeline) exist, but neither surfaces per-session analytics (dominant topics, concept density, code-vs-prose ratio, language breakdown).Today
SessionsSubcommandoffersStats(aggregate),Timeline(temporal),Concepts { concept }(reverse lookup), but no forward analysis on a session or filtered set. Agents cannot answer "what is this session about?" or "what topics dominate my last 7 days of work?" without manually post-processing.Upstream: spec F4.4 example, F5.1 dominant_topics field, Phase 3 Task 3.1.3 + 3.3.
Acceptance Criteria
SessionsSubcommand::Analyze { session_id: Option<String>, show: Option<String>, since: Option<String>, top_n: Option<usize> }session_idNone = analyse all sessions (subject to--since)showone of:concepts(default),languages,files,alltop_ndefaults to 10, max 100SessionAnalyzerinterraphim_sessions::enrichmentthat computes:SessionEnrichment::concepts)SessionMetadata::languagesFilessubcommand backend)RobotResponse { data: { scope: "session" | "global", session_count, dominant_concepts: [{ concept, occurrences, session_count }], languages: [{ lang, percent }], top_files: [...] } }ExitCode::ERROR_NOT_FOUNDwith suggestion "run /sessions import first"cargo test -p terraphim_sessions --features enrichmentpassescargo test -p terraphim_agent --features repl-sessions,enrichmentpassescargo clippy -p terraphim_sessions --features enrichment -- -D warningspassesProposed Approach
terraphim_sessions(newenrichment/analyzer.rs),terraphim_agent(commands.rs, handler.rs, robot/docs.rs)SessionEnrichmentdata; add aggregation functions that fold over a slice--sinceidentical to /sessions import (jiff Timestamp / civil Date)robot/docs.rsentries so schema + examples are discoverableDependencies
Verification
Scope
Single PR. ~300-400 lines across analyser + parser + handler + tests.