Skip to content

Commit e622d8f

Browse files
aorumbayevclaude
andcommitted
docs: document v0.18.0 analytics across external and internal guides
Add coverage for multi-dimensional analytics, intelligent backend selection, and new MCP tools across all user-facing and contributor doc surfaces: External docs: - reference/mcp-tools.md: new Analytics tools section + readonly tier - reference/configuration.md: use_recommended_backend setting - guides/web-dashboard.md: Analytics page section with 4-tab overview - guides/mcp-setup.md: Analytics tools subsection for MCP clients Internal docs: - internal/features/server.md: 9 analytics REST routes documented - internal/features/mcp.md: new Analytics Tools section + renumbered Cross-links point to the existing analytics.md guide for deep dives. Style and formatting match each file's existing conventions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1e72d94 commit e622d8f

6 files changed

Lines changed: 106 additions & 9 deletions

File tree

docs/guides/mcp-setup.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,20 @@ Add `"--role", "WORKER"`, `"--role", "REVIEWER"`, or `"--role", "ORCHESTRATOR"`
277277

278278
______________________________________________________________________
279279

280+
## Analytics tools
281+
282+
Kagan exposes its analytics data over MCP so external clients (Claude Desktop, Cursor, Claude Code, etc.) can query agent performance and session activity programmatically. These tools are available to every role (`WORKER`, `REVIEWER`, `ORCHESTRATOR`) and operate on the currently active project — open a project in Kagan first, otherwise they return empty results.
283+
284+
| Tool | What it returns |
285+
| ---------------------------- | -------------------------------------------------------------------------------- |
286+
| `analytics_backend_stats` | Per-backend session count, success rate, average duration, and retry rate. |
287+
| `analytics_session_timeline` | Daily session counts by status. Accepts `days` (default `30`). |
288+
| `analytics_export` | Combined backend stats + session timeline, ready for dashboards. Accepts `days`. |
289+
290+
See the [Analytics guide](analytics.md) for the full list of metrics, UI surfaces, and export workflows.
291+
292+
______________________________________________________________________
293+
280294
## Multi-repo
281295

282296
**Create:** Kagan → New Project → add repo paths. First repo = active.

docs/guides/web-dashboard.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ kagan web --host 0.0.0.0 # LAN access
1515

1616
## Activity bar
1717

18-
The left-edge activity bar has three icons:
18+
The left-edge activity bar has four icons:
1919

20-
| Icon | Route | Purpose |
21-
| --------- | ------------ | ------------------------------------ |
22-
| Board | `/board` | Kanban board with drag-and-drop |
23-
| Workspace | `/workspace` | Orchestrator-first conversation view |
24-
| Settings | `/settings` | Categorized settings with sidebar |
20+
| Icon | Route | Purpose |
21+
| --------- | ------------- | -------------------------------------- |
22+
| Board | `/board` | Kanban board with drag-and-drop |
23+
| Workspace | `/workspace` | Orchestrator-first conversation view |
24+
| Analytics | `/analytics` | Agent performance and session metrics |
25+
| Settings | `/settings` | Categorized settings with sidebar |
2526

2627
Toggle between Board and Workspace with `Cmd/Ctrl+Shift+W`.
2728

@@ -46,6 +47,25 @@ A conversation-first companion to the board, modeled after ChatGPT / Codex Deskt
4647
- On first visit, if no conversations exist, Kagan creates a blank orchestrator session automatically.
4748
- The global AI rail does not open on `/workspace`; this route already is the AI surface.
4849

50+
## Analytics
51+
52+
Added in v0.18.0. The `/analytics` page surfaces multi-dimensional metrics across your agent runs, with four tabs:
53+
54+
| Tab | Content |
55+
| ---------------- | ------------------------------------------------------------------------------------------------------------------ |
56+
| **Backend** | KPI cards (Total Sessions, Success Rate, Avg Duration, Retry Rate), backend performance table, duration chart, session timeline |
57+
| **By Role** | Per-role success rates (Worker / Orchestrator / Reviewer) and a role comparison chart |
58+
| **By Task Type** | Per-task-type success rates and a Backend x Task Type matrix |
59+
| **Combined** | 3D table of Backend x Role x Task Type combinations |
60+
61+
Top-of-page controls:
62+
63+
- **Time range dropdown**: 7 / 14 / 30 days.
64+
- **Export**: downloads the current dataset as JSON.
65+
- **Glossary**: help icon that explains each metric.
66+
67+
See [Analytics & Metrics](./analytics.md) for the full metric definitions, task-type classifier, and access across other surfaces (TUI, CLI, VS Code, MCP).
68+
4969
## Settings
5070

