# ISS-0024: 诊断输出中缺少 Clinic 深度链接

## Background

User `fuchao.lan@pingcap.com` reported in GitHub issue #144 that the diagnosis output from workspace `ws-1776256323680-07f26bb90` (O11Y-2328599) does not include Clinic log viewer URLs. The user expects links like:

```
https://clinic.pingcap.com/clusters/10754652599988043412/logs?query=%7Bcomponent%3D~%22tidb%7Ctikv%7Cpd%22%7D&start=1743820200&end=1743829200
```

These links allow users to directly open the Clinic UI to view raw logs, metrics, and TopSQL data for the incident window without manual navigation.

## Observed Behavior

The agent's diagnosis output contains:
- Textual description of evidence (metrics, TopSQL, SlowQuery)
- Tables with query data and execution plans
- Recommendations with SQL commands

But does NOT contain:
- Clinic log viewer URL for the incident window
- Clinic metrics viewer URL
- Clinic TopSQL viewer URL
- Any deep links to the data sources used

## Root Cause

The `tidb-clinic-diagnosis` SKILL.md does not instruct the agent to generate Clinic viewer URLs in its output. The URL format is deterministic and can be constructed from known parameters (cluster_id, start/end timestamps, component).

## Fix Plan

### Step 1: Add URL templates to SKILL.md

In the Node E (output) section of `agentkit/skills/builtin/tidb-clinic-diagnosis/SKILL.md`, add a "Reference Links" requirement:

```markdown
### Output Requirements — Reference Links

After the diagnosis, append a "Reference Links" section with Clinic viewer URLs:

| Data Source | URL Template |
|-------------|-------------|
| Logs | `https://clinic.pingcap.com/clusters/{cluster_id}/logs?query=%7Bcomponent%3D~%22tidb%7Ctikv%7Cpd%22%7D&start={start_epoch}&end={end_epoch}` |
| Metrics | `https://clinic.pingcap.com/clusters/{cluster_id}/monitoring?start={start_epoch}&end={end_epoch}` |
| TopSQL | `https://clinic.pingcap.com/clusters/{cluster_id}/topsql?start={start_epoch}&end={end_epoch}` |
| SlowQuery | `https://clinic.pingcap.com/clusters/{cluster_id}/slowquery?start={start_epoch}&end={end_epoch}` |

Use the incident window start/end timestamps (Unix epoch seconds) determined in the evidence collection phase.
```

### Step 2: Update collect_evidence.py output

In `collect_evidence.py`, the `evidence_summary_for_agent.json` output should include a `clinic_urls` section with pre-computed URLs based on the cluster_id and time window used during collection.

### Step 3: Verification

After fix:
1. Run a diagnosis on any workspace
2. Verify the output includes a "Reference Links" section with clickable Clinic URLs
3. Verify the URLs open correctly in a browser (correct cluster, time range)
