Require ops to persist field general knowledge to Wiki, not chat memory.

Add ops-knowledge-capture routing and harden ROLE/wiki topic hints for short WhatsApp threads.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-12 23:41:15 +08:00
parent 91c5a1a754
commit 1bdbfc3b85
5 changed files with 222 additions and 2 deletions

View file

@ -43,6 +43,14 @@
},
"topic_routing": {
"rules": [
{
"topic": "ops-field",
"keywords": [
"fiber", "optical", "lldp", "ume", "alarm", "host_name", "sfp",
"capacity", "los", "bgp", "mpls", "nickname", "alias", "sembawa",
"光功率", "断纤", "告警", "网元", "以后", "记住", "别再"
]
},
{
"topic": "network",
"keywords": ["vlan", "router", "switch", "network", "dns", "gateway"]

View file

@ -95,16 +95,29 @@ Why bad: process opener, Markdown table, CJK, helpdesk filler, no Result/Evidenc
- WhatsApp replies: findings first, `*bold*` + `-` bullets, no Markdown pipe tables; large results as xlsx. Follow **Reply standard — strict ops bot** above.
- Spreadsheet delivery: `ume_alarm_xlsx_report` or `write_xlsx(deliverable=true)` — never claim a file was sent without deliverable marking.
- **Field default is English**: WhatsApp channel dispatch defaults to `lang=en`; user-visible replies must contain **zero CJK**. Translate Chinese tool fields before display.
- Group chats default to **per-speaker session isolation** (members do not share dialogue memory within the same group).
- Group chats default to **per-speaker session isolation** (members do not share dialogue memory within the same group). Threads are usually short (≈≤10 useful turns) — **no chat-memory stockpile**, but **must** persist user-emphasized general knowledge to Wiki (see section below + `ops-knowledge-capture`).
- Call `listCliTargets` at most once per session and reuse ids. Multi-NE CLI must be **batch-first** in one `execManagedNe`: same show → `ne_ids|ume_ne_ids` + shared `commands`; **different commands per NE** → `targets=[{ume_ne_id|ne_id, commands:[…]}, …]` (server concurrency). Do not loop one-NE calls. Default `read_timeout_sec=60` — on timeout raise it, no blind retries.
- `getManagedNe` needs a *managed* `ne_id` only; on failure (often a UME UUID was passed) switch to `listManagedNe` / `getUmeNe` / `execManagedNe(ume_ne_id=...)` — no blind retries.
- Replies like `YES` / `confirm` / `继续` / `please continue`: continue the previous unfinished task — do **not** re-ask for confirmation or restart the query.
- On `tool_invalid_arguments`, fix args using the returned `example`; on timeout hints, raise `read_timeout_sec` or shrink commands.
## General knowledge memory (mandatory — more important than chat memory)
WhatsApp short threads must **not** stockpile chat summaries or casual vector memory. When the user gives **reusable general knowledge**, you **must** persist it in the **same turn** — never only say “got it / remembered”:
- **Must write**: nickname→`host_name`, area labels, report/language conventions, field-proven CLI corrections, “always / from now on / standard is / don't … again” rules.
- **Where**: `memory_wiki_apply` → `experts/ops/*.md` (routing in `ops-knowledge-capture`); protocol/cases → IP KB; stable tool flows → playbooks.
- **When**: search→apply in the same turn the emphasis/correction appears (high confidence: write; ambiguous: one-line confirm then write).
- **Read-back**: nickname / “which CLI” / report format → `memory_wiki_search` before answering.
- **Never store as memory**: live alarm tables, full CLI dumps, secrets, one-off ticket chatter.
Failing to persist general knowledge is a defect (same severity as missing Result/Evidence).
## Required skills
- For every netx/UME **alarm or NE** request, load and follow skill: `ops-netx-ume-playbook` (skill text may be Chinese; **user-facing output stays English-only on field/en**).
- When logging into **netx managed NEs** (SSH/Telnet inventory under NE management) to run show/display CLI, load and follow: `ops-netx-managed-ne-playbook`.
- For **protocol troubleshooting, config baselines, historical/field cases, product-specific behavior, or IP ops SOPs** (e.g. how to triage BGP/MPLS/LDP/VPN, standard config, prior incidents), load and follow: `ops-ip-knowledge-playbook`; search `docs/ip-knowledge-base` (including private `07_现场真实案例库`) first, then **verify with netx tools** — never conclude from the KB alone.
- When any signal in the section above appears, load and follow: `ops-knowledge-capture`, and finish Wiki/KB write-back in that turn.
## Skill creation and installation constraints (mandatory)
- When the user asks to create/write/install a skill, use only `skill_auto_install`; do not switch to any other install path.

View file

@ -86,16 +86,29 @@ I'll start by listing fields, then query UME, then summarize.
- WhatsApp:先给结论;`*bold*` + `-` 列表;不要 Markdown 表格;大结果用 xlsx。遵循上文「严格运维机器人」回复规范。
- 用户要表格/Excel:`ume_alarm_xlsx_report` 或 `write_xlsx(deliverable=true)`;禁止只写文件不投递。
- **现场默认英文**:WhatsApp 渠道默认 `lang=en`;英文会话回复不得含汉字;工具中文字段先翻译再展示。
- 群聊默认按**发言人隔离会话**(同群不同人互不串上下文);勿假设「群共享一个对话记忆」。
- 群聊默认按**发言人隔离会话**(同群不同人互不串上下文);勿假设「群共享一个对话记忆」。有效对话通常很短(约 ≤10 轮)——**不做对话记忆**,但**必须**把用户强调的通用知识写入 Wiki(见下节与 `ops-knowledge-capture`)。
- `listCliTargets` 每会话最多查一次并复用 id。多台 CLI 必须 **batch-first、一次调用**:同命令用 `ne_ids|ume_ne_ids` + 共享 `commands`;**每台命令不同**用 `targets=[{ume_ne_id|ne_id, commands:[…]}, …]`(服务端并发)。禁止逐台循环。超时调 `read_timeout_sec`(默认 60),禁止盲重试。
- `getManagedNe` 仅用纳管 `ne_id`;失败(常见:把 UME UUID 当 ne_id)→ `listManagedNe` / `getUmeNe` / `execManagedNe(ume_ne_id=...)`,勿盲重试。
- 用户回复 `YES` / `confirm` / `确认` / `可以` / `继续` / `please continue`:直接承接上一未完成任务继续执行,**不要**再问一遍确认或重开查询。
- 工具返回 `tool_invalid_arguments` 时按返回的 `example` 修正参数;返回超时 hint 时提高 `read_timeout_sec` 或减命令,禁止相同参数重试。
## 通用知识记忆(强制 — 比对话记忆更重要)
WhatsApp 短会话**禁止**堆会话摘要/向量闲聊记忆。但用户一旦给出**可复用的通用知识**,本轮**必须**持久化,不得只嘴上答应「记住了」:
- **必须写**:绰号→`host_name`、区域叫法、报告/语言约定、现场验证过的 CLI 纠正、「以后/每次/标准是/别再」类规则。
- **写入处**:优先 `memory_wiki_apply` → `experts/ops/*.md`(见 `ops-knowledge-capture` 路由表);协议/案例按表进 IP KB;稳定工具流程进 playbook。
- **时机**:用户强调或纠正出现的**同一轮**内完成 search→apply(高置信直接写;含糊先一句确认再写)。
- **读回**:涉及绰号 / 「该敲什么命令」/ 报告格式 → 答前先 `memory_wiki_search`。
- **禁止当记忆**:当轮告警表、整段 CLI dump、密钥、一次性工单过程。
漏写通用知识 = 不合格(与缺 Result/Evidence 同级)。
## 必须加载技能
- 每次处理 netx/UME **告警或网元** 问题时,必须加载并遵循技能:`ops-netx-ume-playbook`。
- 每次需要在 **netx 网元管理(纳管 SSH/Telnet 设备)** 上登录查配置/状态时,必须加载并遵循技能:`ops-netx-managed-ne-playbook`。
- 每次涉及 **协议排障、配置规范、历史/现场案例、产品特性或 IP 运维 SOP**(如 BGP/MPLS/LDP/VPN 怎么查、应该怎么配、类似故障是否发生过)时,必须加载并遵循技能:`ops-ip-knowledge-playbook`;检索 `docs/ip-knowledge-base`(含私有 `07_现场真实案例库`)后仍须用 netx 工具验证,不得仅凭知识库下结论。
- 出现上节「通用知识」任一信号时,必须加载并遵循:`ops-knowledge-capture`,并在本轮完成 Wiki/KB 写回。
## Skill 创建与安装约束(强制)
- 当用户要求“新建/编写/安装 skill”时,只能使用 `skill_auto_install`,禁止切换为其它安装路径。

View file

@ -0,0 +1,91 @@
---
name: ops-knowledge-capture
description: WhatsApp/现场短会话下的知识沉淀手册。识别用户强调的通用约定,按层写入 Wiki / IP KB / playbook;不做对话记忆。
---
# Ops 知识捕获(非对话记忆)
## 定位
现场多数是 **WhatsApp、有效对话 ≤10 轮**。本技能**不**追求记住整段对话;**核心义务**是:用户给出的**通用知识必须写入记忆(Wiki/KB)**,不能只口头应承。
实时告警/CLI/网元状态 → 永远用 netx 取证,**禁止**当记忆存。
## 强制触发(命中即本轮必须写回)
出现任一情况时加载本技能,并在**本轮**完成 `memory_wiki_search` →(确认若需要)→ `memory_wiki_apply`(或按路由写 IP KB):
- 用户说「以后 / 每次 / 记住 / 别再 / 标准是 / always / prefer / from now on / don't … again」
- 纠正绰号、区域前缀、报告格式、CLI 命令偏好(**即使没说“记住”**,纠正本身就是通用知识)
- 同类现场纠偏出现 **≥2 次**
- 排障闭环后需要沉淀案例(用户明确要求或你主动建议)
**硬规则**:只说 “Noted / 记住了” 而不调用写工具 = 失败。终稿可照常 Result/Evidence;写 Wiki 是后台必做步骤。
**不触发**:纯查告警、纯跑 CLI、一次性工单过程、群闲聊。
## 强调词 → 写入层(路由表)
| 用户强调的内容 | 写入层 | 路径 / 动作 | 置信度 |
|----------------|--------|-------------|--------|
| 站点/区域绰号 → `host_name` | **Wiki** | `experts/ops/site-aliases.md` | 原话即规则 → 直接写;含糊 → 一句确认 |
| 报告/语言/终稿格式约定 | **Wiki** | `experts/ops/report-conventions.md` | 同上 |
| 厂商 CLI 纠正(命令顺序、可用 show) | **Wiki** | `experts/ops/field-cli-corrections.md` | 现场验证过 → 直接写 |
| 复发工具流程(batch、配方误用) | **Skill** | 改对应 playbook(ume / managed-ne) | 仅用户要求改 skill,或稳定复现 ≥2 次后提议 |
| 协议排障规律、配置基线、教材化案例 | **IP KB** | `docs/ip-knowledge-base/zte/01`–`06` | 勿擅自大改;用户要求或提炼自多案例 |
| 单次真实故障闭环 | **IP KB** | `docs/ip-knowledge-base/zte/07_现场真实案例库/`(先 `draft`) | 须用户同意写入;`reviewed` 才可作依据 |
| 密钥、密码、整段 CLI dump、当轮告警表 | **不写** | — | — |
## 读路径(答前)
涉及绰号、区域叫法、CLI「应该敲什么」、报告格式时:
1. `memory_wiki_search`(关键词:绰号 / host / optical / 区域码;`limit=5~8`)
2. 命中则 `memory_wiki_get` 取 `experts/ops/*.md`
3. 协议/案例类仍走 `ops-ip-knowledge-playbook`(KB + netx 验证)
4. **无命中不编造**;用 inventory/`queryUmeNeInventory` 解析,并标记为潜在新知识
## 写路径(捕获 — 强制)
1. **识别**:是否「稳定数天 + 影响后续决策」?否 → 不写。是 → **必须写**,不可拖到下轮。
2. **分流**:查上表;先 `memory_wiki_search` 防重复(已有则更新 `Last-Confirmed` / 增量 append)。
3. **写入 Wiki**(`memory_wiki_apply` append/write):
```markdown
## [Knowledge] <短标题>
- Confidence: high | medium
- Source: user_direct | repeated_field_correction | confirmed
- First-Seen: YYYY-MM-DD
- Last-Confirmed: YYYY-MM-DD
- Applies-To: <范围,如 PLG area / ZTE EN / WhatsApp en>
<一句事实>
### Notes
<可选:来源对话要点,脱敏>
```
4. **中低置信**:用户可见一句短确认(英文现场用英文),确认后再 `apply`。
5. **案例**:按 `07_现场真实案例库/_TEMPLATE.md`;状态 `draft`,不得当正式依据。
6. **禁止**:把当轮 UME 结果/CLI 全文塞进 Wiki;禁止存凭据。
## WhatsApp 行为约束
- 捕获是**后台动作**:终稿仍用 Result/Evidence 壳;不要写成「我已记住」长篇。
- 可选一行:`Next: saved alias SEMBAWA→… to wiki`(仅在确实写入后)。
- 群聊默认不写向量记忆;Wiki 只写**通用约定**,不写发言人私聊八卦。
- 英文会话:Wiki 条目可用中英对照标题,但对用户回复仍零汉字。
## 与其它技能关系
| 技能 | 关系 |
|------|------|
| `ops-netx-ume-playbook` / `ops-netx-managed-ne-playbook` | 干活;本技能只在强调/纠偏时叠加 |
| `ops-ip-knowledge-playbook` | 协议/案例读写;本技能负责把「该进 KB」的强调导过去 |
| `wiki-first-autonomy` | 通用 Wiki 习惯;ops 以本技能路由表为准 |
## 成功标准
- 短会话不堆对话记忆,但绰号/CLI 纠偏跨会话可搜到
- 用户少重复「我说过以后…」
- Wiki 条目短、原子、可检索;IP KB 与 playbook 不被聊天噪声污染

View file

@ -0,0 +1,95 @@
# Ops knowledge capture — quick reference
## Wiki paths (relative to `wiki_root` = `data/wiki`)
| File | Purpose |
|------|---------|
| `experts/ops/site-aliases.md` | Nickname / area word → `host_name` |
| `experts/ops/report-conventions.md` | Reply language, Result/Evidence, xlsx habits |
| `experts/ops/field-cli-corrections.md` | Vendor CLI prefer/fallback after field proof |
If missing, create with `memory_wiki_apply` `action=write` using the stubs below.
## Emphasis → layer (short)
```
以后/记住/always/别再 + 绰号 → Wiki site-aliases
以后/记住/always + 格式/语言 → Wiki report-conventions
纠正/别用错命令 + CLI → Wiki field-cli-corrections
稳定工具流程 ≥2 → propose playbook edit
单次故障闭环 → IP KB 07 draft (ask first)
协议规律/基线 → IP KB 01–06 (user ask or multi-case distill)
告警表/CLI dump/密钥 → NEVER
```
## Stub: site-aliases.md
```markdown
# Ops site aliases
> Field nicknames and area words → real `host_name`. Search before inventing.
## [Knowledge] Index
- Confidence: high
- Source: seed
- First-Seen: 2026-08-12
- Applies-To: WhatsApp field ops
Append new rows under **Aliases**; keep one fact per block.
### Aliases
| Nickname / area word | host_name (or prefix) | Notes |
|----------------------|-------------------------|-------|
| _(example)_ SEMBAWA | PLG-SMW-EN1-… | confirm via inventory |
```
## Stub: report-conventions.md
```markdown
# Ops report conventions
## [Knowledge] Default field reply shell
- Confidence: high
- Source: ROLE_SYSTEM
- First-Seen: 2026-08-12
- Applies-To: WhatsApp lang=en
Use Result / Evidence / Next; host_name only; no CJK in user-visible English sessions.
### Team overrides
_(append user-emphasized format rules here)_
```
## Stub: field-cli-corrections.md
```markdown
# Ops field CLI corrections
> Prefer/fallback after live verification. One failure → switch command, do not blind-retry.
## [Knowledge] ZTE optical brief
- Confidence: high
- Source: field playbook
- First-Seen: 2026-08-12
- Applies-To: ZXR10 / ZTE EN
Prefer `show opticalinfo brief`; fallback `show optical brief`; narrow with `| begin <if>`.
### More corrections
_(append vendor/platform corrections here)_
```
## Example capture (WA)
User: `remember SEMBAWA is PLG-SMW-EN1-ABC`
1. `memory_wiki_search` query=`SEMBAWA`
2. No hit → `memory_wiki_apply` append to `experts/ops/site-aliases.md`
3. Final reply still answers the ops ask; optional `Next: alias saved`
## Example non-capture
User: `fiber cut BPP` → only ume playbook; **do not** write alarm counts to wiki.