Files
TJWaterAgent/.opencode/skills/examples.md
T

102 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 示例(基于 opencode Agent + tjwater-cli 工具调用链)
## 示例 1:简单查询 SCADA 数据
用户意图:查询设备 `170490` 在时间范围内的 `monitored_value`
opencode agent 调用 `tjwater_cli`
```json
{
"reason": "查询设备170490在最近24小时的monitored_value数据",
"command": "data timeseries scada query --device-id 170490 --field monitored_value --start-time 2026-03-29T07:57:47+08:00 --end-time 2026-03-30T07:57:47+08:00"
}
```
## 示例 2:工作流 — 模拟诊断
用户消息:"跑一下水力计算看看管网有什么问题"
典型链路:
1. agent 加载 workflow `simulation-diagnosis`
2. 执行 `tjwater_cli(command="simulation run --start-time ... --duration 30")`
3. 执行 `tjwater_cli(command="data timeseries realtime links --start-time ... --end-time ...")`
4. 执行 `tjwater_cli(command="data timeseries realtime nodes --start-time ... --end-time ...")`
5. 将结果写入 JSON,运行 `python scripts/diagnose_simulation.py result.json`
6. 解读脚本输出,组织 Markdown 报告
## 示例 3:前端工具 — 地图定位
用户消息:"帮我找到管道 P-001 和 P-002"
opencode agent 直接调用前端工具 `locate_features`
```json
{
"reason": "在地图上定位用户请求的管道",
"ids": ["P-001", "P-002"],
"feature_type": "pipe"
}
```
## 示例 4:对话内图表
用户消息:"展示节点 J-001 最近一天的压力变化曲线"
典型链路:
1. `tjwater_cli(command="data timeseries realtime nodes --start-time ... --end-time ... --node-ids J-001")`
2. 处理返回的 pressure 数据为 x_data + series 格式
3. 调用 `show_chart` 渲染 ECharts 图表
## 示例 5:前端工具 — SCADA 监测面板
用户消息:"我想看看 J-001 的监测数据"
opencode agent 调用工具 `view_scada`
```json
{
"reason": "打开J-001的SCADA监测面板",
"device_ids": ["J-001"],
"start_time": "2026-03-29T00:00:00+08:00",
"end_time": "2026-03-30T00:00:00+08:00"
}
```
## 示例 6:命令发现
opencode agent 需要了解可用的 CLI 命令时:
```
tjwater_cli(command="help") → 获取一级命令清单
tjwater_cli(command="help analysis") → 获取 analysis 子命令详情
```
帮助输出 JSON 格式,含 `commands` 数组和 `summary`
## 示例 7:记住用户偏好
用户消息:"以后回答尽量简洁,先给结论再解释。"
opencode agent 调用 `memory_manager`
```json
{
"action": "add",
"reason": "用户明确给出了长期有效的回答风格偏好",
"scope": "user",
"content": "用户偏好先给结论、再补必要解释,整体风格尽量简洁。"
}
```
## 示例 8:沉淀可复用 workflow 模式
用户消息:"这套瓶颈分析流程之后可以复用。"
opencode agent 调用 `skill_manager`
```json
{
"action": "append_pattern",
"reason": "本轮已验证一套稳定可复用的瓶颈分析 workflow",
"skill_path": "workflow/bottleneck-analysis",
"pattern": "当瓶颈分析依赖大体量属性数据和模拟结果时,先用 tjwater_cli 获取 links 结果,再逐管段查询属性,最后合并排序。"
}
```