fix(skills): load categories independently and support non-git checkouts

SkillsManager refused to start when the local skills directory was not a
git repository (cloning into a non-empty path fails), and reload_skills()
returned early when injection/ was missing, so device and feature skills
never loaded. reload_packet_analysis_protocols() had the opposite bug:
an empty result wiped the registry while still reporting success.

- initialize(): accept a non-empty directory without .git as a local-only
  source (skip automatic updates, keep loading files); degrade to local
  files when GitPython is unavailable.
- _update_if_needed(): re-create/clone when the local directory vanished
  or moved, instead of reusing a stale handle forever.
- reload_skills(): injection, device and feature load independently; a
  missing category keeps its previously loaded entries.
- reload_packet_analysis_protocols(): an empty/missing directory keeps
  the existing registry and reports failure.
- reload_skills_repository(): drop the console guard cache so
  config/console_guard.txt applies on reload.

MCP device_skill_get now exposes the category filter, documents the
single-file (topic-less) layout, and returns a sections list for
index/summary of skills that have no topics/issues. An uninitialized
skills repository fails with a clear error instead of an empty list.
This commit is contained in:
yueguobin committed 2026-11-01 23:09:38 +08:00
1 parent 5ed252455d
commit 21fb84e91c
8 files changed
+338 -64

No files matched your search

+4
View File
@@ -322,12 +322,16 @@ The GNS3-Skills repository (the same one the embedded copilot reads) carries per
```python
device_skill_get(action="list") # 1. every loaded skill
device_skill_get(action="list", category="device") # optional category filter
device_skill_get(device_type="frr_vtysh") # 2. that device's skill + topic index
device_skill_get(device_type="frr_vtysh", topic="bgp") # 3. one targeted topic body
device_skill_get(device_type="gns3_vpcs_telnet") # single-file device: complete skill
```
Step 2 returns the base skill plus the topic index; topic bodies load **only** on an explicit `topic` request (step 3). The key is passed back exactly as step 1 returned it.
The repository ships two device layouts: split directories (`device/frr/` = `_base.yaml` + one file per protocol topic) and single files (`device/vpcs.yaml`). Single-file skills have **no topics** — step 2 with the default `full` detail returns the complete skill and there is no step 3. On such a skill, `detail="index"` returns a `sections` list (`config_commands`, `display_commands`, `notes`, ...) instead of an empty body, so the caller knows there is content to fetch.
### Device Config Workflow
```mermaid