@hfyjq/crannia 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/NOTICE +45 -45
- package/THIRD-PARTY-FRONTEND.md +5266 -5266
- package/THIRD-PARTY-PYTHON.md +162 -153
- package/THIRD-PARTY.md +316 -316
- package/apps/desktop/quotes.txt +56 -56
- package/bus/core.py +671 -671
- package/bus/loaders/channel_loader.py +64 -64
- package/bus/loaders/skill_md.py +676 -676
- package/bus/skill_state.py +124 -124
- package/channels/cli_channel/manifest.yaml +5 -5
- package/channels/dingtalk_channel/manifest.yaml +12 -12
- package/channels/feishu_channel/manifest.yaml +12 -12
- package/channels/qq_bot_channel/__init__.py +1 -1
- package/channels/qq_bot_channel/handler.py +881 -881
- package/channels/qq_bot_channel/manifest.yaml +4 -4
- package/channels/telegram_channel/__init__.py +1 -1
- package/channels/telegram_channel/handler.py +813 -813
- package/channels/telegram_channel/manifest.yaml +4 -4
- package/channels/telegram_channel/media.py +231 -231
- package/channels/textfmt.py +58 -58
- package/channels/wechat_channel/__init__.py +1 -1
- package/channels/wechat_channel/auth.py +23 -5
- package/channels/wechat_channel/manifest.yaml +5 -5
- package/channels/wechat_channel/media.py +178 -178
- package/config.yaml +2 -2
- package/core/activity.py +3 -0
- package/core/agent_loop.py +390 -55
- package/core/approval.py +17 -6
- package/core/artifacts.py +7 -0
- package/core/auto_review.py +23 -5
- package/core/channel_configs.py +34 -2
- package/core/channel_turns.py +759 -759
- package/core/child_approval.py +150 -0
- package/core/config_requirements.py +205 -0
- package/core/cron/runner.py +118 -6
- package/core/cron/store.py +14 -5
- package/core/cron/tools.py +17 -5
- package/core/endpoint.py +141 -0
- package/core/events.py +23 -0
- package/core/i18n.py +329 -329
- package/core/ice/store.py +191 -191
- package/core/inbound.py +193 -193
- package/core/jobs.py +19 -3
- package/core/last_good.py +150 -150
- package/core/llm_errors.py +227 -227
- package/core/llm_retry.py +230 -230
- package/core/memory/compressor.py +1214 -1214
- package/core/memory/manager.py +14 -0
- package/core/model_configs.py +80 -0
- package/core/pipeline/scheduler.py +2 -2
- package/core/pipeline/stages/agent_loop.py +24 -4
- package/core/pipeline/stages/pre_process.py +58 -7
- package/core/prompt_assembler.py +680 -680
- package/core/rg.py +255 -255
- package/core/security.py +1544 -1544
- package/core/settings_baseline.py +70 -1
- package/core/shell.py +5 -17
- package/core/skill_settings.py +7 -2
- package/core/state_registry.py +19 -0
- package/core/subagent.py +64 -3
- package/core/task_tool.py +1 -1
- package/core/tasks_notify.py +69 -4
- package/core/tiers.py +9 -3
- package/core/tool_outcome.py +108 -0
- package/core/update_tui.py +158 -0
- package/core/version.py +2 -2
- package/core/web_cache.py +152 -0
- package/crannia_tray.py +278 -278
- package/creators/models.json +4 -4
- package/data/settings.example.json +67 -0
- package/licenses/GPL-3.0.txt +619 -619
- package/licenses/LGPL-2.1.txt +502 -502
- package/licenses/LGPL-3.0.txt +165 -165
- package/licenses/MIT-chat-on-wechat.txt +18 -18
- package/licenses/MIT-deepseek-harness.txt +21 -21
- package/licenses/Molio-LICENSE.txt +44 -44
- package/locales/en.json +9 -4
- package/main.py +154 -154
- package/mcpx/manager.py +522 -522
- package/mcpx/servers/__init__.py +22 -22
- package/mcpx/servers/web_search.py +321 -33
- package/package.json +14 -9
- package/providers/anthropic/client.py +772 -772
- package/providers/cost_table.json +3779 -3779
- package/providers/deepseek/client.py +20 -20
- package/providers/deepseek/manifest.yaml +2 -2
- package/providers/factory.py +136 -136
- package/providers/lmstudio/client.py +2 -2
- package/providers/metadata.py +80 -80
- package/providers/model_capabilities.json +6665 -6665
- package/providers/moonshot/client.py +12 -12
- package/providers/ollama/client.py +2 -2
- package/providers/openai/client.py +13 -13
- package/providers/openrouter/client.py +2 -2
- package/providers/qwen/__init__.py +1 -1
- package/providers/qwen/client.py +2 -2
- package/providers/qwen/manifest.yaml +16 -16
- package/providers/rate_limiter.py +144 -144
- package/providers/siliconflow/client.py +2 -2
- package/providers/validation.py +171 -171
- package/providers/window_table.json +8909 -8909
- package/sbom.json +4413 -4296
- package/skills/entertainment/SKILL.md +35 -35
- package/skills/entertainment/__init__.py +1 -1
- package/skills/entertainment/handler.py +91 -91
- package/skills/entertainment/manifest.yaml +26 -26
- package/skills/file_parser/GUIDANCE.md +10 -10
- package/skills/file_parser/handler.py +177 -4
- package/skills/file_parser/manifest.yaml +22 -1
- package/skills/github/SKILL.md +32 -32
- package/skills/github/__init__.py +1 -1
- package/skills/github/manifest.yaml +5 -0
- package/skills/mail_parser/SKILL.md +68 -68
- package/skills/mail_parser/__init__.py +1 -1
- package/skills/mail_parser/handler.py +806 -806
- package/skills/mail_parser/manifest.yaml +5 -0
- package/skills/media_gen/GUIDANCE.md +19 -19
- package/skills/media_gen/SKILL.md +43 -43
- package/skills/media_gen/__init__.py +1 -1
- package/skills/media_gen/handler.py +430 -430
- package/skills/media_gen/manifest.yaml +93 -88
- package/skills/office_parser/cell_validation.py +127 -127
- package/skills/office_parser/excel_transform.py +936 -936
- package/skills/office_parser/layout_spec.py +243 -243
- package/skills/office_parser/pptx_export/console_encoding.py +27 -27
- package/skills/office_parser/pptx_export/resource_paths.py +88 -88
- package/skills/office_parser/pptx_export/svg_finalize/__init__.py +12 -12
- package/skills/office_parser/pptx_export/svg_finalize/align_embed_images.py +575 -575
- package/skills/office_parser/pptx_export/svg_finalize/crop_images.py +366 -366
- package/skills/office_parser/pptx_export/svg_finalize/embed_icons.py +498 -498
- package/skills/office_parser/pptx_export/svg_finalize/embed_images.py +288 -288
- package/skills/office_parser/pptx_export/svg_finalize/fix_image_aspect.py +388 -388
- package/skills/office_parser/pptx_export/svg_finalize/flatten_tspan.py +818 -818
- package/skills/office_parser/pptx_export/svg_finalize/svg_rect_to_path.py +345 -345
- package/skills/office_parser/pptx_export/svg_to_pptx/__init__.py +14 -14
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/__init__.py +1 -1
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/context.py +186 -186
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/converter.py +781 -781
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/elements.py +2490 -2490
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/paths.py +429 -429
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/styles.py +656 -656
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/__init__.py +1 -1
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/builder.py +1267 -1267
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/dimensions.py +155 -155
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/discovery.py +101 -101
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/media.py +141 -141
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/narration.py +236 -236
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/notes.py +257 -257
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/slide_xml.py +136 -136
- package/skills/office_parser/pptx_export/svg_to_pptx/tspan_flattener.py +44 -44
- package/skills/office_parser/pptx_export/svg_to_pptx/use_expander.py +129 -129
- package/skills/office_parser/references/LICENSE-Office-Word-MCP-Server.txt +20 -20
- package/skills/office_parser/references/LICENSE-excel-mcp-server.txt +21 -21
- package/skills/office_parser/references/layout_library.md +816 -816
- package/skills/office_parser/references/ppt-master/LICENSE +21 -21
- package/skills/office_parser/references/ppt-master/references/executor-base.md +474 -474
- package/skills/office_parser/references/ppt-master/references/shared-standards.md +1002 -1002
- package/skills/office_parser/references/ppt-master/references/strategist.md +880 -880
- package/skills/office_parser/references/ppt-master/references/template-designer.md +402 -402
- package/skills/office_parser/references/ppt-master/references/visual-review.md +240 -240
- package/skills/office_parser/references/ppt-master/references/visual-styles/_index.md +106 -106
- package/skills/office_parser/references/ppt-master/references/visual-styles/blueprint.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/brutalist.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/chalkboard.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/dark-tech.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/data-journalism.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/editorial.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/glassmorphism.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/ink-notes.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/ink-wash.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/memphis.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/paper-cut.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/photo-editorial.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/pixel-art.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/sketch-notes.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/soft-rounded.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/swiss-minimal.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/vintage-poster.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/zine.md +37 -37
- package/skills/office_parser/references/spec_lock.md +235 -235
- package/skills/office_parser/soffice.py +68 -68
- package/skills/office_parser/word_tools.py +2909 -2909
- package/tui/crannia.cmd +134 -0
- package/tui/crannia_tui/__init__.py +1 -0
- package/tui/crannia_tui/__main__.py +223 -0
- package/tui/crannia_tui/app.py +1318 -0
- package/tui/crannia_tui/app.tcss +153 -0
- package/tui/crannia_tui/approval.py +85 -0
- package/tui/crannia_tui/backend.py +279 -0
- package/tui/crannia_tui/channel.py +472 -0
- package/tui/crannia_tui/client.py +125 -0
- package/tui/crannia_tui/clipboard.py +62 -0
- package/tui/crannia_tui/commands.py +65 -0
- package/tui/crannia_tui/doctor.py +304 -0
- package/tui/crannia_tui/events.py +84 -0
- package/tui/crannia_tui/headless.py +152 -0
- package/tui/crannia_tui/i18n.py +164 -0
- package/tui/crannia_tui/locales/en.json +263 -0
- package/tui/crannia_tui/outcome.py +62 -0
- package/tui/crannia_tui/paths.py +181 -0
- package/tui/crannia_tui/probe.py +53 -0
- package/tui/crannia_tui/profile.py +169 -0
- package/tui/crannia_tui/render.py +209 -0
- package/tui/crannia_tui/settings.py +134 -0
- package/tui/crannia_tui/setup.py +380 -0
- package/tui/crannia_tui/term.py +116 -0
- package/tui/crannia_tui/ui.py +1236 -0
- package/tui/crannia_tui/update.py +389 -0
- package/vendor/ripgrep/COPYING.txt +3 -3
- package/vendor/ripgrep/LICENSE-MIT.txt +21 -21
- package/vendor/ripgrep/NOTICE-vscode-ripgrep.txt +13 -13
- package/vendor/ripgrep/README.md +51 -51
- package/vendor/ripgrep/UNLICENSE.txt +24 -24
- package/vendor/ripgrep/package-source.json +19 -19
- package/web/__main__.py +15 -0
- package/web/server.py +168 -19
- package/web/static/img/channel-telegram.svg +1 -1
- package/web/static/img/channel-wechat.svg +1 -1
- package/web/templates/logs.html +49 -49
- package/web/templates/models.html +46 -46
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: entertainment
|
|
3
|
-
description: 娱乐指令 Skill — 音乐点歌。Use when the user asks to play music.
|
|
4
|
-
metadata:
|
|
5
|
-
kind: skill
|
|
6
|
-
loader: manifest.yaml
|
|
7
|
-
tools: search_song
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# entertainment
|
|
11
|
-
|
|
12
|
-
娱乐指令 Skill — 音乐点歌。
|
|
13
|
-
|
|
14
|
-
> 此 skill 仍在搭建中,剩余功能支持请等待更新。
|
|
15
|
-
|
|
16
|
-
## 架构
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
用户: "来首周杰伦的歌"
|
|
20
|
-
→ entertainment.search_song
|
|
21
|
-
→ 网易云音乐公开搜索接口
|
|
22
|
-
→ 返回结构化结果给 LLM → 回复用户
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## 工具
|
|
26
|
-
|
|
27
|
-
| 工具 | 说明 | 依赖 |
|
|
28
|
-
|------|------|------|
|
|
29
|
-
| `search_song` | 搜索网易云音乐歌曲 | 无(直接 HTTP API) |
|
|
30
|
-
|
|
31
|
-
## 待扩展
|
|
32
|
-
|
|
33
|
-
- `get_trending` — 热榜/热门内容
|
|
34
|
-
- `download_audio` — 音频下载(需 yt-dlp)
|
|
35
|
-
- `create_playlist` — 歌单管理
|
|
1
|
+
---
|
|
2
|
+
name: entertainment
|
|
3
|
+
description: 娱乐指令 Skill — 音乐点歌。Use when the user asks to play music.
|
|
4
|
+
metadata:
|
|
5
|
+
kind: skill
|
|
6
|
+
loader: manifest.yaml
|
|
7
|
+
tools: search_song
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# entertainment
|
|
11
|
+
|
|
12
|
+
娱乐指令 Skill — 音乐点歌。
|
|
13
|
+
|
|
14
|
+
> 此 skill 仍在搭建中,剩余功能支持请等待更新。
|
|
15
|
+
|
|
16
|
+
## 架构
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
用户: "来首周杰伦的歌"
|
|
20
|
+
→ entertainment.search_song
|
|
21
|
+
→ 网易云音乐公开搜索接口
|
|
22
|
+
→ 返回结构化结果给 LLM → 回复用户
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 工具
|
|
26
|
+
|
|
27
|
+
| 工具 | 说明 | 依赖 |
|
|
28
|
+
|------|------|------|
|
|
29
|
+
| `search_song` | 搜索网易云音乐歌曲 | 无(直接 HTTP API) |
|
|
30
|
+
|
|
31
|
+
## 待扩展
|
|
32
|
+
|
|
33
|
+
- `get_trending` — 热榜/热门内容
|
|
34
|
+
- `download_audio` — 音频下载(需 yt-dlp)
|
|
35
|
+
- `create_playlist` — 歌单管理
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"""Entertainment skill — music, video, link sharing."""
|
|
1
|
+
"""Entertainment skill — music, video, link sharing."""
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Entertainment skill — music commands.
|
|
3
|
-
|
|
4
|
-
此 skill 仍在搭建中,剩余功能支持请等待更新。
|
|
5
|
-
|
|
6
|
-
Handles user-facing entertainment requests like "play a song" / "来首周杰伦的歌".
|
|
7
|
-
|
|
8
|
-
Hard constraints:
|
|
9
|
-
1. No media download — information first, URLs only.
|
|
10
|
-
2. Returns structured, LLM-friendly dicts.
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
from __future__ import annotations
|
|
14
|
-
|
|
15
|
-
from core.security import SecurityGuard
|
|
16
|
-
|
|
17
|
-
_security: SecurityGuard | None = None
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def init(security: SecurityGuard) -> None:
|
|
21
|
-
"""装载入口 —— 与其它 skill 同一个接口(`bus/loaders/skill_loader.py` 调它)。"""
|
|
22
|
-
global _security
|
|
23
|
-
_security = security
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
# Tool: search_song
|
|
27
|
-
|
|
28
|
-
def search_song(keyword: str, limit: int = 5) -> dict:
|
|
29
|
-
"""
|
|
30
|
-
Search NetEase Cloud Music for songs.
|
|
31
|
-
|
|
32
|
-
Uses the public search API (no auth required for basic search).
|
|
33
|
-
Returns song ID, name, artist, album for each result.
|
|
34
|
-
|
|
35
|
-
Args:
|
|
36
|
-
keyword: Search query (song name, artist name).
|
|
37
|
-
limit: Max results (default 5).
|
|
38
|
-
|
|
39
|
-
Returns:
|
|
40
|
-
dict with songs list.
|
|
41
|
-
"""
|
|
42
|
-
if not keyword.strip():
|
|
43
|
-
return {"success": False, "error": "请提供搜索关键词"}
|
|
44
|
-
|
|
45
|
-
import asyncio
|
|
46
|
-
import concurrent.futures
|
|
47
|
-
|
|
48
|
-
async def _search():
|
|
49
|
-
import aiohttp
|
|
50
|
-
url = "https://music.163.com/api/search/get"
|
|
51
|
-
params = {"s": keyword, "type": 1, "limit": min(limit, 20), "offset": 0}
|
|
52
|
-
headers = {
|
|
53
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
|
54
|
-
"Referer": "https://music.163.com",
|
|
55
|
-
}
|
|
56
|
-
try:
|
|
57
|
-
async with aiohttp.ClientSession() as session:
|
|
58
|
-
async with session.get(url, params=params, headers=headers, timeout=aiohttp.ClientTimeout(total=10)) as resp:
|
|
59
|
-
if resp.status >= 400:
|
|
60
|
-
return {"success": False, "error": f"搜索 API 返回 {resp.status}"}
|
|
61
|
-
# NetEase API often returns text/plain instead of application/json
|
|
62
|
-
data = await resp.json(content_type=None)
|
|
63
|
-
except Exception as e:
|
|
64
|
-
return {"success": False, "error": f"搜索请求失败: {type(e).__name__}: {e}"}
|
|
65
|
-
|
|
66
|
-
songs = []
|
|
67
|
-
for item in data.get("result", {}).get("songs", [])[:limit]:
|
|
68
|
-
artists = ", ".join(a.get("name", "") for a in item.get("artists", []))
|
|
69
|
-
songs.append({
|
|
70
|
-
"song_id": str(item.get("id", "")),
|
|
71
|
-
"name": item.get("name", ""),
|
|
72
|
-
"artists": artists,
|
|
73
|
-
"album": item.get("album", {}).get("name", ""),
|
|
74
|
-
"url": f"https://music.163.com/#/song?id={item.get('id', '')}",
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
"success": True,
|
|
79
|
-
"keyword": keyword,
|
|
80
|
-
"count": len(songs),
|
|
81
|
-
"songs": songs,
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
# Safe async runner
|
|
85
|
-
try:
|
|
86
|
-
loop = asyncio.get_running_loop()
|
|
87
|
-
except RuntimeError:
|
|
88
|
-
return asyncio.run(_search())
|
|
89
|
-
else:
|
|
90
|
-
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool:
|
|
91
|
-
return pool.submit(asyncio.run, _search()).result()
|
|
1
|
+
"""
|
|
2
|
+
Entertainment skill — music commands.
|
|
3
|
+
|
|
4
|
+
此 skill 仍在搭建中,剩余功能支持请等待更新。
|
|
5
|
+
|
|
6
|
+
Handles user-facing entertainment requests like "play a song" / "来首周杰伦的歌".
|
|
7
|
+
|
|
8
|
+
Hard constraints:
|
|
9
|
+
1. No media download — information first, URLs only.
|
|
10
|
+
2. Returns structured, LLM-friendly dicts.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from core.security import SecurityGuard
|
|
16
|
+
|
|
17
|
+
_security: SecurityGuard | None = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def init(security: SecurityGuard) -> None:
|
|
21
|
+
"""装载入口 —— 与其它 skill 同一个接口(`bus/loaders/skill_loader.py` 调它)。"""
|
|
22
|
+
global _security
|
|
23
|
+
_security = security
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# Tool: search_song
|
|
27
|
+
|
|
28
|
+
def search_song(keyword: str, limit: int = 5) -> dict:
|
|
29
|
+
"""
|
|
30
|
+
Search NetEase Cloud Music for songs.
|
|
31
|
+
|
|
32
|
+
Uses the public search API (no auth required for basic search).
|
|
33
|
+
Returns song ID, name, artist, album for each result.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
keyword: Search query (song name, artist name).
|
|
37
|
+
limit: Max results (default 5).
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
dict with songs list.
|
|
41
|
+
"""
|
|
42
|
+
if not keyword.strip():
|
|
43
|
+
return {"success": False, "error": "请提供搜索关键词"}
|
|
44
|
+
|
|
45
|
+
import asyncio
|
|
46
|
+
import concurrent.futures
|
|
47
|
+
|
|
48
|
+
async def _search():
|
|
49
|
+
import aiohttp
|
|
50
|
+
url = "https://music.163.com/api/search/get"
|
|
51
|
+
params = {"s": keyword, "type": 1, "limit": min(limit, 20), "offset": 0}
|
|
52
|
+
headers = {
|
|
53
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
|
54
|
+
"Referer": "https://music.163.com",
|
|
55
|
+
}
|
|
56
|
+
try:
|
|
57
|
+
async with aiohttp.ClientSession() as session:
|
|
58
|
+
async with session.get(url, params=params, headers=headers, timeout=aiohttp.ClientTimeout(total=10)) as resp:
|
|
59
|
+
if resp.status >= 400:
|
|
60
|
+
return {"success": False, "error": f"搜索 API 返回 {resp.status}"}
|
|
61
|
+
# NetEase API often returns text/plain instead of application/json
|
|
62
|
+
data = await resp.json(content_type=None)
|
|
63
|
+
except Exception as e:
|
|
64
|
+
return {"success": False, "error": f"搜索请求失败: {type(e).__name__}: {e}"}
|
|
65
|
+
|
|
66
|
+
songs = []
|
|
67
|
+
for item in data.get("result", {}).get("songs", [])[:limit]:
|
|
68
|
+
artists = ", ".join(a.get("name", "") for a in item.get("artists", []))
|
|
69
|
+
songs.append({
|
|
70
|
+
"song_id": str(item.get("id", "")),
|
|
71
|
+
"name": item.get("name", ""),
|
|
72
|
+
"artists": artists,
|
|
73
|
+
"album": item.get("album", {}).get("name", ""),
|
|
74
|
+
"url": f"https://music.163.com/#/song?id={item.get('id', '')}",
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
"success": True,
|
|
79
|
+
"keyword": keyword,
|
|
80
|
+
"count": len(songs),
|
|
81
|
+
"songs": songs,
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# Safe async runner
|
|
85
|
+
try:
|
|
86
|
+
loop = asyncio.get_running_loop()
|
|
87
|
+
except RuntimeError:
|
|
88
|
+
return asyncio.run(_search())
|
|
89
|
+
else:
|
|
90
|
+
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool:
|
|
91
|
+
return pool.submit(asyncio.run, _search()).result()
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
kind: skill
|
|
2
|
-
name: entertainment
|
|
3
|
-
version: "0.1.0"
|
|
4
|
-
load_strategy: on_demand
|
|
5
|
-
description: "娱乐指令 — 音乐点歌"
|
|
6
|
-
|
|
7
|
-
tools:
|
|
8
|
-
- name: search_song
|
|
9
|
-
permission: read
|
|
10
|
-
destructive: false
|
|
11
|
-
output_kind: structured
|
|
12
|
-
description: >
|
|
13
|
-
根据歌名或歌手搜索网易云音乐歌曲。返回歌曲 id、名称、歌手、专辑信息。
|
|
14
|
-
用户说"点歌"/"放歌"/"来首歌"时调用。不下载文件,仅返回歌曲信息。
|
|
15
|
-
inputSchema:
|
|
16
|
-
$schema: "https://json-schema.org/draft/2020-12/schema"
|
|
17
|
-
type: object
|
|
18
|
-
properties:
|
|
19
|
-
keyword:
|
|
20
|
-
type: string
|
|
21
|
-
description: "搜索关键词,如歌名、歌手名"
|
|
22
|
-
limit:
|
|
23
|
-
type: integer
|
|
24
|
-
default: 5
|
|
25
|
-
description: "返回结果数,默认 5"
|
|
26
|
-
required: [keyword]
|
|
1
|
+
kind: skill
|
|
2
|
+
name: entertainment
|
|
3
|
+
version: "0.1.0"
|
|
4
|
+
load_strategy: on_demand
|
|
5
|
+
description: "娱乐指令 — 音乐点歌"
|
|
6
|
+
|
|
7
|
+
tools:
|
|
8
|
+
- name: search_song
|
|
9
|
+
permission: read
|
|
10
|
+
destructive: false
|
|
11
|
+
output_kind: structured
|
|
12
|
+
description: >
|
|
13
|
+
根据歌名或歌手搜索网易云音乐歌曲。返回歌曲 id、名称、歌手、专辑信息。
|
|
14
|
+
用户说"点歌"/"放歌"/"来首歌"时调用。不下载文件,仅返回歌曲信息。
|
|
15
|
+
inputSchema:
|
|
16
|
+
$schema: "https://json-schema.org/draft/2020-12/schema"
|
|
17
|
+
type: object
|
|
18
|
+
properties:
|
|
19
|
+
keyword:
|
|
20
|
+
type: string
|
|
21
|
+
description: "搜索关键词,如歌名、歌手名"
|
|
22
|
+
limit:
|
|
23
|
+
type: integer
|
|
24
|
+
default: 5
|
|
25
|
+
description: "返回结果数,默认 5"
|
|
26
|
+
required: [keyword]
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
**权威在这几处**(通用文件与 PDF):
|
|
2
|
-
|
|
3
|
-
- **规范**:ISO 32000(PDF)—— 对象、字体、编码、内容流的语义。拿不准一段字节该怎么解、
|
|
4
|
-
一个字体映射为什么错位,以它为准。
|
|
5
|
-
- **库的源码**:`PyMuPDF`(`fitz`)与 `pdfplumber` 装在本机 `.venv` 里;
|
|
6
|
-
用 `run_command` 读它们的源码与 docstring,别凭记忆填参数名。
|
|
7
|
-
- **原始字节**:先把 `raw` / `bytes` 打出来看一眼再决定怎么解 ——
|
|
8
|
-
猜解码方式一个个试,代价是时间。
|
|
9
|
-
|
|
10
|
-
本 skill 的写件改的是用户的文件;处理不了就明说,别交半成品。
|
|
1
|
+
**权威在这几处**(通用文件与 PDF):
|
|
2
|
+
|
|
3
|
+
- **规范**:ISO 32000(PDF)—— 对象、字体、编码、内容流的语义。拿不准一段字节该怎么解、
|
|
4
|
+
一个字体映射为什么错位,以它为准。
|
|
5
|
+
- **库的源码**:`PyMuPDF`(`fitz`)与 `pdfplumber` 装在本机 `.venv` 里;
|
|
6
|
+
用 `run_command` 读它们的源码与 docstring,别凭记忆填参数名。
|
|
7
|
+
- **原始字节**:先把 `raw` / `bytes` 打出来看一眼再决定怎么解 ——
|
|
8
|
+
猜解码方式一个个试,代价是时间。
|
|
9
|
+
|
|
10
|
+
本 skill 的写件改的是用户的文件;处理不了就明说,别交半成品。
|
|
@@ -12,6 +12,7 @@ definitions live in manifest.yaml so the LLM sees them.
|
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
14
|
import io
|
|
15
|
+
import re
|
|
15
16
|
from pathlib import Path
|
|
16
17
|
from typing import Dict, Iterator, List, Tuple
|
|
17
18
|
|
|
@@ -231,6 +232,172 @@ def _pdf_read_plan(path):
|
|
|
231
232
|
return diag.repair
|
|
232
233
|
|
|
233
234
|
|
|
235
|
+
# ------------------------------------------------------------------
|
|
236
|
+
# 按页读(已知页码时取那几页的原文)
|
|
237
|
+
# ------------------------------------------------------------------
|
|
238
|
+
|
|
239
|
+
#: 单次最多读几页。与本仓库"一次工具结果就把事说清"的口径一致:
|
|
240
|
+
#: 页数多的需求用页码范围分几次读,不要一次拉一整本。
|
|
241
|
+
_READ_PAGES_MAX = 20
|
|
242
|
+
|
|
243
|
+
#: 单次正文字符预算。低于 `tool_result_max_chars`(生产 6000),
|
|
244
|
+
#: 留出页眉与尾注的位置 —— 这样一次结果就能完整装下,不必再走落盘指针。
|
|
245
|
+
_READ_PAGES_CHARS = 5000
|
|
246
|
+
|
|
247
|
+
#: 预算只剩这么多时就不再塞下一页(更短的片段没有阅读价值,只是噪声)。
|
|
248
|
+
_READ_PAGES_MIN_CHARS = 200
|
|
249
|
+
|
|
250
|
+
_PAGE_SEP_RE = re.compile(r"[,,、\s]+")
|
|
251
|
+
_PAGE_RANGE_RE = re.compile(r"(\d+)\s*[-~-]\s*(\d+)")
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _parse_page_spec(spec: str, total: int) -> Tuple[List[int], List[str]]:
|
|
255
|
+
"""解析页码表达式,返回 (页码列表, 附注)。
|
|
256
|
+
|
|
257
|
+
接受 `3` / `1-5` / `1,3,7-9`,页码从 1 起、闭区间。
|
|
258
|
+
越界的部分夹进 [1, total] 并把这件事记成附注 —— 夹取要如实说出来,
|
|
259
|
+
不能静默少读几页。写法本身读不懂才抛 `ValueError`(那是调用错误,
|
|
260
|
+
不是"这份文件的问题")。
|
|
261
|
+
"""
|
|
262
|
+
text = str(spec or "").strip()
|
|
263
|
+
if not text:
|
|
264
|
+
raise ValueError('没有给页码。用 pages="1-5" 这样的写法(从 1 起,闭区间)。')
|
|
265
|
+
wanted: List[int] = []
|
|
266
|
+
notes: List[str] = []
|
|
267
|
+
for part in _PAGE_SEP_RE.split(text):
|
|
268
|
+
if not part:
|
|
269
|
+
continue
|
|
270
|
+
m = _PAGE_RANGE_RE.fullmatch(part)
|
|
271
|
+
if m:
|
|
272
|
+
start, end = int(m.group(1)), int(m.group(2))
|
|
273
|
+
elif part.isdigit():
|
|
274
|
+
start = end = int(part)
|
|
275
|
+
else:
|
|
276
|
+
raise ValueError("页码写得读不懂:%s。用 3 / 1-5 / 1,3,7-9 这几种写法。"
|
|
277
|
+
% part)
|
|
278
|
+
if start > end:
|
|
279
|
+
raise ValueError("页码范围反了:%s(起点大于终点)。" % part)
|
|
280
|
+
if start < 1:
|
|
281
|
+
raise ValueError("页码从 1 起,收到 %d。" % start)
|
|
282
|
+
if start > total:
|
|
283
|
+
notes.append("第 %d 页起没有内容(全文共 %d 页)" % (start, total))
|
|
284
|
+
continue
|
|
285
|
+
if end > total:
|
|
286
|
+
notes.append("要的第 %d-%d 页只有到第 %d 页(全文共 %d 页)"
|
|
287
|
+
% (start, end, total, total))
|
|
288
|
+
wanted.extend(range(start, min(end, total) + 1))
|
|
289
|
+
return sorted(set(wanted)), notes
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def _page_span(pages: List[int]) -> str:
|
|
293
|
+
"""把页码列表收成 `1-3,7` 这种写法(尾注里让它可读、可直接粘回去)。"""
|
|
294
|
+
ordered = sorted(set(int(p) for p in pages))
|
|
295
|
+
out: List[str] = []
|
|
296
|
+
i = 0
|
|
297
|
+
while i < len(ordered):
|
|
298
|
+
j = i
|
|
299
|
+
while j + 1 < len(ordered) and ordered[j + 1] == ordered[j] + 1:
|
|
300
|
+
j += 1
|
|
301
|
+
out.append(str(ordered[i]) if i == j
|
|
302
|
+
else "%d-%d" % (ordered[i], ordered[j]))
|
|
303
|
+
i = j + 1
|
|
304
|
+
return ",".join(out)
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def read_pdf_pages(file_path: str, pages: str) -> str:
|
|
308
|
+
"""按页码读 PDF 的正文,直接把那几页的文字返回(回执是纯文本)。
|
|
309
|
+
|
|
310
|
+
与 `parse_pdf` 的分工:那个把全文切块建索引,正文只能靠 `search_chunks`
|
|
311
|
+
检索;这个给的是已知页码时的原文(某张报表、附录、图纸),不建索引、
|
|
312
|
+
也不进检索。
|
|
313
|
+
|
|
314
|
+
Args:
|
|
315
|
+
file_path: PDF 路径(相对路径按工作区解析)。
|
|
316
|
+
pages: 页码表达式,从 1 起,如 `3` / `1-5` / `1,3,7-9`。
|
|
317
|
+
|
|
318
|
+
单次最多 20 页、约 5000 字符;没读到的部分如实说明并给出下一次的
|
|
319
|
+
页码,不静默截断。
|
|
320
|
+
"""
|
|
321
|
+
_require_security()
|
|
322
|
+
resolved_path = _require_file(file_path)
|
|
323
|
+
resolved = _security.validate_path(str(resolved_path)) # type: ignore[union-attr]
|
|
324
|
+
|
|
325
|
+
if resolved.suffix.lower() != ".pdf":
|
|
326
|
+
return ("错误:%s 不是 PDF(后缀 %s)。解析 PDF 用这个工具,"
|
|
327
|
+
"别的格式用 `parse_txt` 那一族。"
|
|
328
|
+
% (resolved.name, resolved.suffix or "无"))
|
|
329
|
+
|
|
330
|
+
try:
|
|
331
|
+
reader = PdfReader(str(resolved))
|
|
332
|
+
total = len(reader.pages)
|
|
333
|
+
except Exception as exc: # noqa: BLE001
|
|
334
|
+
return "错误:打不开这份 PDF(%s: %s)。" % (type(exc).__name__, exc)
|
|
335
|
+
if total <= 0:
|
|
336
|
+
return "错误:这份 PDF 没有页(或者页数读不出来)。先用 `pdf_info` 看它。"
|
|
337
|
+
|
|
338
|
+
try:
|
|
339
|
+
wanted, notes = _parse_page_spec(pages, total)
|
|
340
|
+
except ValueError as exc:
|
|
341
|
+
return "错误:%s" % exc
|
|
342
|
+
if not wanted:
|
|
343
|
+
return ("没有可读的页码(%s)。全文共 %d 页,用 pages=\"1-%d\"。"
|
|
344
|
+
% (";".join(notes) or "都超出范围", total,
|
|
345
|
+
min(total, _READ_PAGES_MAX)))
|
|
346
|
+
|
|
347
|
+
try:
|
|
348
|
+
plan = _pdf_read_plan(resolved)
|
|
349
|
+
except ValueError as exc:
|
|
350
|
+
return "错误:%s" % exc
|
|
351
|
+
|
|
352
|
+
blocks: List[str] = []
|
|
353
|
+
read: List[int] = []
|
|
354
|
+
used = 0
|
|
355
|
+
try:
|
|
356
|
+
import pdfplumber
|
|
357
|
+
with pdfplumber.open(str(resolved)) as pdf:
|
|
358
|
+
for pno in wanted[:_READ_PAGES_MAX]:
|
|
359
|
+
page = pdf.pages[pno - 1]
|
|
360
|
+
body = (_page_text(page, plan) or "").strip()
|
|
361
|
+
if not body:
|
|
362
|
+
body = ("(本页没有可提取的文本层;若是扫描件,"
|
|
363
|
+
"用 `pdf_to_images` 渲成图片看。)")
|
|
364
|
+
header = "\n--- 第 %d 页 / 共 %d 页 ---\n" % (pno, total)
|
|
365
|
+
room = _READ_PAGES_CHARS - used
|
|
366
|
+
if len(body) > room:
|
|
367
|
+
if room >= _READ_PAGES_MIN_CHARS:
|
|
368
|
+
blocks.append(
|
|
369
|
+
header + body[:room]
|
|
370
|
+
+ "\n[本页被截断:原文 %d 字符,单次约 %d 字符。"
|
|
371
|
+
"要检索这一页的内容用 `parse_pdf` + `search_chunks`;"
|
|
372
|
+
"要\"看\"这一页用 `pdf_to_images`。]"
|
|
373
|
+
% (len(body), _READ_PAGES_CHARS))
|
|
374
|
+
read.append(pno)
|
|
375
|
+
break
|
|
376
|
+
blocks.append(header + body)
|
|
377
|
+
read.append(pno)
|
|
378
|
+
used += len(body) + len(header)
|
|
379
|
+
except Exception as exc: # noqa: BLE001
|
|
380
|
+
# 空密码能开的加密文档 pdfminer 自己会试;试不过的才落到这里。
|
|
381
|
+
_name = type(exc).__name__
|
|
382
|
+
if _name in ("PDFPasswordIncorrect", "PDFEncryptionError") \
|
|
383
|
+
or "password" in str(exc).lower():
|
|
384
|
+
return ("错误:这份 PDF 加了密,读不出正文。可以用密码打开的话,"
|
|
385
|
+
"另存一份不加密的再读;拿不到密码就如实告诉用户。")
|
|
386
|
+
return "错误:读这几页时失败(%s: %s)。" % (_name, exc)
|
|
387
|
+
|
|
388
|
+
tail = list(notes)
|
|
389
|
+
skipped = [p for p in wanted if p not in read]
|
|
390
|
+
if skipped:
|
|
391
|
+
tail.append("还有 %d 页没读(本次最多 %d 页、约 %d 字符);"
|
|
392
|
+
"下一次用 pages=\"%s\" 继续。"
|
|
393
|
+
% (len(skipped), _READ_PAGES_MAX, _READ_PAGES_CHARS,
|
|
394
|
+
_page_span(skipped[:_READ_PAGES_MAX])))
|
|
395
|
+
text = "".join(blocks).strip("\n")
|
|
396
|
+
if tail:
|
|
397
|
+
text += "\n\n[说明] " + ";".join(tail)
|
|
398
|
+
return text
|
|
399
|
+
|
|
400
|
+
|
|
234
401
|
def parse_txt(file_path: str, encoding: str = "utf-8") -> List[Dict]:
|
|
235
402
|
"""
|
|
236
403
|
Stream-parse a TXT file.
|
|
@@ -701,15 +868,21 @@ def _cross_zone_allowed(wm) -> bool:
|
|
|
701
868
|
return wm.take_cross_zone_grant()
|
|
702
869
|
|
|
703
870
|
|
|
704
|
-
def _delete_prompt(file_list: str) -> str:
|
|
871
|
+
def _delete_prompt(file_list: str, *, bulk: bool = False) -> str:
|
|
705
872
|
"""删除审批的提示语 —— 由 `core/approval.py` 那唯一一份选项表渲染。
|
|
706
873
|
|
|
707
874
|
不要在别处再拼一份:选项表一旦有多份副本,跨区与删除两条通道
|
|
708
875
|
会长出不一致的按钮与措辞。
|
|
876
|
+
|
|
877
|
+
*bulk* 必须换表,不能只换抬头:批量删除只有「1 同意 / 2 不同意」,
|
|
878
|
+
而 `delete` 那张表的 `"2"` 是「同意并且不再问删除」(会话级)。
|
|
879
|
+
拿错表给文本通道,用户回 `2` 的意思是「同意」,结算器(`delete_bulk`)
|
|
880
|
+
读出来的却是「不同意」——同一串数字在两条通道上是相反的意思。
|
|
709
881
|
"""
|
|
710
882
|
from core.approval import render_delete_body, render_prompt
|
|
711
|
-
|
|
712
|
-
|
|
883
|
+
kind = "delete_bulk" if bulk else "delete"
|
|
884
|
+
return render_prompt(kind, 1,
|
|
885
|
+
body=render_delete_body(file_list, kind=kind),
|
|
713
886
|
footer=False)
|
|
714
887
|
|
|
715
888
|
|
|
@@ -1182,7 +1355,7 @@ def delete_files(file_paths: list | None = None, pattern: str = "") -> dict:
|
|
|
1182
1355
|
"file_paths": [str(p) for p in valid],
|
|
1183
1356
|
"invalid": invalid,
|
|
1184
1357
|
# 选项表收在 `core/approval.py`(唯一一份)
|
|
1185
|
-
"prompt": _delete_prompt(file_list),
|
|
1358
|
+
"prompt": _delete_prompt(file_list, bulk=_over),
|
|
1186
1359
|
# 把已经排好版、已经折叠过的列表也带出去 —— 浮窗的渲染源
|
|
1187
1360
|
# 就是它。若浮窗自己拿 `file_paths` 重拼一份、且没有折叠逻辑,
|
|
1188
1361
|
# 同一个授权会在两条通道上长得不一样(IM 列 5 个,Web 全列)。
|
|
@@ -13,7 +13,7 @@ review_input: none
|
|
|
13
13
|
#: 措辞原则:新能力、最可能被找的东西放最前面,别按"先来后到"排。
|
|
14
14
|
#: 原先这段是纯英文("Parse PDF, TXT, CSV files…"),而模型的查询是中文,
|
|
15
15
|
#: jieba 切出来的词永远匹配不上英文文本,于是工具在、搜不到,等于不在。
|
|
16
|
-
description: "
|
|
16
|
+
description: "文件与图片:PDF 按页读、页面操作(合并/拆分/提取/旋转/水印/压缩/加密/转图片)、图片合成 PDF/压缩/缩放/转格式、解析 PDF/TXT/CSV 并检索、工作区文件与跨区搜索、交付文件。"
|
|
17
17
|
|
|
18
18
|
tools:
|
|
19
19
|
- name: parse_pdf
|
|
@@ -22,6 +22,7 @@ tools:
|
|
|
22
22
|
output_kind: prose
|
|
23
23
|
description: >
|
|
24
24
|
读取 PDF 文件内容:按页解析、分块建索引,正文用 search_chunks 检索。
|
|
25
|
+
已知页码、只想看那几页的原文时,改用 read_pdf_pages(不建索引,直接回文字)。
|
|
25
26
|
inputSchema:
|
|
26
27
|
$schema: "https://json-schema.org/draft/2020-12/schema"
|
|
27
28
|
type: object
|
|
@@ -31,6 +32,26 @@ tools:
|
|
|
31
32
|
description: "Path to the PDF file. If relative, resolved under workspace/"
|
|
32
33
|
required: ["file_path"]
|
|
33
34
|
|
|
35
|
+
- name: read_pdf_pages
|
|
36
|
+
permission: read
|
|
37
|
+
destructive: false
|
|
38
|
+
output_kind: prose
|
|
39
|
+
description: >
|
|
40
|
+
按页读 PDF 正文:直接返回那几页的文字,不建索引。
|
|
41
|
+
pages 是页码(支持 3 / 1-5 / 1,3,7-9);单次最多 20 页、约 5000 字符。
|
|
42
|
+
已知页码、只想看那几页时用它;通读全文用 parse_pdf + search_chunks。
|
|
43
|
+
inputSchema:
|
|
44
|
+
$schema: "https://json-schema.org/draft/2020-12/schema"
|
|
45
|
+
type: object
|
|
46
|
+
properties:
|
|
47
|
+
file_path:
|
|
48
|
+
type: string
|
|
49
|
+
description: "Path to the PDF file. If relative, resolved under workspace/"
|
|
50
|
+
pages:
|
|
51
|
+
type: string
|
|
52
|
+
description: "Page numbers (1-based): '3', '1-5', or '1,3,7-9'. Max 20 pages per call."
|
|
53
|
+
required: ["file_path", "pages"]
|
|
54
|
+
|
|
34
55
|
- name: parse_txt
|
|
35
56
|
permission: read
|
|
36
57
|
destructive: false
|
package/skills/github/SKILL.md
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: github
|
|
3
|
-
description: Query and act on GitHub through its REST API — your identity, repository files and directory listings, code search, issues (list/read/create), pull requests (list/read/create) and recent commits. Use when the user asks about a GitHub repo, wants to look at code hosted on GitHub, file or triage an issue, or open a pull request. Requires a GitHub token in the environment.
|
|
4
|
-
metadata:
|
|
5
|
-
kind: skill
|
|
6
|
-
loader: manifest.yaml
|
|
7
|
-
tools: github_whoami, github_get_file, github_search_code, github_list_issues, github_get_issue, github_create_issue, github_list_pulls, github_get_pull, github_create_pull, github_list_commits
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# GitHub
|
|
11
|
-
|
|
12
|
-
直接走 `api.github.com`,不经过任何第三方 MCP 服务。
|
|
13
|
-
|
|
14
|
-
## 凭据
|
|
15
|
-
|
|
16
|
-
环境变量 `CRANNIA_GITHUB_TOKEN`(优先)或 `GITHUB_PERSONAL_ACCESS_TOKEN`。
|
|
17
|
-
细粒度令牌只需要目标仓库的 **Contents 只读**;要建 issue / PR 再给对应读写。
|
|
18
|
-
|
|
19
|
-
**没配令牌时**:工具照常出现在工具表里,调用会回一句「没有配置 GitHub 令牌」——
|
|
20
|
-
那不是说"功能不存在",是"这一步需要一个令牌"。
|
|
21
|
-
|
|
22
|
-
## 什么时候用它
|
|
23
|
-
|
|
24
|
-
- 用户给的是一个 **GitHub 上**的链接 / `owner/repo` ⇒ 用它(本机的同名目录不是它)
|
|
25
|
-
- 要读**别人的仓库**(本机没有那份代码)⇒ 用它
|
|
26
|
-
- 只是读**本机**文件 ⇒ 用 `read_file`,不要绕道 GitHub
|
|
27
|
-
|
|
28
|
-
## 错误怎么读
|
|
29
|
-
|
|
30
|
-
- `401` 令牌无效或过期
|
|
31
|
-
- `403` 权限不足 **或** 触发限流(回执里有剩余次数与重置时间戳)
|
|
32
|
-
- `404` 仓库/文件/编号不对,**或者令牌看不到它**(私有仓库要选对 repository access)
|
|
1
|
+
---
|
|
2
|
+
name: github
|
|
3
|
+
description: Query and act on GitHub through its REST API — your identity, repository files and directory listings, code search, issues (list/read/create), pull requests (list/read/create) and recent commits. Use when the user asks about a GitHub repo, wants to look at code hosted on GitHub, file or triage an issue, or open a pull request. Requires a GitHub token in the environment.
|
|
4
|
+
metadata:
|
|
5
|
+
kind: skill
|
|
6
|
+
loader: manifest.yaml
|
|
7
|
+
tools: github_whoami, github_get_file, github_search_code, github_list_issues, github_get_issue, github_create_issue, github_list_pulls, github_get_pull, github_create_pull, github_list_commits
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# GitHub
|
|
11
|
+
|
|
12
|
+
直接走 `api.github.com`,不经过任何第三方 MCP 服务。
|
|
13
|
+
|
|
14
|
+
## 凭据
|
|
15
|
+
|
|
16
|
+
环境变量 `CRANNIA_GITHUB_TOKEN`(优先)或 `GITHUB_PERSONAL_ACCESS_TOKEN`。
|
|
17
|
+
细粒度令牌只需要目标仓库的 **Contents 只读**;要建 issue / PR 再给对应读写。
|
|
18
|
+
|
|
19
|
+
**没配令牌时**:工具照常出现在工具表里,调用会回一句「没有配置 GitHub 令牌」——
|
|
20
|
+
那不是说"功能不存在",是"这一步需要一个令牌"。
|
|
21
|
+
|
|
22
|
+
## 什么时候用它
|
|
23
|
+
|
|
24
|
+
- 用户给的是一个 **GitHub 上**的链接 / `owner/repo` ⇒ 用它(本机的同名目录不是它)
|
|
25
|
+
- 要读**别人的仓库**(本机没有那份代码)⇒ 用它
|
|
26
|
+
- 只是读**本机**文件 ⇒ 用 `read_file`,不要绕道 GitHub
|
|
27
|
+
|
|
28
|
+
## 错误怎么读
|
|
29
|
+
|
|
30
|
+
- `401` 令牌无效或过期
|
|
31
|
+
- `403` 权限不足 **或** 触发限流(回执里有剩余次数与重置时间戳)
|
|
32
|
+
- `404` 仓库/文件/编号不对,**或者令牌看不到它**(私有仓库要选对 repository access)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"""GitHub 原生集成 —— 走 REST API(不经 MCP)。"""
|
|
1
|
+
"""GitHub 原生集成 —— 走 REST API(不经 MCP)。"""
|