5171
The settings page uses a left sidebar for category navigation. See [Configuration reference -- Web dashboard settings](../reference/configuration.md#web-dashboard-settings) for the full category list.

docs/internal/features/mcp.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,19 @@ ______________________________________________________________________
111111

112112
______________________________________________________________________
113113

114-
## 12. Resources
114+
## 12. Analytics Tools
115+
116+
Read-only wrappers around `Analytics` in `kagan.core._analytics`, scoped to the active project. All three tools are registered in the WORKER tier so any agent role can query them; they return empty payloads when no project is active.
117+
118+
- `analytics_backend_stats` — per-backend aggregates (count, success rate, avg duration, retry rate) for choosing an agent backend
119+
- `analytics_session_timeline(days=30)` — daily session counts bucketed by status (completed/failed/cancelled/running/pending) for trend charts
120+
- `analytics_export(days=30)` — combined `{exported_at, period_days, backend_stats, session_timeline}` snapshot for archival or offline analysis
121+
122+
The richer multi-dimensional analytics (by agent role, by task type, per-task backend recommendation) live only on the REST surface under `/api/analytics/*` (see `src/kagan/server/_analytics_routes.py`). They are intentionally not exposed as MCP tools yet — add them to `toolsets/analytics.py` and register in `_policy.py` if a use case emerges.
123+
124+
______________________________________________________________________
125+
126+
## 13. Resources
115127

116128
- Read-only data endpoints, always available regardless of access mode
117129
- `kagan://ping` — health check
@@ -122,7 +134,7 @@ ______________________________________________________________________
122134

123135
______________________________________________________________________
124136

125-
## 13. Access Control
137+
## 14. Access Control
126138

127139
- Three roles: WORKER (board awareness + own-task annotation), REVIEWER (+ verdicts), ORCHESTRATOR (full control)
128140
- `--role` flag sets the agent role; defaults to ORCHESTRATOR

docs/internal/features/server.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,26 @@ curl -X POST http://localhost:8765/api/plugins/{name}/import
200200

201201
______________________________________________________________________
202202

203+
## Analytics Routes
204+
205+
Registered in `src/kagan/server/_analytics_routes.py`. All endpoints require an active project context — if none is set, they return an empty list or object rather than erroring. Used by the web dashboard's analytics views and by agents deciding which backend to invoke.
206+
207+
| Endpoint | Purpose |
208+
| ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- |
209+
| `GET /api/analytics/backend-stats` | Per-backend aggregates (sessions, success rate, duration) for the active project. |
210+
| `GET /api/analytics/session-timeline?days=N` | Daily session counts over the last `N` days (default 30). |
211+
| `GET /api/analytics/timeline-summary?days=N` | Rolled-up timeline aggregates over `N` days (default 30). |
212+
| `GET /api/analytics/recommended-backend` | Simple recommendation: the backend with the highest success rate for this project. |
213+
| `GET /api/analytics/export?days=N` | Combined export blob (backend stats + session timeline) over `N` days — used for download/share. |
214+
| `GET /api/analytics/by-role` | Backend stats grouped by agent role (WORKER/REVIEWER/ORCHESTRATOR). |
215+
| `GET /api/analytics/by-task-type` | Backend stats grouped by task type. |
216+
| `GET /api/analytics/by-role-and-task-type?role=&task_type=` | 3D stats (backend × role × task type), optionally filtered by role and/or task type query params. |
217+
| `GET /api/analytics/recommend-for-task?title=&description=&role=` | Intelligent backend selection via `BackendSelector` — combines history with task title/description. |
218+
219+
`title` is required on `/recommend-for-task`; omitting it returns a default `claude-code` recommendation with zero confidence.
220+
221+
______________________________________________________________________
222+
203223
## Troubleshooting
204224

205225
### Port Conflicts

docs/reference/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ max_concurrent_agents = 3
4646
| `require_review_approval` | boolean | `false` | Require review approval before merge |
4747
| `serialize_merges` | boolean | `true` | Queue merge actions |
4848
| `default_agent_backend` | string | `"claude-code"` | Default worker agent |
49+
| `use_recommended_backend` | boolean | `false` | Auto-pick the best-performing backend per task from historical analytics (requires ≥5 prior sessions per backend × role × task-type). See [intelligent backend selection](../guides/analytics.md#intelligent-backend-selection). |
4950
| `additional_instructions` | string | `""` | Free-text rules appended to every agent prompt |
5051
| `review_strictness` | string | `"balanced"` | Review rigor. Allowed: `strict`, `balanced`, `relaxed` |
5152
| `planning_depth` | string | `"always"` | When to create task plans. Allowed: `always`, `multi_task`, `never` |

docs/reference/mcp-tools.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,36 @@ Review semantics:
113113
| `plugins_sync(...)` | `destructive` | Sync issues via plugin, returns counts |
114114
| `plugins_preflight(...)` | `read-only` | Check plugin prerequisites and readiness |
115115

116+
### Analytics tools (`toolsets/analytics.py`)
117+
118+
All analytics tools are read-only, scoped to the active project, and return empty payloads when no project is active.
119+
120+
| Tool | Annotation | Purpose |
121+
| ------------------------------- | ----------- | ------------------------------------------------------------------- |
122+
| `analytics_backend_stats()` | `read-only` | Per-backend session stats: count, success rate, avg duration, retry rate |
123+
| `analytics_session_timeline(...)` | `read-only` | Daily session counts by status over a trailing window |
124+
| `analytics_export(...)` | `read-only` | Combined backend stats + session timeline snapshot |
125+
126+
#### `analytics_backend_stats`
127+
128+
- **Arguments**: none
129+
- **Returns**: `{"backends": [{"agent_backend", "count", "success_rate", "avg_duration_seconds", "retry_rate"}, ...]}`
130+
- **Use case**: Compare agent backends across the active project to choose the most reliable one for a new task.
131+
132+
#### `analytics_session_timeline`
133+
134+
- **Arguments**: `days: int = 30`
135+
- **Returns**: `{"timeline": [{"date", "total", "completed", "failed", "cancelled", "running", "pending"}, ...]}`
136+
- **Use case**: Plot session volume and outcome trends over a trailing window.
137+
138+
#### `analytics_export`
139+
140+
- **Arguments**: `days: int = 30`
141+
- **Returns**: `{"exported_at", "period_days", "backend_stats", "session_timeline"}`
142+
- **Use case**: Snapshot aggregate analytics in a single call for archival, sharing, or offline analysis.
143+
144+
Additional multi-dimensional analytics (by role, by task type, per-task backend recommendation) are exposed over REST at `/api/analytics/...` but are not currently wrapped as MCP tools.
145+
116146
______________________________________________________________________
117147

118148
## `task_get` API
@@ -300,7 +330,7 @@ same orchestrator-scoped MCP tool set.
300330

301331
| Tier | Visible tools |
302332
| ---------- | ------------- |
303-
| `readonly` | Worker-scope tools (`task_get`, `task_list`, `task_events`, `task_wait`, `run_get`, `run_cancel`, `run_detach`, `run_summary`, `review_conflicts`, `settings_get`, `plugins_preflight`, `plugins_preview`, `verify_step`, `verification_summary`, `checkpoint_create`, `checkpoint_list`, `session_rewind`, `insight_add`, `insight_list`) |
333+
| `readonly` | Worker-scope tools (`task_get`, `task_list`, `task_events`, `task_wait`, `run_get`, `run_cancel`, `run_detach`, `run_summary`, `review_conflicts`, `settings_get`, `plugins_preflight`, `plugins_preview`, `verify_step`, `verification_summary`, `checkpoint_create`, `checkpoint_list`, `session_rewind`, `insight_add`, `insight_list`, `analytics_backend_stats`, `analytics_session_timeline`, `analytics_export`) |
304334
| `default` | Orchestrator-scope tools (worker tools plus `task_create`, `task_update`, `task_delete`, `run_start`, `review_decide`, `review_merge`, `review_rebase`, `review_verdict`, `review_clear_verdicts`, `project_list`, `project_setup`, `project_update`, `settings_set`, `audit_list`, `plugins_sync`, `persona_inspect`, `persona_import`, `persona_export`, `persona_trust`, `insight_remove`) |
305335
| `admin` | Alias of `default` for MCP; currently exposes the same tool surface |
306336

0 commit comments

Comments
 (0)