@gulibs/safe-coder 0.0.26 → 0.0.28
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/README.md +678 -994
- package/dist/cache/cache-manager.d.ts +71 -0
- package/dist/cache/cache-manager.d.ts.map +1 -0
- package/dist/cache/cache-manager.js +244 -0
- package/dist/cache/cache-manager.js.map +1 -0
- package/dist/executor/cli-executor.d.ts +116 -0
- package/dist/executor/cli-executor.d.ts.map +1 -0
- package/dist/executor/cli-executor.js +140 -0
- package/dist/executor/cli-executor.js.map +1 -0
- package/dist/executor/dependency-checker.d.ts +23 -0
- package/dist/executor/dependency-checker.d.ts.map +1 -0
- package/dist/executor/dependency-checker.js +62 -0
- package/dist/executor/dependency-checker.js.map +1 -0
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/processor/content-processor.d.ts +76 -0
- package/dist/processor/content-processor.d.ts.map +1 -0
- package/dist/processor/content-processor.js +182 -0
- package/dist/processor/content-processor.js.map +1 -0
- package/dist/processor/guide-generator.d.ts +68 -0
- package/dist/processor/guide-generator.d.ts.map +1 -0
- package/dist/processor/guide-generator.js +189 -0
- package/dist/processor/guide-generator.js.map +1 -0
- package/dist/server/safe-coder-mcp.d.ts +18 -0
- package/dist/server/safe-coder-mcp.d.ts.map +1 -0
- package/dist/server/safe-coder-mcp.js +171 -0
- package/dist/server/safe-coder-mcp.js.map +1 -0
- package/dist/tools/cache-tools.d.ts +42 -0
- package/dist/tools/cache-tools.d.ts.map +1 -0
- package/dist/tools/cache-tools.js +70 -0
- package/dist/tools/cache-tools.js.map +1 -0
- package/dist/tools/crawl-documentation.d.ts +78 -0
- package/dist/tools/crawl-documentation.d.ts.map +1 -0
- package/dist/tools/crawl-documentation.js +103 -0
- package/dist/tools/crawl-documentation.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/save-skill.d.ts +49 -0
- package/dist/tools/save-skill.d.ts.map +1 -0
- package/dist/tools/save-skill.js +207 -0
- package/dist/tools/save-skill.js.map +1 -0
- package/package.json +18 -28
- package/dist/documentation/browser-doc-browser.d.ts +0 -41
- package/dist/documentation/browser-doc-browser.d.ts.map +0 -1
- package/dist/documentation/browser-doc-browser.js +0 -357
- package/dist/documentation/browser-doc-browser.js.map +0 -1
- package/dist/documentation/browser-manager.d.ts +0 -51
- package/dist/documentation/browser-manager.d.ts.map +0 -1
- package/dist/documentation/browser-manager.js +0 -260
- package/dist/documentation/browser-manager.js.map +0 -1
- package/dist/documentation/cache.d.ts +0 -13
- package/dist/documentation/cache.d.ts.map +0 -1
- package/dist/documentation/cache.js +0 -48
- package/dist/documentation/cache.js.map +0 -1
- package/dist/documentation/checkpoint-manager.d.ts +0 -38
- package/dist/documentation/checkpoint-manager.d.ts.map +0 -1
- package/dist/documentation/checkpoint-manager.js +0 -101
- package/dist/documentation/checkpoint-manager.js.map +0 -1
- package/dist/documentation/doc-crawler.d.ts +0 -221
- package/dist/documentation/doc-crawler.d.ts.map +0 -1
- package/dist/documentation/doc-crawler.js +0 -1415
- package/dist/documentation/doc-crawler.js.map +0 -1
- package/dist/documentation/github-client.d.ts +0 -13
- package/dist/documentation/github-client.d.ts.map +0 -1
- package/dist/documentation/github-client.js +0 -90
- package/dist/documentation/github-client.js.map +0 -1
- package/dist/documentation/http-fetcher.d.ts +0 -8
- package/dist/documentation/http-fetcher.d.ts.map +0 -1
- package/dist/documentation/http-fetcher.js +0 -31
- package/dist/documentation/http-fetcher.js.map +0 -1
- package/dist/documentation/index.d.ts +0 -16
- package/dist/documentation/index.d.ts.map +0 -1
- package/dist/documentation/index.js +0 -159
- package/dist/documentation/index.js.map +0 -1
- package/dist/documentation/llms-txt/detector.d.ts +0 -31
- package/dist/documentation/llms-txt/detector.d.ts.map +0 -1
- package/dist/documentation/llms-txt/detector.js +0 -77
- package/dist/documentation/llms-txt/detector.js.map +0 -1
- package/dist/documentation/llms-txt/downloader.d.ts +0 -30
- package/dist/documentation/llms-txt/downloader.d.ts.map +0 -1
- package/dist/documentation/llms-txt/downloader.js +0 -84
- package/dist/documentation/llms-txt/downloader.js.map +0 -1
- package/dist/documentation/llms-txt/index.d.ts +0 -4
- package/dist/documentation/llms-txt/index.d.ts.map +0 -1
- package/dist/documentation/llms-txt/index.js +0 -4
- package/dist/documentation/llms-txt/index.js.map +0 -1
- package/dist/documentation/llms-txt/parser.d.ts +0 -43
- package/dist/documentation/llms-txt/parser.d.ts.map +0 -1
- package/dist/documentation/llms-txt/parser.js +0 -177
- package/dist/documentation/llms-txt/parser.js.map +0 -1
- package/dist/documentation/normalizer.d.ts +0 -6
- package/dist/documentation/normalizer.d.ts.map +0 -1
- package/dist/documentation/normalizer.js +0 -38
- package/dist/documentation/normalizer.js.map +0 -1
- package/dist/documentation/npm-client.d.ts +0 -19
- package/dist/documentation/npm-client.d.ts.map +0 -1
- package/dist/documentation/npm-client.js +0 -182
- package/dist/documentation/npm-client.js.map +0 -1
- package/dist/documentation/skill-generator.d.ts +0 -108
- package/dist/documentation/skill-generator.d.ts.map +0 -1
- package/dist/documentation/skill-generator.js +0 -642
- package/dist/documentation/skill-generator.js.map +0 -1
- package/dist/documentation/web-doc-browser.d.ts +0 -67
- package/dist/documentation/web-doc-browser.d.ts.map +0 -1
- package/dist/documentation/web-doc-browser.js +0 -555
- package/dist/documentation/web-doc-browser.js.map +0 -1
- package/dist/errors/api-validator.d.ts +0 -9
- package/dist/errors/api-validator.d.ts.map +0 -1
- package/dist/errors/api-validator.js +0 -57
- package/dist/errors/api-validator.js.map +0 -1
- package/dist/errors/contextual-analysis.d.ts +0 -14
- package/dist/errors/contextual-analysis.d.ts.map +0 -1
- package/dist/errors/contextual-analysis.js +0 -173
- package/dist/errors/contextual-analysis.js.map +0 -1
- package/dist/errors/cross-file-analyzer.d.ts +0 -16
- package/dist/errors/cross-file-analyzer.d.ts.map +0 -1
- package/dist/errors/cross-file-analyzer.js +0 -172
- package/dist/errors/cross-file-analyzer.js.map +0 -1
- package/dist/errors/eslint-integration.d.ts +0 -9
- package/dist/errors/eslint-integration.d.ts.map +0 -1
- package/dist/errors/eslint-integration.js +0 -131
- package/dist/errors/eslint-integration.js.map +0 -1
- package/dist/errors/framework-detector.d.ts +0 -10
- package/dist/errors/framework-detector.d.ts.map +0 -1
- package/dist/errors/framework-detector.js +0 -126
- package/dist/errors/framework-detector.js.map +0 -1
- package/dist/errors/index.d.ts +0 -18
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js +0 -134
- package/dist/errors/index.js.map +0 -1
- package/dist/errors/pattern-matcher.d.ts +0 -25
- package/dist/errors/pattern-matcher.d.ts.map +0 -1
- package/dist/errors/pattern-matcher.js +0 -44
- package/dist/errors/pattern-matcher.js.map +0 -1
- package/dist/errors/patterns.d.ts +0 -11
- package/dist/errors/patterns.d.ts.map +0 -1
- package/dist/errors/patterns.js +0 -351
- package/dist/errors/patterns.js.map +0 -1
- package/dist/errors/performance-detector.d.ts +0 -11
- package/dist/errors/performance-detector.d.ts.map +0 -1
- package/dist/errors/performance-detector.js +0 -119
- package/dist/errors/performance-detector.js.map +0 -1
- package/dist/errors/runtime-detector.d.ts +0 -7
- package/dist/errors/runtime-detector.d.ts.map +0 -1
- package/dist/errors/runtime-detector.js +0 -86
- package/dist/errors/runtime-detector.js.map +0 -1
- package/dist/errors/security-detector.d.ts +0 -6
- package/dist/errors/security-detector.d.ts.map +0 -1
- package/dist/errors/security-detector.js +0 -75
- package/dist/errors/security-detector.js.map +0 -1
- package/dist/errors/typescript-integration.d.ts +0 -6
- package/dist/errors/typescript-integration.d.ts.map +0 -1
- package/dist/errors/typescript-integration.js +0 -46
- package/dist/errors/typescript-integration.js.map +0 -1
- package/dist/server/mcp-server.d.ts +0 -14
- package/dist/server/mcp-server.d.ts.map +0 -1
- package/dist/server/mcp-server.js +0 -793
- package/dist/server/mcp-server.js.map +0 -1
- package/dist/types/documentation.d.ts +0 -26
- package/dist/types/documentation.d.ts.map +0 -1
- package/dist/types/documentation.js +0 -2
- package/dist/types/documentation.js.map +0 -1
- package/dist/utils/config.d.ts +0 -21
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js +0 -34
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/http-client.d.ts +0 -17
- package/dist/utils/http-client.d.ts.map +0 -1
- package/dist/utils/http-client.js +0 -62
- package/dist/utils/http-client.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -36
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -128
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/rate-limiter.d.ts +0 -9
- package/dist/utils/rate-limiter.d.ts.map +0 -1
- package/dist/utils/rate-limiter.js +0 -26
- package/dist/utils/rate-limiter.js.map +0 -1
- package/dist/validation/auto-fix.d.ts +0 -15
- package/dist/validation/auto-fix.d.ts.map +0 -1
- package/dist/validation/auto-fix.js +0 -49
- package/dist/validation/auto-fix.js.map +0 -1
- package/dist/validation/index.d.ts +0 -21
- package/dist/validation/index.d.ts.map +0 -1
- package/dist/validation/index.js +0 -45
- package/dist/validation/index.js.map +0 -1
- package/dist/validation/resolution-db.d.ts +0 -15
- package/dist/validation/resolution-db.d.ts.map +0 -1
- package/dist/validation/resolution-db.js +0 -62
- package/dist/validation/resolution-db.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,1237 +1,921 @@
|
|
|
1
|
-
# Safe Coder MCP
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
1
|
+
# Safe Coder MCP Server
|
|
2
|
+
|
|
3
|
+
> **Version:** 0.0.27
|
|
4
|
+
> **Status:** Development Preview
|
|
5
|
+
> **Architecture:** MCP Server (orchestration layer)
|
|
6
|
+
|
|
7
|
+
MCP Server for documentation crawling orchestration. Coordinates with `@gulibs/safe-coder-cli` to crawl documentation websites, process content, and provide structured guidance for creating Cursor AI SKILL files.
|
|
8
|
+
|
|
9
|
+
## ⚠️ Current Version Status
|
|
10
|
+
|
|
11
|
+
**Version 0.0.27 - Development Preview:**
|
|
12
|
+
- ✅ Architecture refactored: Clean separation between MCP Server and CLI
|
|
13
|
+
- ✅ Core functionality: Crawling orchestration, content processing, SKILL guidance
|
|
14
|
+
- ✅ **NEW: `save_skill` tool** - Automatic SKILL file creation with complete directory structure
|
|
15
|
+
- ⚠️ **Not published to npm** - requires manual installation from source
|
|
16
|
+
|
|
17
|
+
## What This Package Does
|
|
18
|
+
|
|
19
|
+
**Safe Coder MCP Server is an orchestration layer** that:
|
|
20
|
+
|
|
21
|
+
1. ✅ **Checks dependencies** - Verifies `safe-coder-cli` is installed
|
|
22
|
+
2. ✅ **Spawns CLI process** - Executes crawling via child process
|
|
23
|
+
3. ✅ **Parses CLI output** - Reads JSON from stdout, progress from stderr
|
|
24
|
+
4. ✅ **Processes content** - Extracts key points, code patterns, topics
|
|
25
|
+
5. ✅ **Generates guidance** - Creates structured SKILL generation recommendations
|
|
26
|
+
6. ✅ **Manages cache** - Stores results for 7 days in `~/.safe-coder/cache/`
|
|
27
|
+
7. ✅ **Saves SKILL files** - Creates complete directory structure (SKILL.md + references/)
|
|
28
|
+
8. ✅ **Exposes MCP tools** - Provides 4 tools to Cursor AI
|
|
29
|
+
|
|
30
|
+
**This package does NOT:**
|
|
31
|
+
- ❌ Perform web crawling (delegated to CLI)
|
|
32
|
+
- ❌ Run browser automation (CLI responsibility)
|
|
33
|
+
|
|
34
|
+
## Architecture
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
38
|
+
│ Cursor / Claude Desktop (MCP Client) │
|
|
39
|
+
│ • Calls MCP tools │
|
|
40
|
+
│ • Receives data + guidance │
|
|
41
|
+
│ • Creates SKILL.md based on guidance │
|
|
42
|
+
└────────────────┬────────────────────────────────────────────┘
|
|
43
|
+
│ MCP Protocol (JSON-RPC over stdio)
|
|
44
|
+
┌────────────────▼────────────────────────────────────────────┐
|
|
45
|
+
│ @gulibs/safe-coder (MCP Server) - THIS PACKAGE │
|
|
46
|
+
│ ┌──────────────────────────────────────────────────────┐ │
|
|
47
|
+
│ │ 1. Dependency Check (which safe-coder-cli) │ │
|
|
48
|
+
│ │ 2. CLI Executor (spawn child process) │ │
|
|
49
|
+
│ │ 3. Parse JSON Output (stdout → data) │ │
|
|
50
|
+
│ │ 4. Content Processor (extract key info) │ │
|
|
51
|
+
│ │ 5. Guide Generator (create SKILL guidance) │ │
|
|
52
|
+
│ │ 6. Cache Manager (store/retrieve results) │ │
|
|
53
|
+
│ └──────────────────────────────────────────────────────┘ │
|
|
54
|
+
│ │
|
|
55
|
+
│ Tools: crawl_documentation, save_skill, │
|
|
56
|
+
│ list_cached_documentation, clear_cache │
|
|
57
|
+
└────────────────┬────────────────────────────────────────────┘
|
|
58
|
+
│ spawn('safe-coder-cli', ['crawl', url, ...])
|
|
59
|
+
│ stdin: commands, stdout: JSON, stderr: progress
|
|
60
|
+
┌────────────────▼────────────────────────────────────────────┐
|
|
61
|
+
│ @gulibs/safe-coder-cli (Standalone CLI Tool) │
|
|
62
|
+
│ • HTTP + Browser-based web crawling │
|
|
63
|
+
│ • Content extraction and markup conversion │
|
|
64
|
+
│ • JSON output to stdout (results) │
|
|
65
|
+
│ • JSON output to stderr (progress messages) │
|
|
66
|
+
└────────────────┬────────────────────────────────────────────┘
|
|
67
|
+
│ HTTP requests / Puppeteer / Playwright
|
|
68
|
+
┌────────────────▼────────────────────────────────────────────┐
|
|
69
|
+
│ Documentation Website (e.g., react.dev, vuejs.org) │
|
|
70
|
+
└─────────────────────────────────────────────────────────────┘
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Installation
|
|
74
|
+
|
|
75
|
+
### Step 1: Prerequisites
|
|
76
|
+
|
|
77
|
+
**Node.js 18+**
|
|
73
78
|
```bash
|
|
74
|
-
#
|
|
75
|
-
npm install -g @gulibs/safe-coder
|
|
76
|
-
|
|
77
|
-
# 或者本地安装到项目
|
|
78
|
-
npm install @gulibs/safe-coder
|
|
79
|
+
node --version # Must be v18.0.0 or higher
|
|
79
80
|
```
|
|
80
81
|
|
|
81
|
-
###
|
|
82
|
+
### Step 2: Install CLI Tool (Required)
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
# 克隆或下载项目
|
|
85
|
-
git clone <repository-url>
|
|
86
|
-
cd safe-coder
|
|
87
|
-
|
|
88
|
-
# 安装依赖
|
|
89
|
-
npm install
|
|
90
|
-
|
|
91
|
-
# 构建项目
|
|
92
|
-
npm run build
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## 配置
|
|
96
|
-
|
|
97
|
-
设置环境变量(可选):
|
|
98
|
-
|
|
99
|
-
- `CACHE_TTL_MINUTES` - 文档缓存 TTL(分钟),默认:60
|
|
100
|
-
- `GITHUB_TOKEN` - GitHub API token(用于访问私有仓库,可选)
|
|
101
|
-
- `ENABLE_AUTO_FIX` - 启用自动修复,默认:true
|
|
102
|
-
- `RATE_LIMIT_REQUESTS` - 每个窗口的最大请求数,默认:100
|
|
103
|
-
- `RATE_LIMIT_WINDOW_MS` - 速率限制窗口(毫秒),默认:60000
|
|
104
|
-
- `LOG_LEVEL` - 日志级别:`DEBUG`、`INFO`、`WARN`、`ERROR`,默认:`INFO`
|
|
105
|
-
- `LOG_COLORS` - 启用彩色日志输出,默认:`true`(设置为 `false` 禁用)
|
|
106
|
-
|
|
107
|
-
### 代理配置(适用于国内网络环境)
|
|
108
|
-
|
|
109
|
-
如果无法直接访问 npm registry 或 GitHub API,可以配置代理:
|
|
110
|
-
|
|
111
|
-
- `HTTP_PROXY` 或 `http_proxy` - HTTP 代理地址,例如:`http://127.0.0.1:7890`
|
|
112
|
-
- `HTTPS_PROXY` 或 `https_proxy` - HTTPS 代理地址,例如:`http://127.0.0.1:7890`
|
|
113
|
-
- `NO_PROXY` 或 `no_proxy` - 不使用代理的地址列表(逗号分隔),例如:`localhost,127.0.0.1`
|
|
114
|
-
|
|
115
|
-
**示例配置:**
|
|
84
|
+
⚠️ **The MCP server requires `@gulibs/safe-coder-cli` to be globally installed.**
|
|
116
85
|
|
|
86
|
+
**Option A: From npm (after publication)**
|
|
117
87
|
```bash
|
|
118
|
-
|
|
119
|
-
export HTTP_PROXY=http://127.0.0.1:7890
|
|
120
|
-
export HTTPS_PROXY=http://127.0.0.1:7890
|
|
121
|
-
|
|
122
|
-
# 或者使用 SOCKS5 代理(如果代理支持)
|
|
123
|
-
export HTTP_PROXY=socks5://127.0.0.1:1080
|
|
124
|
-
export HTTPS_PROXY=socks5://127.0.0.1:1080
|
|
125
|
-
|
|
126
|
-
# 排除本地地址
|
|
127
|
-
export NO_PROXY=localhost,127.0.0.1,*.local
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
**在 Cursor 配置文件中设置:**
|
|
131
|
-
|
|
132
|
-
```json
|
|
133
|
-
{
|
|
134
|
-
"mcpServers": {
|
|
135
|
-
"safe-coder": {
|
|
136
|
-
"command": "npx",
|
|
137
|
-
"args": ["-y", "@gulibs/safe-coder"],
|
|
138
|
-
"env": {
|
|
139
|
-
"HTTP_PROXY": "http://127.0.0.1:7890",
|
|
140
|
-
"HTTPS_PROXY": "http://127.0.0.1:7890",
|
|
141
|
-
"NO_PROXY": "localhost,127.0.0.1"
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
88
|
+
npm install -g @gulibs/safe-coder-cli
|
|
146
89
|
```
|
|
147
90
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
### 1. 运行服务器
|
|
151
|
-
|
|
91
|
+
**Option B: From source (current development setup)**
|
|
152
92
|
```bash
|
|
153
|
-
#
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
# 生产模式(需要先构建)
|
|
93
|
+
# Clone and build CLI
|
|
94
|
+
cd /path/to/safe-coder-cli
|
|
95
|
+
npm install
|
|
157
96
|
npm run build
|
|
158
|
-
npm
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
服务器通过 stdio 运行,使用 MCP 协议进行通信。
|
|
162
|
-
|
|
163
|
-
### 2. 监控服务状态
|
|
164
|
-
|
|
165
|
-
#### 查看日志
|
|
97
|
+
npm link # Makes 'safe-coder-cli' available globally
|
|
166
98
|
|
|
167
|
-
|
|
168
|
-
-
|
|
169
|
-
|
|
170
|
-
- 错误和警告信息
|
|
171
|
-
|
|
172
|
-
**日志格式示例:**
|
|
173
|
-
|
|
174
|
-
```
|
|
175
|
-
[2024-01-01T12:00:00.000Z] [INFO] Safe Coder MCP server started {"version":"1.0.0","pid":12345}
|
|
176
|
-
[2024-01-01T12:00:00.100Z] [INFO] MCP server connected to transport
|
|
177
|
-
[2024-01-01T12:00:00.200Z] [INFO] Tool invoked: get_documentation {"requestId":"req-1234567890-1","tool":"get_documentation","params":{"packageName":"react"}}
|
|
178
|
-
[2024-01-01T12:00:00.500Z] [INFO] Tool completed: get_documentation {"requestId":"req-1234567890-1","tool":"get_documentation","duration":"500ms","success":true}
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
**日志级别(通过 `LOG_LEVEL` 环境变量设置):**
|
|
182
|
-
- `DEBUG` - 详细调试信息
|
|
183
|
-
- `INFO` - 一般信息(工具调用、完成)默认
|
|
184
|
-
- `WARN` - 警告信息
|
|
185
|
-
- `ERROR` - 错误信息
|
|
186
|
-
|
|
187
|
-
#### 使用 get_status 工具
|
|
188
|
-
|
|
189
|
-
在 Cursor 中,你可以调用 `get_status` 工具来查看服务器状态:
|
|
190
|
-
|
|
191
|
-
```json
|
|
192
|
-
{
|
|
193
|
-
"status": "running",
|
|
194
|
-
"uptime": 3600,
|
|
195
|
-
"version": "1.0.0",
|
|
196
|
-
"tools": ["get_documentation", "detect_errors", "validate_code", "resolve_error", "get_status"],
|
|
197
|
-
"cacheSize": 10,
|
|
198
|
-
"pid": 12345
|
|
199
|
-
}
|
|
99
|
+
# Verify
|
|
100
|
+
safe-coder-cli --version
|
|
101
|
+
# Output: 0.0.1
|
|
200
102
|
```
|
|
201
103
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
1. **打开 Cursor 的开发者工具**:
|
|
205
|
-
- macOS: `Cmd + Shift + P` → "Developer: Toggle Developer Tools"
|
|
206
|
-
- Windows/Linux: `Ctrl + Shift + P` → "Developer: Toggle Developer Tools"
|
|
207
|
-
|
|
208
|
-
2. **查看控制台**:
|
|
209
|
-
- 在开发者工具中切换到 "Console" 标签
|
|
210
|
-
- MCP 服务器的日志会显示在这里
|
|
211
|
-
|
|
212
|
-
3. **启用调试模式**:
|
|
213
|
-
|
|
214
|
-
在 Cursor 配置中添加:
|
|
215
|
-
|
|
216
|
-
```json
|
|
217
|
-
{
|
|
218
|
-
"mcpServers": {
|
|
219
|
-
"safe-coder": {
|
|
220
|
-
"command": "npx",
|
|
221
|
-
"args": ["-y", "@gulibs/safe-coder"],
|
|
222
|
-
"env": {
|
|
223
|
-
"LOG_LEVEL": "DEBUG",
|
|
224
|
-
"LOG_COLORS": "true"
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### 3. 在 Cursor 中配置
|
|
232
|
-
|
|
233
|
-
> **⚠️ 重要提示**:如果包还没有发布到 npm,请使用"本地开发配置"方式。
|
|
234
|
-
|
|
235
|
-
#### 步骤 1:找到 Cursor 配置文件
|
|
236
|
-
|
|
237
|
-
Cursor 的 MCP 配置文件位置:
|
|
238
|
-
- **macOS**: `~/Library/Application Support/Cursor/User/globalStorage/mcp.json`
|
|
239
|
-
- **Windows**: `%APPDATA%\Cursor\User\globalStorage\mcp.json`
|
|
240
|
-
- **Linux**: `~/.config/Cursor/User/globalStorage/mcp.json`
|
|
241
|
-
|
|
242
|
-
或者通过 Cursor 设置界面:
|
|
243
|
-
1. 打开 Cursor 设置(`Cmd/Ctrl + ,`)
|
|
244
|
-
2. 搜索 "MCP" 或 "Model Context Protocol"
|
|
245
|
-
3. 找到 MCP 服务器配置
|
|
246
|
-
|
|
247
|
-
#### 步骤 2:添加配置
|
|
104
|
+
### Step 3: Install MCP Server
|
|
248
105
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
##### 方式 A:本地开发配置(推荐,如果包未发布)
|
|
252
|
-
|
|
253
|
-
使用项目的绝对路径:
|
|
254
|
-
|
|
255
|
-
```json
|
|
256
|
-
{
|
|
257
|
-
"mcpServers": {
|
|
258
|
-
"safe-coder": {
|
|
259
|
-
"command": "node",
|
|
260
|
-
"args": ["/Users/wormhole/Documents/Developments/Our/mcp/safe-coder/dist/index.js"],
|
|
261
|
-
"env": {
|
|
262
|
-
"CACHE_TTL_MINUTES": "60",
|
|
263
|
-
"GITHUB_TOKEN": "your_token_here"
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
**获取你的项目路径:**
|
|
106
|
+
⚠️ **Not yet published to npm - use local installation:**
|
|
271
107
|
|
|
108
|
+
**Development Installation:**
|
|
272
109
|
```bash
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
##### 方式 B:通过 npm 安装(需要先发布到 npm)
|
|
278
|
-
|
|
279
|
-
如果包已发布到 npm,可以使用 npx:
|
|
110
|
+
cd /path/to/safe-coder
|
|
111
|
+
npm install
|
|
112
|
+
npm run build
|
|
280
113
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
"mcpServers": {
|
|
284
|
-
"safe-coder": {
|
|
285
|
-
"command": "npx",
|
|
286
|
-
"args": ["-y", "@gulibs/safe-coder"],
|
|
287
|
-
"env": {
|
|
288
|
-
"CACHE_TTL_MINUTES": "60",
|
|
289
|
-
"GITHUB_TOKEN": "your_token_here"
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
114
|
+
# Optional: Link for global access
|
|
115
|
+
npm link
|
|
294
116
|
```
|
|
295
117
|
|
|
296
|
-
|
|
118
|
+
### Step 4: Configure Cursor
|
|
297
119
|
|
|
298
|
-
|
|
299
|
-
# 全局安装
|
|
300
|
-
npm install -g @gulibs/safe-coder
|
|
301
|
-
|
|
302
|
-
# 查看全局安装路径
|
|
303
|
-
npm root -g
|
|
304
|
-
```
|
|
120
|
+
**Edit Cursor MCP configuration:**
|
|
305
121
|
|
|
306
|
-
|
|
122
|
+
File location: `~/Library/Application Support/Cursor/User/globalStorage/mcp.json`
|
|
307
123
|
|
|
308
124
|
```json
|
|
309
125
|
{
|
|
310
126
|
"mcpServers": {
|
|
311
127
|
"safe-coder": {
|
|
312
128
|
"command": "node",
|
|
313
|
-
"args": ["
|
|
314
|
-
"env": {
|
|
315
|
-
"CACHE_TTL_MINUTES": "60",
|
|
316
|
-
"GITHUB_TOKEN": "your_token_here"
|
|
317
|
-
}
|
|
129
|
+
"args": ["/absolute/path/to/safe-coder/dist/index.js"]
|
|
318
130
|
}
|
|
319
131
|
}
|
|
320
132
|
}
|
|
321
133
|
```
|
|
322
134
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
找到你安装的路径,然后配置:
|
|
326
|
-
|
|
135
|
+
**Replace `/absolute/path/to/safe-coder`** with actual path, e.g.:
|
|
327
136
|
```json
|
|
328
137
|
{
|
|
329
138
|
"mcpServers": {
|
|
330
139
|
"safe-coder": {
|
|
331
140
|
"command": "node",
|
|
332
|
-
"args": ["
|
|
333
|
-
"env": {
|
|
334
|
-
"CACHE_TTL_MINUTES": "60",
|
|
335
|
-
"GITHUB_TOKEN": "your_token_here"
|
|
336
|
-
}
|
|
141
|
+
"args": ["/Users/yourname/projects/mcp/safe-coder/dist/index.js"]
|
|
337
142
|
}
|
|
338
143
|
}
|
|
339
144
|
}
|
|
340
145
|
```
|
|
341
146
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
在项目目录下运行:
|
|
345
|
-
|
|
346
|
-
```bash
|
|
347
|
-
# macOS/Linux
|
|
348
|
-
pwd
|
|
349
|
-
|
|
350
|
-
# Windows PowerShell
|
|
351
|
-
(Get-Location).Path
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
##### 如果使用本地项目安装(node_modules):
|
|
355
|
-
|
|
147
|
+
**Future (after npm publication):**
|
|
356
148
|
```json
|
|
357
149
|
{
|
|
358
150
|
"mcpServers": {
|
|
359
151
|
"safe-coder": {
|
|
360
|
-
"command": "
|
|
361
|
-
"args": ["
|
|
362
|
-
"env": {
|
|
363
|
-
"CACHE_TTL_MINUTES": "60",
|
|
364
|
-
"GITHUB_TOKEN": "your_token_here"
|
|
365
|
-
}
|
|
152
|
+
"command": "npx",
|
|
153
|
+
"args": ["-y", "@gulibs/safe-coder@latest"]
|
|
366
154
|
}
|
|
367
155
|
}
|
|
368
156
|
}
|
|
369
157
|
```
|
|
370
158
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
1. **检查配置文件格式**:确保 JSON 格式正确,可以使用在线 JSON 验证器
|
|
374
|
-
2. **重启 Cursor**:保存配置后,完全重启 Cursor
|
|
375
|
-
3. **检查连接状态**:
|
|
376
|
-
- 在 Cursor 设置中查看 MCP 服务器列表
|
|
377
|
-
- 应该能看到 "safe-coder" 服务器
|
|
378
|
-
- 状态应该显示为已连接(绿色)
|
|
159
|
+
### Step 5: Restart Cursor
|
|
379
160
|
|
|
380
|
-
|
|
161
|
+
Restart Cursor to load the MCP server.
|
|
381
162
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
```
|
|
385
|
-
请使用 get_documentation 工具获取 axios 库的文档
|
|
386
|
-
```
|
|
163
|
+
## Usage: SKILL File Generation Workflow
|
|
387
164
|
|
|
388
|
-
|
|
165
|
+
### ⚠️ Important: How SKILL Files Are Created
|
|
389
166
|
|
|
390
|
-
|
|
167
|
+
**The MCP server does NOT create `SKILL.md` files directly.** Here's the actual workflow:
|
|
391
168
|
|
|
392
|
-
|
|
169
|
+
#### What the MCP Server Returns
|
|
393
170
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
4. `detect_spa` - 检测单页应用
|
|
399
|
-
5. `detect_errors` - 检测代码错误
|
|
400
|
-
6. `validate_code` - 验证代码
|
|
401
|
-
7. `resolve_error` - 解决错误
|
|
402
|
-
8. `get_status` - 获取服务器状态
|
|
403
|
-
9. `get_version` - 获取版本号
|
|
171
|
+
1. **Crawled content** - Full text from all pages
|
|
172
|
+
2. **Processed data** - Key points, code patterns, categories, topics
|
|
173
|
+
3. **SKILL generation guide** - Structured recommendations for SKILL.md
|
|
174
|
+
4. **Quality assessment** - Scores for content quality, completeness
|
|
404
175
|
|
|
405
|
-
####
|
|
176
|
+
#### Where SKILL Files Are Saved
|
|
406
177
|
|
|
407
|
-
|
|
178
|
+
**You must explicitly tell Cursor AI where to save the file:**
|
|
408
179
|
|
|
409
|
-
**参数:**
|
|
410
|
-
- `packageName`(必需):包名(npm)、仓库(owner/repo)或 URL
|
|
411
|
-
- `version`(可选):版本或分支 / 标签
|
|
412
|
-
- `source`(可选):源类型('npm'、'github'、'http')- 如果不指定会自动检测
|
|
413
|
-
|
|
414
|
-
**使用示例:**
|
|
415
|
-
|
|
416
|
-
```
|
|
417
|
-
请帮我获取 axios 库的文档
|
|
418
180
|
```
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
"source": "npm"
|
|
427
|
-
}
|
|
181
|
+
User: "Crawl React docs and create a SKILL file"
|
|
182
|
+
↓
|
|
183
|
+
Cursor AI: [Calls crawl_documentation, receives data + guidance]
|
|
184
|
+
↓
|
|
185
|
+
User: "Save it to ~/.claude/skills/react-docs/SKILL.md"
|
|
186
|
+
↓
|
|
187
|
+
Cursor AI: [Creates file at specified location]
|
|
428
188
|
```
|
|
429
189
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
浏览和搜索网页文档页面。
|
|
433
|
-
|
|
434
|
-
**参数:**
|
|
435
|
-
- `url`(必需):文档 URL
|
|
436
|
-
- `query`(可选):搜索查询词,用于过滤内容
|
|
437
|
-
- `navigateTo`(可选):导航到文档内的其他页面
|
|
438
|
-
|
|
439
|
-
**使用示例:**
|
|
440
|
-
|
|
190
|
+
**Recommended location pattern:**
|
|
441
191
|
```
|
|
442
|
-
|
|
192
|
+
~/.claude/skills/
|
|
193
|
+
├── react-docs/SKILL.md # React documentation
|
|
194
|
+
├── vue-guide/SKILL.md # Vue.js guide
|
|
195
|
+
├── typescript-handbook/SKILL.md # TypeScript handbook
|
|
196
|
+
└── [tech-name]/SKILL.md # Generic pattern
|
|
443
197
|
```
|
|
444
198
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
199
|
+
**Naming conventions:**
|
|
200
|
+
- Directory: `[technology-name]` (lowercase, hyphens)
|
|
201
|
+
- File: Always `SKILL.md` (Cursor convention)
|
|
202
|
+
- Examples: `react-docs`, `vue-guide`, `next-js-docs`
|
|
448
203
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
递归爬取文档网站,提取内容并生成结构化的 Agent Skill。
|
|
452
|
-
|
|
453
|
-
**基础参数:**
|
|
454
|
-
- `url`(必需):文档根 URL
|
|
455
|
-
- `maxDepth`(可选):最大爬取深度(默认:3)
|
|
456
|
-
- `maxPages`(可选):最大页面数(默认:50)
|
|
457
|
-
- `includePaths`(可选):额外包含的路径模式
|
|
458
|
-
- `excludePaths`(可选):排除的路径模式
|
|
459
|
-
- `rateLimit`(可选):请求间隔(毫秒,默认:500)
|
|
460
|
-
- `maxRetries`(可选):失败请求的最大重试次数(默认:2)
|
|
461
|
-
- `retryDelay`(可选):重试前的延迟(毫秒,默认:1000)
|
|
462
|
-
- `outputDir`(可选):保存技能文件的目录(如果不提供,只返回内容)
|
|
463
|
-
- `filename`(可选):自定义文件名(不含扩展名)
|
|
464
|
-
|
|
465
|
-
**🌟 增强参数(新增):**
|
|
466
|
-
- `crawlStrategy`(可选):爬取策略 `'bfs'` | `'dfs'`(默认:bfs)
|
|
467
|
-
- **BFS**(广度优先):逐层爬取,适合全面覆盖
|
|
468
|
-
- **DFS**(深度优先):深入一条路径,适合深度理解
|
|
469
|
-
- `workers`(可选):并发worker数量 1-10(默认:1)
|
|
470
|
-
- 建议:小型站点2-3个,大型站点5-8个
|
|
471
|
-
- 性能提升:3 workers ≈ 3倍,5 workers ≈ 4-5倍
|
|
472
|
-
- `skipLlmsTxt`(可选):是否跳过llms.txt检测(默认:false)
|
|
473
|
-
- 启用时自动检测和使用llms.txt,效率提升2-3倍
|
|
474
|
-
- `checkpoint`(可选):断点续传配置
|
|
475
|
-
- `enabled`:是否启用断点功能
|
|
476
|
-
- `interval`:每N页保存一次(默认:10)
|
|
477
|
-
- `file`:checkpoint文件路径(可选)
|
|
478
|
-
- `resume`(可选):是否从上次断点恢复(默认:false)
|
|
479
|
-
|
|
480
|
-
**基础功能:**
|
|
481
|
-
- ✅ **SPA 检测**:自动检测单页应用(SPA)并提供建议
|
|
482
|
-
- ✅ **智能重试**:对临时错误(超时、网络错误等)自动重试
|
|
483
|
-
- ✅ **错误分类**:详细的错误类型分类和统计
|
|
484
|
-
- ✅ **进度日志**:实时显示爬取进度和统计信息
|
|
485
|
-
|
|
486
|
-
**🎯 使用示例:**
|
|
487
|
-
|
|
488
|
-
##### 1. 快速基础爬取
|
|
489
|
-
```
|
|
490
|
-
爬取 https://react.dev/docs 的文档并生成技能
|
|
491
|
-
```
|
|
204
|
+
### Complete Example Workflow
|
|
492
205
|
|
|
493
|
-
|
|
206
|
+
**1. Request crawl:**
|
|
494
207
|
```
|
|
495
|
-
|
|
208
|
+
User: "Crawl the React documentation at https://react.dev and create a SKILL file"
|
|
496
209
|
```
|
|
497
210
|
|
|
498
|
-
|
|
499
|
-
```
|
|
500
|
-
{
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
```
|
|
507
|
-
|
|
508
|
-
##### 3. 深度优先策略
|
|
509
|
-
```
|
|
510
|
-
使用 DFS 策略爬取 https://docs.example.com,深度限制为 6
|
|
511
|
-
```
|
|
512
|
-
|
|
513
|
-
对应参数:
|
|
514
|
-
```json
|
|
515
|
-
{
|
|
516
|
-
"url": "https://docs.example.com",
|
|
517
|
-
"crawlStrategy": "dfs",
|
|
518
|
-
"maxDepth": 6,
|
|
519
|
-
"workers": 3
|
|
520
|
-
}
|
|
211
|
+
**2. Cursor AI calls MCP tool:**
|
|
212
|
+
```typescript
|
|
213
|
+
crawl_documentation({
|
|
214
|
+
url: "https://react.dev",
|
|
215
|
+
maxPages: 200, // Default
|
|
216
|
+
depth: 3 // Default
|
|
217
|
+
})
|
|
521
218
|
```
|
|
522
219
|
|
|
523
|
-
|
|
220
|
+
**3. MCP Server process:**
|
|
524
221
|
```
|
|
525
|
-
|
|
222
|
+
[Dependency Check] ✓ safe-coder-cli found at /usr/local/bin/safe-coder-cli
|
|
223
|
+
[Spawning CLI] safe-coder-cli crawl https://react.dev --output-format json ...
|
|
224
|
+
[Progress] Crawling... 10/50 pages
|
|
225
|
+
[Progress] Crawling... 25/50 pages
|
|
226
|
+
[Progress] Crawling... 50/50 pages complete
|
|
227
|
+
[Processing] Analyzing content...
|
|
228
|
+
[Processing] Generating SKILL guidance...
|
|
229
|
+
[Cache] Saving to ~/.safe-coder/cache/aHR0cHM6Ly9yZWFjdC5kZXY=.json
|
|
230
|
+
[Complete] Ready to return
|
|
526
231
|
```
|
|
527
232
|
|
|
528
|
-
|
|
233
|
+
**4. MCP returns to Cursor:**
|
|
529
234
|
```json
|
|
530
235
|
{
|
|
531
|
-
"
|
|
532
|
-
"
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
236
|
+
"success": true,
|
|
237
|
+
"data": {
|
|
238
|
+
"source": {
|
|
239
|
+
"url": "https://react.dev",
|
|
240
|
+
"crawledAt": "2026-01-15T14:30:00Z",
|
|
241
|
+
"pageCount": 50,
|
|
242
|
+
"depth": 3
|
|
243
|
+
},
|
|
244
|
+
"pages": [
|
|
245
|
+
{
|
|
246
|
+
"url": "https://react.dev/learn",
|
|
247
|
+
"title": "Quick Start",
|
|
248
|
+
"content": "Welcome to React...",
|
|
249
|
+
"keyPoints": [
|
|
250
|
+
"React is a JavaScript library",
|
|
251
|
+
"Components are building blocks",
|
|
252
|
+
"...more..."
|
|
253
|
+
],
|
|
254
|
+
"codePatterns": [
|
|
255
|
+
{
|
|
256
|
+
"language": "jsx",
|
|
257
|
+
"pattern": "function Component() { return <div>...</div> }",
|
|
258
|
+
"description": "Functional component syntax"
|
|
259
|
+
}
|
|
260
|
+
],
|
|
261
|
+
"wordCount": 1500,
|
|
262
|
+
"codeBlocks": 12
|
|
263
|
+
}
|
|
264
|
+
// ... 49 more pages
|
|
265
|
+
],
|
|
266
|
+
"analysis": {
|
|
267
|
+
"mainTopics": ["Components", "Hooks", "State", "Props", "Effects"],
|
|
268
|
+
"difficulty": "intermediate",
|
|
269
|
+
"technicalDensity": 0.65
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
"skillGenerationGuide": {
|
|
273
|
+
"suggestedStructure": [
|
|
274
|
+
"Overview",
|
|
275
|
+
"Quick Start",
|
|
276
|
+
"Core Concepts",
|
|
277
|
+
"Hooks Reference",
|
|
278
|
+
"Best Practices",
|
|
279
|
+
"Common Patterns",
|
|
280
|
+
"Troubleshooting"
|
|
281
|
+
],
|
|
282
|
+
"keyTopics": [
|
|
283
|
+
"JSX Syntax",
|
|
284
|
+
"Components (Functional & Class)",
|
|
285
|
+
"Props and State",
|
|
286
|
+
"Hooks (useState, useEffect, useContext, etc.)",
|
|
287
|
+
"Event Handling",
|
|
288
|
+
"Conditional Rendering",
|
|
289
|
+
"Lists and Keys"
|
|
290
|
+
],
|
|
291
|
+
"recommendedSections": {
|
|
292
|
+
"overview": "React is a JavaScript library for building user interfaces...",
|
|
293
|
+
"quickStart": [
|
|
294
|
+
"Install: npx create-react-app my-app",
|
|
295
|
+
"Create first component",
|
|
296
|
+
"Understand JSX"
|
|
297
|
+
],
|
|
298
|
+
"coreFeatures": [
|
|
299
|
+
"Component-based architecture",
|
|
300
|
+
"Virtual DOM",
|
|
301
|
+
"One-way data flow",
|
|
302
|
+
"Declarative UI"
|
|
303
|
+
],
|
|
304
|
+
"bestPractices": [
|
|
305
|
+
"Use functional components with Hooks",
|
|
306
|
+
"Keep components small and focused",
|
|
307
|
+
"Lift state up when needed"
|
|
308
|
+
]
|
|
309
|
+
},
|
|
310
|
+
"tips": [
|
|
311
|
+
"Focus on the Hooks API (modern approach)",
|
|
312
|
+
"Include examples for common Hooks",
|
|
313
|
+
"Explain component lifecycle clearly",
|
|
314
|
+
"Cover both client and server rendering"
|
|
315
|
+
],
|
|
316
|
+
"quality": {
|
|
317
|
+
"contentQuality": 90,
|
|
318
|
+
"codeExamples": 85,
|
|
319
|
+
"completeness": 88,
|
|
320
|
+
"overall": 87
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
"fromCache": false,
|
|
324
|
+
"message": "Successfully crawled 50 pages. Quality score: 87/100"
|
|
538
325
|
}
|
|
539
326
|
```
|
|
540
327
|
|
|
541
|
-
|
|
328
|
+
**5. Tell Cursor where to save:**
|
|
542
329
|
```
|
|
543
|
-
|
|
330
|
+
User: "Save this as a SKILL file at ~/.claude/skills/react-docs/SKILL.md"
|
|
544
331
|
```
|
|
545
332
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
"checkpoint": { "enabled": true }
|
|
552
|
-
}
|
|
553
|
-
```
|
|
333
|
+
**6. Cursor AI generates and saves:**
|
|
334
|
+
- Uses `data.pages` for content
|
|
335
|
+
- Uses `skillGenerationGuide` for structure
|
|
336
|
+
- Creates formatted `SKILL.md`
|
|
337
|
+
- Saves to specified location
|
|
554
338
|
|
|
555
|
-
|
|
339
|
+
## MCP Tools Reference
|
|
556
340
|
|
|
557
|
-
|
|
558
|
-
|---------|---------|-------------------|------|
|
|
559
|
-
| 50页 | ~90秒 | ~22秒 | **4倍** ⚡ |
|
|
560
|
-
| 100页 | ~180秒 | ~45秒 | **4倍** ⚡ |
|
|
561
|
-
| 200页 | ~360秒 | ~80秒 | **4.5倍** ⚡ |
|
|
341
|
+
### Tool 1: `crawl_documentation`
|
|
562
342
|
|
|
563
|
-
|
|
564
|
-
- `skillContent`: Markdown 格式的技能内容
|
|
565
|
-
- `metadata`: 技能元数据(标题、描述、源 URL 等)
|
|
566
|
-
- `crawlStats`: 爬取统计(总页数、最大深度、错误列表、质量指标)
|
|
567
|
-
- `files`(可选):保存的文件路径
|
|
568
|
-
- `skillFile`: SKILL.md 文件路径
|
|
569
|
-
- `manifestFile`: metadata.json 文件路径
|
|
343
|
+
(**Recommended Workflow**: Use with `save_skill` for complete automation)
|
|
570
344
|
|
|
571
|
-
|
|
572
|
-
1. **先小规模测试**:maxPages设为10-20验证效果
|
|
573
|
-
2. **逐步增加并发**:从workers=2开始,观察效果
|
|
574
|
-
3. **大规模使用断点**:超过200页建议启用checkpoint
|
|
575
|
-
4. **关注质量指标**:diversity和coverage应 > 0.5
|
|
345
|
+
Crawl documentation website and return processed data with SKILL generation guidance.
|
|
576
346
|
|
|
577
|
-
|
|
347
|
+
**Parameters:**
|
|
578
348
|
|
|
579
|
-
|
|
349
|
+
| Parameter | Type | Required | Default | Description |
|
|
350
|
+
|-----------|------|----------|---------|-------------|
|
|
351
|
+
| `url` | `string` | ✅ Yes | - | Documentation URL to crawl |
|
|
352
|
+
| `maxPages` | `number` | No | `200` | Maximum pages to crawl |
|
|
353
|
+
| `depth` | `number` | No | `3` | Maximum crawl depth |
|
|
354
|
+
| `workers` | `number` | No | `1` | Number of parallel workers |
|
|
355
|
+
| `useBrowser` | `boolean` | No | `false` | Force browser automation |
|
|
356
|
+
| `browser` | `'puppeteer'` \| `'playwright'` | No | `'puppeteer'` | Browser type |
|
|
357
|
+
| `spaStrategy` | `'smart'` \| `'auto'` \| `'manual'` | No | `'smart'` | SPA detection |
|
|
358
|
+
| `useCache` | `boolean` | No | `true` | Use cached results |
|
|
359
|
+
| `forceRefresh` | `boolean` | No | `false` | Bypass cache |
|
|
580
360
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
361
|
+
**⚠️ Parameters NOT Currently Exposed (CLI supports, MCP doesn't):**
|
|
362
|
+
- `strategy` (bfs/dfs) - Crawl strategy
|
|
363
|
+
- `checkpoint`, `resume` - Checkpoint/resume functionality
|
|
364
|
+
- `rateLimit`, `maxRetries`, `retryDelay` - Rate limiting and retry control
|
|
365
|
+
- `includePaths`, `excludePaths` - URL path filtering
|
|
366
|
+
- `skipLlmsTxt` - llms.txt detection control
|
|
585
367
|
|
|
586
|
-
|
|
368
|
+
**Returns:**
|
|
587
369
|
```typescript
|
|
588
370
|
{
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
371
|
+
success: boolean;
|
|
372
|
+
data: {
|
|
373
|
+
source: { url, crawledAt, pageCount, depth };
|
|
374
|
+
pages: Array<{
|
|
375
|
+
url, title, content, keyPoints, codePatterns,
|
|
376
|
+
category, wordCount, codeBlocks, headings
|
|
377
|
+
}>;
|
|
378
|
+
metadata: { technology, version, documentType, categories };
|
|
379
|
+
statistics: { totalPages, maxDepthReached, errors, linkDiscovery };
|
|
380
|
+
analysis: {
|
|
381
|
+
totalWords, totalCodeBlocks, categories,
|
|
382
|
+
mainTopics, technicalDensity, difficulty
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
skillGenerationGuide: {
|
|
386
|
+
suggestedStructure: string[];
|
|
387
|
+
keyTopics: string[];
|
|
388
|
+
recommendedSections: {
|
|
389
|
+
overview, quickStart, coreFeatures, bestPractices, troubleshooting
|
|
390
|
+
};
|
|
391
|
+
tips: string[];
|
|
392
|
+
quality: { contentQuality, codeExamples, completeness, overall };
|
|
393
|
+
};
|
|
394
|
+
fromCache: boolean;
|
|
395
|
+
cacheAge?: string; // If from cache
|
|
396
|
+
message: string;
|
|
594
397
|
}
|
|
595
398
|
```
|
|
596
399
|
|
|
597
|
-
|
|
598
|
-
- **smart(默认)**: HTTP优先,内容不足时自动切换浏览器(推荐)
|
|
599
|
-
- **auto**: 检测到SPA立即使用浏览器
|
|
600
|
-
- **manual**: 仅在useBrowserAutomation=true时使用浏览器
|
|
400
|
+
**Example Cursor prompts:**
|
|
601
401
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
- ✅ 或设置CHROME_PATH环境变量
|
|
606
|
-
- 📖 详见:[SPA浏览器设置指南](docs/SPA_BROWSER_SETUP.md)
|
|
402
|
+
```bash
|
|
403
|
+
# Basic usage
|
|
404
|
+
"Crawl https://react.dev and create a SKILL"
|
|
607
405
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
- 浏览器模式:2-3秒/页
|
|
611
|
-
- smart策略:平均<1.5秒/页(自动优化)
|
|
406
|
+
# Limit pages
|
|
407
|
+
"Crawl Vue.js docs but only 50 pages"
|
|
612
408
|
|
|
613
|
-
|
|
409
|
+
# Force refresh
|
|
410
|
+
"Re-crawl React docs, ignore cache"
|
|
614
411
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
爬取 https://vuejs.org,自动处理SPA,最多100页
|
|
412
|
+
# Use browser for SPA
|
|
413
|
+
"Crawl https://app.example.com with Playwright"
|
|
618
414
|
```
|
|
619
415
|
|
|
620
|
-
|
|
621
|
-
```
|
|
622
|
-
从 https://angular.io 生成技能,使用浏览器渲染,5个并发worker
|
|
623
|
-
```
|
|
416
|
+
### Tool 2: `list_cached_documentation`
|
|
624
417
|
|
|
625
|
-
|
|
626
|
-
|
|
418
|
+
List all cached documentation crawl results with metadata.
|
|
419
|
+
|
|
420
|
+
**Parameters:** None
|
|
421
|
+
|
|
422
|
+
**Returns:**
|
|
423
|
+
```typescript
|
|
627
424
|
{
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
425
|
+
success: boolean;
|
|
426
|
+
entries: Array<{
|
|
427
|
+
url: string;
|
|
428
|
+
technology?: string;
|
|
429
|
+
pageCount: number;
|
|
430
|
+
cachedAt: string; // ISO timestamp
|
|
431
|
+
age: string; // Human-readable, e.g., "2 hours ago"
|
|
432
|
+
size: string; // Human-readable, e.g., "2.5 MB"
|
|
433
|
+
}>;
|
|
434
|
+
statistics: {
|
|
435
|
+
totalEntries: number;
|
|
436
|
+
totalSize: number; // Bytes
|
|
437
|
+
oldestEntry?: Date;
|
|
438
|
+
newestEntry?: Date;
|
|
439
|
+
};
|
|
440
|
+
message: string;
|
|
632
441
|
}
|
|
633
442
|
```
|
|
634
443
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
#### `detect_errors` - 检测错误
|
|
642
|
-
|
|
643
|
-
检测代码中的错误和警告。
|
|
644
|
-
|
|
645
|
-
**参数:**
|
|
646
|
-
- `code`(必需):要分析的代码
|
|
647
|
-
- `filename`(可选):用于上下文的文件名(默认:'code.ts')
|
|
648
|
-
|
|
649
|
-
**使用示例:**
|
|
650
|
-
|
|
651
|
-
```
|
|
652
|
-
请检测这段代码的错误:
|
|
653
|
-
const x = y;
|
|
654
|
-
console.log(z);
|
|
444
|
+
**Example Cursor prompts:**
|
|
445
|
+
```bash
|
|
446
|
+
"Show me all cached documentation"
|
|
447
|
+
"List cached docs"
|
|
448
|
+
"What's in the cache?"
|
|
655
449
|
```
|
|
656
450
|
|
|
657
|
-
|
|
451
|
+
### Tool 3: `save_skill` ⭐ NEW
|
|
658
452
|
|
|
659
|
-
|
|
453
|
+
**Save complete SKILL directory structure to filesystem.**
|
|
660
454
|
|
|
661
|
-
|
|
662
|
-
- `
|
|
663
|
-
- `
|
|
664
|
-
-
|
|
455
|
+
Creates a properly formatted Cursor Agent Skill with:
|
|
456
|
+
- `SKILL.md` - Main skill file with metadata
|
|
457
|
+
- `references/` - Reference documentation organized by category
|
|
458
|
+
- Standard directory structure compatible with Cursor
|
|
665
459
|
|
|
666
|
-
|
|
460
|
+
**Parameters:**
|
|
667
461
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
462
|
+
| Parameter | Type | Required | Default | Description |
|
|
463
|
+
|-----------|------|----------|---------|-------------|
|
|
464
|
+
| `skillName` | `string` | ✅ Yes | - | Name for skill directory (e.g., "react-docs") |
|
|
465
|
+
| `skillContent` | `string` | ✅ Yes | - | Content for SKILL.md file |
|
|
466
|
+
| `referenceFiles` | `Record<string, string>` | No | `{}` | Map of category → markdown content |
|
|
467
|
+
| `baseDirectory` | `string` | No | `~/.claude/skills` | Base directory for skills |
|
|
468
|
+
| `overwrite` | `boolean` | No | `false` | Overwrite existing skill |
|
|
469
|
+
|
|
470
|
+
**Returns:**
|
|
471
|
+
```typescript
|
|
472
|
+
{
|
|
473
|
+
success: boolean;
|
|
474
|
+
skillDirectory: string; // Absolute path to skill directory
|
|
475
|
+
filesCreated: {
|
|
476
|
+
skillMd: string; // Path to SKILL.md
|
|
477
|
+
references: string[]; // Paths to reference files
|
|
478
|
+
};
|
|
479
|
+
message: string;
|
|
672
480
|
}
|
|
673
481
|
```
|
|
674
482
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
获取特定错误的解决方案建议。
|
|
678
|
-
|
|
679
|
-
**参数:**
|
|
680
|
-
- `errorType`(必需):错误类型
|
|
681
|
-
- `message`(必需):错误消息
|
|
682
|
-
- `line`(可选):错误发生的行号
|
|
683
|
-
|
|
684
|
-
**使用示例:**
|
|
685
|
-
|
|
483
|
+
**Directory Structure Created:**
|
|
686
484
|
```
|
|
687
|
-
|
|
485
|
+
~/.claude/skills/
|
|
486
|
+
└── [skillName]/
|
|
487
|
+
├── SKILL.md # Main skill file
|
|
488
|
+
└── references/ # Reference documentation
|
|
489
|
+
├── api.md # API category
|
|
490
|
+
├── guides.md # Guides category
|
|
491
|
+
├── getting_started.md # Getting started
|
|
492
|
+
└── ... # Other categories
|
|
688
493
|
```
|
|
689
494
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
检测网站是否为需要 JavaScript 渲染的单页应用(SPA)。
|
|
495
|
+
**Example Cursor Prompts:**
|
|
693
496
|
|
|
694
|
-
|
|
695
|
-
|
|
497
|
+
```bash
|
|
498
|
+
# After crawling, extract and save skill data
|
|
499
|
+
"Use the crawled React data to create a complete SKILL:
|
|
500
|
+
- skillName: 'react-docs'
|
|
501
|
+
- skillContent: [generated from guidance]
|
|
502
|
+
- referenceFiles: [organized by category]"
|
|
696
503
|
|
|
697
|
-
|
|
504
|
+
# Save with custom location
|
|
505
|
+
"Save the Vue skill to ~/my-skills/"
|
|
698
506
|
|
|
699
|
-
|
|
700
|
-
|
|
507
|
+
# Overwrite existing
|
|
508
|
+
"Update the react-docs skill with new content"
|
|
701
509
|
```
|
|
702
510
|
|
|
703
|
-
|
|
704
|
-
- `isSPA`:是否为 SPA
|
|
705
|
-
- `confidence`:检测置信度(high/medium/low)
|
|
706
|
-
- `indicators`:检测到的 SPA 指标
|
|
707
|
-
- `suggestion`:建议(如果检测到 SPA)
|
|
511
|
+
**Automated Workflow Example:**
|
|
708
512
|
|
|
709
|
-
|
|
513
|
+
```
|
|
514
|
+
User: "Crawl React docs and save as a complete SKILL"
|
|
710
515
|
|
|
711
|
-
|
|
516
|
+
Step 1: Cursor calls crawl_documentation
|
|
517
|
+
Step 2: Receives data with pages organized by category
|
|
518
|
+
Step 3: Cursor calls save_skill with:
|
|
519
|
+
{
|
|
520
|
+
skillName: "react-docs",
|
|
521
|
+
skillContent: "[Generated SKILL.md from guidance]",
|
|
522
|
+
referenceFiles: {
|
|
523
|
+
"api": "[API pages content]",
|
|
524
|
+
"guides": "[Guide pages content]",
|
|
525
|
+
"getting_started": "[Getting started content]"
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
Step 4: Tool creates complete directory structure
|
|
529
|
+
Step 5: Returns paths to all created files
|
|
530
|
+
```
|
|
712
531
|
|
|
713
|
-
|
|
532
|
+
### Tool 4: `clear_cache`
|
|
714
533
|
|
|
715
|
-
|
|
534
|
+
Clear cached documentation results by pattern, all entries, or expired only.
|
|
716
535
|
|
|
717
|
-
|
|
536
|
+
**Parameters:**
|
|
718
537
|
|
|
719
|
-
|
|
538
|
+
| Parameter | Type | Required | Default | Description |
|
|
539
|
+
|-----------|------|----------|---------|-------------|
|
|
540
|
+
| `urlPattern` | `string` | No | - | URL pattern to match (substring) |
|
|
541
|
+
| `clearAll` | `boolean` | No | `false` | Clear all cached entries |
|
|
720
542
|
|
|
721
|
-
|
|
543
|
+
**Behavior:**
|
|
544
|
+
- If `clearAll: true` → Delete all cached entries
|
|
545
|
+
- If `urlPattern` provided → Delete entries matching pattern
|
|
546
|
+
- If neither → Delete only expired entries (>7 days old)
|
|
722
547
|
|
|
548
|
+
**Returns:**
|
|
549
|
+
```typescript
|
|
550
|
+
{
|
|
551
|
+
success: boolean;
|
|
552
|
+
deletedCount: number;
|
|
553
|
+
message: string;
|
|
554
|
+
}
|
|
723
555
|
```
|
|
724
|
-
safe-coder/
|
|
725
|
-
├── src/
|
|
726
|
-
│ ├── documentation/ # 文档获取、缓存、爬取和技能生成
|
|
727
|
-
│ │ ├── index.ts # 文档服务
|
|
728
|
-
│ │ ├── web-doc-browser.ts # 网页文档浏览
|
|
729
|
-
│ │ ├── doc-crawler.ts # 文档爬取
|
|
730
|
-
│ │ └── skill-generator.ts # 技能生成
|
|
731
|
-
│ ├── errors/ # 错误检测(ESLint、TypeScript、模式、上下文)
|
|
732
|
-
│ ├── validation/ # 代码验证和自动修复
|
|
733
|
-
│ ├── server/ # MCP 服务器实现
|
|
734
|
-
│ ├── types/ # TypeScript 类型定义
|
|
735
|
-
│ ├── utils/ # 配置和工具函数
|
|
736
|
-
│ └── index.ts # 入口文件
|
|
737
|
-
├── tests/ # 测试文件
|
|
738
|
-
├── dist/ # 编译输出
|
|
739
|
-
└── package.json
|
|
740
|
-
```
|
|
741
|
-
|
|
742
|
-
### 开发命令
|
|
743
556
|
|
|
557
|
+
**Example Cursor prompts:**
|
|
744
558
|
```bash
|
|
745
|
-
#
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
# 构建项目
|
|
749
|
-
npm run build
|
|
750
|
-
|
|
751
|
-
# 开发模式运行(自动重新编译)
|
|
752
|
-
npm run dev
|
|
753
|
-
|
|
754
|
-
# 运行测试
|
|
755
|
-
npm test
|
|
756
|
-
|
|
757
|
-
# 监听模式运行测试
|
|
758
|
-
npm run test:watch
|
|
559
|
+
# Clear all
|
|
560
|
+
"Clear all cached documentation"
|
|
759
561
|
|
|
760
|
-
#
|
|
761
|
-
|
|
562
|
+
# Clear by pattern
|
|
563
|
+
"Clear cache for react.dev"
|
|
564
|
+
"Delete cached Vue docs"
|
|
762
565
|
|
|
763
|
-
#
|
|
764
|
-
|
|
566
|
+
# Clear expired only
|
|
567
|
+
"Clear old cached docs"
|
|
765
568
|
```
|
|
766
569
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
如果遇到问题,可以:
|
|
770
|
-
|
|
771
|
-
1. **检查服务器是否正常运行**:
|
|
772
|
-
|
|
773
|
-
```bash
|
|
774
|
-
npm run dev
|
|
775
|
-
```
|
|
776
|
-
|
|
777
|
-
应该看到:`Safe Coder MCP server running on stdio`
|
|
778
|
-
|
|
779
|
-
2. **查看 Cursor 的 MCP 日志**:
|
|
780
|
-
- 在 Cursor 中打开开发者工具
|
|
781
|
-
- 查看控制台中的 MCP 相关错误
|
|
782
|
-
|
|
783
|
-
3. **测试工具调用**:
|
|
784
|
-
可以在 Cursor 的 AI 对话中直接请求使用工具,例如:
|
|
785
|
-
|
|
786
|
-
```
|
|
787
|
-
请使用 get_documentation 工具获取 react 的文档
|
|
788
|
-
```
|
|
789
|
-
|
|
790
|
-
## 常见问题
|
|
570
|
+
## Internal Workflow
|
|
791
571
|
|
|
792
|
-
###
|
|
572
|
+
### 1. Dependency Check
|
|
793
573
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
- 查看错误日志
|
|
798
|
-
|
|
799
|
-
### Q: 无法获取 GitHub 文档?
|
|
800
|
-
|
|
801
|
-
**A:**
|
|
802
|
-
- 如果访问私有仓库,需要设置 `GITHUB_TOKEN` 环境变量
|
|
803
|
-
- 公开仓库通常不需要 token,但设置 token 可以提高速率限制
|
|
574
|
+
```typescript
|
|
575
|
+
const checker = new DependencyChecker();
|
|
576
|
+
const check = await checker.checkCLIInstalled();
|
|
804
577
|
|
|
805
|
-
|
|
578
|
+
if (!check.installed) {
|
|
579
|
+
throw new Error(`
|
|
580
|
+
⚠️ safe-coder-cli is not installed.
|
|
806
581
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
- 某些复杂的错误可能需要更多上下文
|
|
810
|
-
- 可以尝试使用 `validate_code` 工具获得更全面的分析
|
|
582
|
+
Please install globally:
|
|
583
|
+
npm install -g @gulibs/safe-coder-cli
|
|
811
584
|
|
|
812
|
-
|
|
585
|
+
Or from source:
|
|
586
|
+
cd /path/to/safe-coder-cli
|
|
587
|
+
npm install && npm run build && npm link
|
|
813
588
|
|
|
814
|
-
|
|
815
|
-
-
|
|
816
|
-
|
|
817
|
-
|
|
589
|
+
Then verify:
|
|
590
|
+
safe-coder-cli --version
|
|
591
|
+
`);
|
|
592
|
+
}
|
|
593
|
+
```
|
|
818
594
|
|
|
819
|
-
###
|
|
595
|
+
### 2. CLI Execution
|
|
820
596
|
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
597
|
+
```typescript
|
|
598
|
+
const executor = new CLIExecutor(checker);
|
|
599
|
+
const result = await executor.executeCrawl({
|
|
600
|
+
url: 'https://react.dev',
|
|
601
|
+
maxPages: 200,
|
|
602
|
+
maxDepth: 3,
|
|
603
|
+
// ... other params
|
|
604
|
+
}, (progress) => {
|
|
605
|
+
console.error(`[Progress] ${progress.message}`);
|
|
606
|
+
});
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
**Under the hood:**
|
|
610
|
+
```bash
|
|
611
|
+
spawn('safe-coder-cli', [
|
|
612
|
+
'crawl',
|
|
613
|
+
'https://react.dev',
|
|
614
|
+
'--output-format', 'json',
|
|
615
|
+
'--max-pages', '200',
|
|
616
|
+
'--depth', '3'
|
|
617
|
+
])
|
|
826
618
|
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
爬取 https://react.dev/docs 的文档并生成技能
|
|
619
|
+
# stdout → JSON result
|
|
620
|
+
# stderr → Progress messages
|
|
830
621
|
```
|
|
831
622
|
|
|
832
|
-
###
|
|
623
|
+
### 3. Content Processing
|
|
833
624
|
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
- 调整 `rateLimit` 避免对服务器造成压力(默认 500ms)
|
|
838
|
-
- 使用 `workers` 参数启用并行爬取(推荐5-8个)
|
|
839
|
-
- 启用 `checkpoint` 断点续传(超过200页建议启用)
|
|
840
|
-
- 大型站点建议分多次爬取不同部分
|
|
841
|
-
|
|
842
|
-
### Q: 如何爬取SPA网站(React、Vue等)?
|
|
843
|
-
|
|
844
|
-
**A:**
|
|
845
|
-
- 系统自动检测SPA并智能切换到浏览器渲染
|
|
846
|
-
- 确保系统已安装Chrome/Chromium/Edge浏览器
|
|
847
|
-
- 使用 `spaStrategy: "smart"` 获得最佳性能(默认)
|
|
848
|
-
- 或使用 `spaStrategy: "auto"` 强制使用浏览器
|
|
849
|
-
- 详见:`docs/SPA_BROWSER_SETUP.md`
|
|
625
|
+
```typescript
|
|
626
|
+
const processor = new ContentProcessor();
|
|
627
|
+
const processed = await processor.process(rawResult);
|
|
850
628
|
|
|
851
|
-
|
|
629
|
+
// Extracts:
|
|
630
|
+
// - Key points from each page
|
|
631
|
+
// - Code patterns and examples
|
|
632
|
+
// - Content categories
|
|
633
|
+
// - Technical density
|
|
634
|
+
// - Difficulty level
|
|
852
635
|
```
|
|
853
|
-
爬取 https://react.dev,自动处理SPA
|
|
854
|
-
```
|
|
855
|
-
|
|
856
|
-
### Q: 系统没有Chrome怎么办?
|
|
857
636
|
|
|
858
|
-
|
|
859
|
-
有三种解决方案:
|
|
860
|
-
1. **安装Chrome**(推荐):
|
|
861
|
-
- macOS: `brew install --cask google-chrome`
|
|
862
|
-
- Windows: `winget install Google.Chrome`
|
|
863
|
-
- Linux: `sudo apt install google-chrome-stable`
|
|
637
|
+
### 4. SKILL Guidance Generation
|
|
864
638
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
```
|
|
869
|
-
|
|
870
|
-
3. **设置浏览器路径**:
|
|
871
|
-
```bash
|
|
872
|
-
export CHROME_PATH=/path/to/chrome
|
|
873
|
-
```
|
|
639
|
+
```typescript
|
|
640
|
+
const guideGenerator = new GuideGenerator();
|
|
641
|
+
const guide = guideGenerator.generate(processed);
|
|
874
642
|
|
|
875
|
-
|
|
643
|
+
// Creates:
|
|
644
|
+
// - Suggested SKILL structure
|
|
645
|
+
// - Key topics to cover
|
|
646
|
+
// - Recommended sections
|
|
647
|
+
// - Writing tips
|
|
648
|
+
// - Quality assessment
|
|
649
|
+
```
|
|
876
650
|
|
|
877
|
-
###
|
|
651
|
+
### 5. Caching
|
|
878
652
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
- **`crawl_documentation`**: 递归爬取多个页面,生成完整的技能文件
|
|
882
|
-
- 浏览适合查看特定内容,爬取适合生成完整文档技能
|
|
653
|
+
```typescript
|
|
654
|
+
const cache = new CacheManager();
|
|
883
655
|
|
|
884
|
-
|
|
656
|
+
// Save (7-day TTL)
|
|
657
|
+
await cache.set(url, processed, guide);
|
|
885
658
|
|
|
886
|
-
|
|
659
|
+
// Retrieve
|
|
660
|
+
const cached = await cache.get(url);
|
|
661
|
+
if (cached && !forceRefresh) {
|
|
662
|
+
return cached;
|
|
663
|
+
}
|
|
664
|
+
```
|
|
887
665
|
|
|
888
|
-
|
|
666
|
+
**Cache location:** `~/.safe-coder/cache/`
|
|
667
|
+
**Cache format:** JSON files with base64-encoded URL as filename
|
|
668
|
+
**TTL:** 7 days (default)
|
|
889
669
|
|
|
890
|
-
|
|
891
|
-
# 确保已登录 npm
|
|
892
|
-
npm login
|
|
670
|
+
## Error Handling
|
|
893
671
|
|
|
894
|
-
|
|
895
|
-
npm view @gulibs/safe-coder
|
|
672
|
+
### CLI Not Installed
|
|
896
673
|
|
|
897
|
-
# 更新版本号
|
|
898
|
-
npm version patch # 或 minor, major
|
|
899
674
|
```
|
|
675
|
+
Error: safe-coder-cli is not installed
|
|
900
676
|
|
|
901
|
-
|
|
677
|
+
Please install:
|
|
678
|
+
npm install -g @gulibs/safe-coder-cli
|
|
902
679
|
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
npm publish --access public
|
|
680
|
+
Current PATH checked:
|
|
681
|
+
/usr/local/bin
|
|
682
|
+
/usr/bin
|
|
683
|
+
/bin
|
|
684
|
+
...
|
|
909
685
|
```
|
|
910
686
|
|
|
911
|
-
###
|
|
687
|
+
### CLI Execution Failed
|
|
912
688
|
|
|
913
|
-
```bash
|
|
914
|
-
# 检查包是否已发布
|
|
915
|
-
npm view @gulibs/safe-coder
|
|
916
|
-
|
|
917
|
-
# 测试安装
|
|
918
|
-
npm install -g @gulibs/safe-coder
|
|
919
689
|
```
|
|
690
|
+
Error: CLI process exited with code 1
|
|
920
691
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
692
|
+
stderr output:
|
|
693
|
+
[Error] Failed to crawl: Network timeout
|
|
694
|
+
[Error] URL: https://example.com
|
|
924
695
|
|
|
925
|
-
|
|
696
|
+
Possible solutions:
|
|
697
|
+
- Check network connectivity
|
|
698
|
+
- Try with --use-browser flag
|
|
699
|
+
- Increase timeout with --rate-limit
|
|
700
|
+
```
|
|
926
701
|
|
|
927
|
-
|
|
702
|
+
### Cache Errors
|
|
928
703
|
|
|
929
|
-
```json
|
|
930
|
-
{
|
|
931
|
-
"mcpServers": {
|
|
932
|
-
"safe-coder": {
|
|
933
|
-
"command": "node",
|
|
934
|
-
"args": ["./dist/index.js"],
|
|
935
|
-
"env": {
|
|
936
|
-
"CACHE_TTL_MINUTES": "60",
|
|
937
|
-
"GITHUB_TOKEN": ""
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
704
|
```
|
|
705
|
+
Warning: Failed to cache results
|
|
706
|
+
Error: EACCES: permission denied, mkdir '~/.safe-coder/cache'
|
|
943
707
|
|
|
944
|
-
|
|
708
|
+
Continuing without cache...
|
|
709
|
+
```
|
|
945
710
|
|
|
946
|
-
|
|
711
|
+
Cache errors are non-fatal - the operation continues without caching.
|
|
947
712
|
|
|
948
|
-
|
|
713
|
+
## Configuration
|
|
949
714
|
|
|
950
|
-
|
|
951
|
-
#!/bin/bash
|
|
952
|
-
# test-mcp.sh
|
|
715
|
+
### Cache Settings
|
|
953
716
|
|
|
954
|
-
|
|
955
|
-
npm run build
|
|
717
|
+
Modify cache behavior by editing `src/cache/cache-manager.ts`:
|
|
956
718
|
|
|
957
|
-
|
|
958
|
-
|
|
719
|
+
```typescript
|
|
720
|
+
const cache = new CacheManager(
|
|
721
|
+
'/custom/cache/path', // Default: ~/.safe-coder/cache
|
|
722
|
+
14 // TTL in days (default: 7)
|
|
723
|
+
);
|
|
959
724
|
```
|
|
960
725
|
|
|
961
|
-
|
|
726
|
+
### CLI Arguments Mapping
|
|
962
727
|
|
|
963
|
-
|
|
728
|
+
| MCP Parameter | CLI Argument |
|
|
729
|
+
|---------------|--------------|
|
|
730
|
+
| `url` | `<url>` (positional) |
|
|
731
|
+
| `maxPages` | `--max-pages <number>` |
|
|
732
|
+
| `depth` | `--max-depth <number>` |
|
|
733
|
+
| `workers` | `--workers <number>` |
|
|
734
|
+
| `useBrowser` | (implicitly sets `--spa-strategy auto`) |
|
|
735
|
+
| `browser` | `--browser <type>` |
|
|
736
|
+
| `spaStrategy` | `--spa-strategy <type>` |
|
|
737
|
+
| - | `--output-format json` (forced) |
|
|
964
738
|
|
|
965
|
-
|
|
966
|
-
1. 检查路径是否正确(使用绝对路径)
|
|
967
|
-
2. 确保 `dist/index.js` 文件存在
|
|
968
|
-
3. 检查 Node.js 是否在 PATH 中:`which node` 或 `where node`
|
|
739
|
+
## Troubleshooting
|
|
969
740
|
|
|
970
|
-
###
|
|
741
|
+
### MCP Server Not Appearing in Cursor
|
|
971
742
|
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
743
|
+
1. **Check configuration file exists:**
|
|
744
|
+
```bash
|
|
745
|
+
cat ~/Library/Application\ Support/Cursor/User/globalStorage/mcp.json
|
|
746
|
+
```
|
|
976
747
|
|
|
977
|
-
|
|
748
|
+
2. **Verify JSON syntax is valid**
|
|
978
749
|
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
750
|
+
3. **Check absolute path is correct:**
|
|
751
|
+
```bash
|
|
752
|
+
node /absolute/path/to/safe-coder/dist/index.js
|
|
753
|
+
# Should not error
|
|
754
|
+
```
|
|
983
755
|
|
|
984
|
-
|
|
756
|
+
4. **Restart Cursor completely**
|
|
985
757
|
|
|
986
|
-
|
|
758
|
+
### "CLI Not Found" Error
|
|
987
759
|
|
|
988
760
|
```bash
|
|
989
|
-
#
|
|
990
|
-
|
|
991
|
-
```
|
|
761
|
+
# Check if CLI is in PATH
|
|
762
|
+
which safe-coder-cli
|
|
992
763
|
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
764
|
+
# If not found, reinstall
|
|
765
|
+
cd /path/to/safe-coder-cli
|
|
766
|
+
npm link
|
|
996
767
|
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
### 快速上手
|
|
1000
|
-
|
|
1001
|
-
#### 步骤1:在Claude/Cursor中触发爬取
|
|
1002
|
-
|
|
1003
|
-
**中文触发词:**
|
|
1004
|
-
```
|
|
1005
|
-
帮我爬取 https://react.dev 的文档并生成Agent Skill
|
|
768
|
+
# Verify
|
|
769
|
+
safe-coder-cli --version
|
|
1006
770
|
```
|
|
1007
771
|
|
|
1008
|
-
|
|
1009
|
-
使用并行爬取从 https://docs.example.com 生成技能,要快一点
|
|
1010
|
-
```
|
|
772
|
+
### Slow Crawling
|
|
1011
773
|
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
774
|
+
- Reduce `maxPages` (e.g., 50 instead of 200)
|
|
775
|
+
- Decrease `depth` (e.g., 2 instead of 3)
|
|
776
|
+
- Increase `workers` (e.g., 3 for parallel crawling) - *requires CLI support*
|
|
1015
777
|
|
|
1016
|
-
|
|
1017
|
-
```
|
|
1018
|
-
Crawl https://react.dev and generate an agent skill
|
|
1019
|
-
```
|
|
778
|
+
### Cache Not Working
|
|
1020
779
|
|
|
1021
|
-
```
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
```
|
|
1026
|
-
Recursive crawl https://nextjs.org/docs with DFS strategy
|
|
1027
|
-
```
|
|
1028
|
-
|
|
1029
|
-
#### 步骤2:配置爬取参数
|
|
1030
|
-
|
|
1031
|
-
Claude/Cursor会自动调用`crawl_documentation`工具,你可以在对话中指定参数:
|
|
1032
|
-
|
|
1033
|
-
**基础爬取:**
|
|
1034
|
-
```
|
|
1035
|
-
爬取 https://react.dev/docs,最多50页
|
|
1036
|
-
```
|
|
780
|
+
```bash
|
|
781
|
+
# Check cache directory
|
|
782
|
+
ls -la ~/.safe-coder/cache/
|
|
1037
783
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
爬取 https://react.dev,使用5个并发worker,最多200页
|
|
1041
|
-
```
|
|
784
|
+
# Permissions issue?
|
|
785
|
+
chmod 755 ~/.safe-coder/cache/
|
|
1042
786
|
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
787
|
+
# Clear and rebuild
|
|
788
|
+
rm -rf ~/.safe-coder/cache/
|
|
789
|
+
# Cache will recreate on next crawl
|
|
1046
790
|
```
|
|
1047
791
|
|
|
1048
|
-
|
|
1049
|
-
```
|
|
1050
|
-
爬取 https://large-docs.com,最多1000页,启用断点续传每50页保存
|
|
1051
|
-
```
|
|
792
|
+
## Development
|
|
1052
793
|
|
|
1053
|
-
###
|
|
794
|
+
### Project Structure
|
|
1054
795
|
|
|
1055
|
-
#### 场景1:快速探索新技术栈
|
|
1056
|
-
```
|
|
1057
|
-
帮我爬取 Svelte 的官方文档,快速生成一个技能
|
|
1058
796
|
```
|
|
797
|
+
safe-coder/
|
|
798
|
+
├── src/
|
|
799
|
+
│ ├── index.ts # Entry point
|
|
800
|
+
│ ├── server/
|
|
801
|
+
│ │ └── safe-coder-mcp.ts # MCP server class
|
|
802
|
+
│ ├── executor/
|
|
803
|
+
│ │ ├── dependency-checker.ts # Check CLI installation
|
|
804
|
+
│ │ └── cli-executor.ts # Spawn CLI process
|
|
805
|
+
│ ├── processor/
|
|
806
|
+
│ │ ├── content-processor.ts # Analyze content
|
|
807
|
+
│ │ └── guide-generator.ts # Generate SKILL guidance
|
|
808
|
+
│ ├── cache/
|
|
809
|
+
│ │ └── cache-manager.ts # Cache management
|
|
810
|
+
│ └── tools/
|
|
811
|
+
│ ├── crawl-documentation.ts # Main MCP tool
|
|
812
|
+
│ ├── cache-tools.ts # Cache MCP tools
|
|
813
|
+
│ └── index.ts # Tool exports
|
|
814
|
+
├── dist/ # Compiled output
|
|
815
|
+
├── tsconfig.json
|
|
816
|
+
├── package.json
|
|
817
|
+
└── README.md
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
### Build and Test
|
|
1059
821
|
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
- crawlStrategy: bfs(全面覆盖)
|
|
1064
|
-
|
|
1065
|
-
#### 场景2:深入学习框架
|
|
1066
|
-
```
|
|
1067
|
-
深入爬取 Vue 3 的文档,我要完整理解它的 API
|
|
1068
|
-
```
|
|
822
|
+
```bash
|
|
823
|
+
# Install dependencies
|
|
824
|
+
npm install
|
|
1069
825
|
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
- maxDepth: 5(深入层级)
|
|
1073
|
-
- workers: 5(加速)
|
|
1074
|
-
- maxPages: 200(完整覆盖)
|
|
826
|
+
# Build
|
|
827
|
+
npm run build
|
|
1075
828
|
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
爬取 MDN Web Docs 的 JavaScript 部分,分多次进行,支持断点恢复
|
|
1079
|
-
```
|
|
829
|
+
# Watch mode
|
|
830
|
+
npm run build -- --watch
|
|
1080
831
|
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
- maxPages: 1000
|
|
1084
|
-
- checkpoint: { enabled: true, interval: 50 }
|
|
832
|
+
# Test locally
|
|
833
|
+
node dist/index.js
|
|
1085
834
|
|
|
1086
|
-
|
|
835
|
+
# Test with MCP Inspector (if available)
|
|
836
|
+
npx @modelcontextprotocol/inspector node dist/index.js
|
|
1087
837
|
```
|
|
1088
|
-
上次爬取中断了,从断点继续爬取 https://large-docs.com
|
|
1089
|
-
```
|
|
1090
|
-
|
|
1091
|
-
**自动参数:**
|
|
1092
|
-
- resume: true
|
|
1093
|
-
- checkpoint: { enabled: true }
|
|
1094
|
-
|
|
1095
|
-
### 生成的Agent Skill格式
|
|
1096
838
|
|
|
1097
|
-
|
|
839
|
+
### Running with Debug Output
|
|
1098
840
|
|
|
1099
|
-
```
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
├── Core Concepts # 核心概念
|
|
1104
|
-
├── API Reference # API参考
|
|
1105
|
-
├── Examples # 示例代码
|
|
1106
|
-
└── Reference Files # 引用文件列表
|
|
1107
|
-
|
|
1108
|
-
references/ # 引用文件目录
|
|
1109
|
-
├── page-1.md
|
|
1110
|
-
├── page-2.md
|
|
1111
|
-
└── ...
|
|
841
|
+
```typescript
|
|
842
|
+
// In src/index.ts
|
|
843
|
+
console.error('[Debug] MCP Server starting...');
|
|
844
|
+
console.error('[Debug] Available tools:', server.listTools());
|
|
1112
845
|
```
|
|
1113
846
|
|
|
1114
|
-
|
|
847
|
+
MCP uses stdio, so:
|
|
848
|
+
- `stdout` → MCP protocol messages (JSON-RPC)
|
|
849
|
+
- `stderr` → Debug/log output (visible in Cursor logs)
|
|
1115
850
|
|
|
1116
|
-
|
|
851
|
+
## Roadmap / Future Enhancements
|
|
1117
852
|
|
|
1118
|
-
|
|
1119
|
-
|-----|-----|---------|
|
|
1120
|
-
| **内容充足性** | 每页内容长度 | > 100字符/页 |
|
|
1121
|
-
| **结构完整性** | 标题、章节组织 | 至少1个标题/页 |
|
|
1122
|
-
| **内容多样性** | URL路径和主题分布 | diversity > 0.7 |
|
|
1123
|
-
| **API覆盖度** | 代码示例比例 | coverage > 0.5 |
|
|
853
|
+
### Planned Features
|
|
1124
854
|
|
|
1125
|
-
|
|
855
|
+
1. **Expose More CLI Parameters**
|
|
856
|
+
- [ ] `strategy` (bfs/dfs)
|
|
857
|
+
- [ ] `checkpoint`, `resume`
|
|
858
|
+
- [ ] `rateLimit`, `maxRetries`
|
|
859
|
+
- [ ] `includePaths`, `excludePaths`
|
|
1126
860
|
|
|
1127
|
-
|
|
861
|
+
2. **Direct File Creation Tool**
|
|
862
|
+
- [ ] `save_skill` tool to create SKILL.md directly
|
|
863
|
+
- [ ] Automatic filename generation
|
|
864
|
+
- [ ] Default location management
|
|
1128
865
|
|
|
1129
|
-
|
|
866
|
+
3. **Enhanced Processing**
|
|
867
|
+
- [ ] Semantic analysis of content
|
|
868
|
+
- [ ] Automatic category detection
|
|
869
|
+
- [ ] Code example quality scoring
|
|
870
|
+
- [ ] Cross-reference detection
|
|
1130
871
|
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
872
|
+
4. **Better Caching**
|
|
873
|
+
- [ ] Configurable TTL per URL
|
|
874
|
+
- [ ] Cache compression
|
|
875
|
+
- [ ] Partial cache updates
|
|
876
|
+
- [ ] Cache analytics
|
|
1136
877
|
|
|
1137
|
-
|
|
878
|
+
## Contributing
|
|
1138
879
|
|
|
1139
|
-
|
|
1140
|
-
爬取并保存到 ./skills 目录,文件名为 react-docs
|
|
1141
|
-
```
|
|
880
|
+
This package is part of the Safe Coder project. Contributions welcome!
|
|
1142
881
|
|
|
1143
|
-
|
|
1144
|
-
- `./skills/react-docs.md` - Skill内容
|
|
1145
|
-
- `./skills/react-docs.metadata.json` - 元数据
|
|
882
|
+
### Development Workflow
|
|
1146
883
|
|
|
1147
|
-
|
|
884
|
+
1. Fork and clone both `safe-coder` and `safe-coder-cli`
|
|
885
|
+
2. Make changes
|
|
886
|
+
3. Build and test locally
|
|
887
|
+
4. Submit pull request
|
|
1148
888
|
|
|
1149
|
-
|
|
889
|
+
### Testing
|
|
1150
890
|
|
|
1151
891
|
```bash
|
|
1152
|
-
#
|
|
1153
|
-
|
|
892
|
+
# Unit tests (when implemented)
|
|
893
|
+
npm test
|
|
1154
894
|
|
|
1155
|
-
#
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
895
|
+
# Integration test
|
|
896
|
+
# 1. Build both packages
|
|
897
|
+
cd safe-coder-cli && npm run build && npm link
|
|
898
|
+
cd ../safe-coder && npm run build && npm link
|
|
1159
899
|
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
#### Q: 如何选择爬取策略?
|
|
1163
|
-
**A:**
|
|
1164
|
-
- **BFS(广度优先)**:适合扁平结构、需要全面覆盖的文档
|
|
1165
|
-
- **DFS(深度优先)**:适合层级结构、需要深入理解的文档
|
|
1166
|
-
|
|
1167
|
-
#### Q: workers设置多少合适?
|
|
1168
|
-
**A:**
|
|
1169
|
-
- 小型站点(<50页):workers: 2-3
|
|
1170
|
-
- 中型站点(50-200页):workers: 3-5
|
|
1171
|
-
- 大型站点(>200页):workers: 5-8
|
|
1172
|
-
|
|
1173
|
-
#### Q: 什么时候需要启用断点?
|
|
1174
|
-
**A:**
|
|
1175
|
-
- 爬取页面超过200页
|
|
1176
|
-
- 网络不稳定
|
|
1177
|
-
- 需要分批次爬取
|
|
1178
|
-
|
|
1179
|
-
#### Q: 如何提高爬取速度?
|
|
1180
|
-
**A:**
|
|
1181
|
-
1. 增加workers数量(推荐5-8个)
|
|
1182
|
-
2. 降低rateLimit(200-300ms)
|
|
1183
|
-
3. 确保站点有llms.txt(自动检测)
|
|
1184
|
-
|
|
1185
|
-
#### Q: 生成的Skill质量不够怎么办?
|
|
1186
|
-
**A:**
|
|
1187
|
-
1. 增加maxPages(建议200+)
|
|
1188
|
-
2. 调整maxDepth(建议3-5)
|
|
1189
|
-
3. 使用includePaths精确指定路径
|
|
1190
|
-
4. 查看日志中的质量指标建议
|
|
1191
|
-
|
|
1192
|
-
### 性能提示
|
|
1193
|
-
|
|
1194
|
-
**🚀 极速模式(适合快速探索):**
|
|
1195
|
-
```json
|
|
1196
|
-
{
|
|
1197
|
-
"workers": 5,
|
|
1198
|
-
"maxPages": 50,
|
|
1199
|
-
"rateLimit": 200,
|
|
1200
|
-
"crawlStrategy": "bfs"
|
|
1201
|
-
}
|
|
900
|
+
# 2. Configure in Cursor
|
|
901
|
+
# 3. Test end-to-end
|
|
1202
902
|
```
|
|
1203
903
|
|
|
1204
|
-
|
|
1205
|
-
```json
|
|
1206
|
-
{
|
|
1207
|
-
"workers": 5,
|
|
1208
|
-
"maxPages": 300,
|
|
1209
|
-
"maxDepth": 5,
|
|
1210
|
-
"crawlStrategy": "dfs",
|
|
1211
|
-
"checkpoint": { "enabled": true }
|
|
1212
|
-
}
|
|
1213
|
-
```
|
|
904
|
+
## License
|
|
1214
905
|
|
|
1215
|
-
|
|
1216
|
-
```json
|
|
1217
|
-
{
|
|
1218
|
-
"workers": 8,
|
|
1219
|
-
"skipLlmsTxt": false,
|
|
1220
|
-
"rateLimit": 200
|
|
1221
|
-
}
|
|
1222
|
-
```
|
|
906
|
+
MIT
|
|
1223
907
|
|
|
1224
|
-
|
|
908
|
+
## Related Projects
|
|
1225
909
|
|
|
1226
|
-
-
|
|
1227
|
-
-
|
|
1228
|
-
-
|
|
1229
|
-
- **原始文档爬取指南**:`docs/DOC_CRAWLER_USAGE.md`
|
|
910
|
+
- **@gulibs/safe-coder-cli** - Standalone documentation crawler
|
|
911
|
+
- **Cursor** - AI-powered code editor
|
|
912
|
+
- **Model Context Protocol (MCP)** - Protocol for AI tool integration
|
|
1230
913
|
|
|
1231
|
-
|
|
914
|
+
## Support
|
|
1232
915
|
|
|
1233
|
-
|
|
916
|
+
Issues: https://github.com/gulibs/safe-coder/issues
|
|
917
|
+
Discord: [Link TBD]
|
|
1234
918
|
|
|
1235
|
-
|
|
919
|
+
---
|
|
1236
920
|
|
|
1237
|
-
|
|
921
|
+
**Safe Coder** - Bringing documentation intelligence to your AI coding assistant.
|