deepspider 0.2.9 → 0.2.11
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/.trellis/spec/backend/quality-guidelines.md +28 -4
- package/README.md +10 -9
- package/package.json +1 -1
- package/requirements-crypto.txt +14 -8
- package/src/agent/prompts/system.js +2 -2
- package/src/agent/setup.js +4 -10
- package/src/agent/tools/python.js +6 -6
- package/src/agent/tools/report.js +8 -2
|
@@ -193,24 +193,48 @@ console.log('[DeepSpider:' + type + ']' + loc, data);
|
|
|
193
193
|
|
|
194
194
|
## Release Process
|
|
195
195
|
|
|
196
|
+
### 原生模块依赖处理
|
|
197
|
+
|
|
198
|
+
项目依赖 `isolated-vm` 等原生 C++ 模块,需要编译环境。
|
|
199
|
+
|
|
200
|
+
**postinstall 自动处理**:
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"scripts": {
|
|
204
|
+
"postinstall": "patchright install chromium && npm rebuild isolated-vm 2>/dev/null || true"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**编译环境要求**:
|
|
210
|
+
- macOS: `xcode-select --install`
|
|
211
|
+
- Ubuntu: `sudo apt install build-essential`
|
|
212
|
+
- Windows: Visual Studio Build Tools
|
|
213
|
+
|
|
214
|
+
> **注意**: `2>/dev/null || true` 确保编译失败不会阻塞安装,但沙箱功能可能不可用。
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
196
218
|
### 版本发布流程
|
|
197
219
|
|
|
198
|
-
|
|
220
|
+
升级版本并推送 tag,GitHub Actions 会自动发布到 npm:
|
|
199
221
|
|
|
200
222
|
```bash
|
|
201
223
|
# 1. 升级 package.json 版本
|
|
202
|
-
|
|
224
|
+
# 编辑 package.json 中的 version 字段
|
|
203
225
|
|
|
204
226
|
# 2. 提交版本变更
|
|
205
227
|
git add package.json
|
|
206
228
|
git commit -m "chore: bump version to x.x.x"
|
|
207
229
|
|
|
208
230
|
# 3. 创建并推送 git tag
|
|
209
|
-
git tag vx.x.x
|
|
231
|
+
git tag -a vx.x.x -m "vx.x.x"
|
|
210
232
|
git push && git push origin vx.x.x
|
|
211
233
|
```
|
|
212
234
|
|
|
213
|
-
|
|
235
|
+
> **注意**: 推送 tag 后 GitHub Actions 会自动触发 npm 发布,无需手动 `npm publish`。
|
|
236
|
+
|
|
237
|
+
**原因**: 自动化发布避免手动操作失误,确保版本一致性。
|
|
214
238
|
|
|
215
239
|
---
|
|
216
240
|
|
package/README.md
CHANGED
|
@@ -22,22 +22,23 @@
|
|
|
22
22
|
### 安装
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
# 方式一:npm
|
|
25
|
+
# 方式一:npm 全局安装(推荐)
|
|
26
26
|
npm install -g deepspider
|
|
27
27
|
|
|
28
|
-
#
|
|
28
|
+
# 方式二:pnpm 全局安装
|
|
29
|
+
pnpm approve-builds -g deepspider isolated-vm # 首次需要批准构建脚本
|
|
30
|
+
pnpm install -g deepspider
|
|
31
|
+
|
|
32
|
+
# 方式三:克隆仓库
|
|
29
33
|
git clone https://github.com/ma-pony/deepspider.git
|
|
30
34
|
cd deepspider
|
|
31
35
|
pnpm install
|
|
32
|
-
|
|
33
|
-
# 安装 Python
|
|
34
|
-
pnpm run setup:crypto
|
|
35
|
-
|
|
36
|
-
# 配置环境变量
|
|
37
|
-
cp .env.example .env
|
|
38
|
-
# 编辑 .env 填入配置(见下方环境变量说明)
|
|
36
|
+
cp .env.example .env # 配置环境变量
|
|
37
|
+
pnpm run setup:crypto # 安装 Python 加密库(可选)
|
|
39
38
|
```
|
|
40
39
|
|
|
40
|
+
安装完成后,首次运行会提示配置环境变量(LLM API)。
|
|
41
|
+
|
|
41
42
|
> **注意**: 项目依赖 `isolated-vm` 原生模块,需要 C++ 编译环境:
|
|
42
43
|
> - macOS: `xcode-select --install`
|
|
43
44
|
> - Ubuntu: `sudo apt install build-essential`
|
package/package.json
CHANGED
package/requirements-crypto.txt
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DeepSpider Python 依赖
|
|
2
2
|
# 安装: uv pip install -r requirements-crypto.txt
|
|
3
3
|
|
|
4
|
-
#
|
|
4
|
+
# 加密库
|
|
5
5
|
pycryptodome>=3.20.0 # AES/DES/RSA/MD5/SHA 等
|
|
6
|
+
gmssl>=3.2.2 # SM2/SM3/SM4 国密算法
|
|
7
|
+
rsa>=4.9 # RSA
|
|
8
|
+
pyDes>=2.0.1 # DES/3DES
|
|
6
9
|
|
|
7
|
-
#
|
|
8
|
-
|
|
10
|
+
# HTTP 请求
|
|
11
|
+
requests>=2.31.0 # HTTP 客户端
|
|
12
|
+
httpx>=0.27.0 # 异步 HTTP 客户端
|
|
9
13
|
|
|
10
|
-
#
|
|
11
|
-
|
|
14
|
+
# JS 执行
|
|
15
|
+
PyExecJS>=1.5.1 # 执行 JS 代码
|
|
12
16
|
|
|
13
|
-
#
|
|
14
|
-
|
|
17
|
+
# 数据处理
|
|
18
|
+
lxml>=5.0.0 # HTML/XML 解析
|
|
19
|
+
beautifulsoup4>=4.12.0 # HTML 解析
|
|
20
|
+
parsel>=1.8.0 # XPath/CSS 选择器
|
|
@@ -59,7 +59,7 @@ export const fullAnalysisPrompt = `
|
|
|
59
59
|
|
|
60
60
|
#### 第一层:算法验证(必须)
|
|
61
61
|
验证加密/解密函数本身是否正确:
|
|
62
|
-
1. 使用 \`
|
|
62
|
+
1. 使用 \`run_python_code\` 执行加密/解密代码
|
|
63
63
|
2. 检查:encrypt(plaintext) → ciphertext → decrypt() → plaintext
|
|
64
64
|
|
|
65
65
|
#### 第二层:端到端验证(必须)
|
|
@@ -88,7 +88,7 @@ export const fullAnalysisPrompt = `
|
|
|
88
88
|
3. **必须在最终输出中告知用户文件保存路径**
|
|
89
89
|
|
|
90
90
|
**调用 save_analysis_report 的前提条件**(必须全部满足):
|
|
91
|
-
1. 已使用 \`
|
|
91
|
+
1. 已使用 \`run_python_code\` 或 \`verify_with_python\` 验证代码能正确运行
|
|
92
92
|
2. 验证结果与预期一致
|
|
93
93
|
3. 已用 \`artifact_save\` 保存代码文件
|
|
94
94
|
|
package/src/agent/setup.js
CHANGED
|
@@ -35,21 +35,15 @@ export function ensureConfig() {
|
|
|
35
35
|
|
|
36
36
|
配置方式(任选其一):
|
|
37
37
|
|
|
38
|
-
1.
|
|
38
|
+
1. 配置环境变量(推荐):
|
|
39
39
|
export DEEPSPIDER_API_KEY=sk-xxx
|
|
40
40
|
export DEEPSPIDER_BASE_URL=https://api.openai.com/v1
|
|
41
41
|
export DEEPSPIDER_MODEL=gpt-4o
|
|
42
42
|
|
|
43
|
-
2.
|
|
44
|
-
|
|
45
|
-
# 编辑 .env 填入配置
|
|
43
|
+
2. 一行命令:
|
|
44
|
+
DEEPSPIDER_API_KEY=sk-xxx DEEPSPIDER_BASE_URL=https://api.openai.com/v1 DEEPSPIDER_MODEL=gpt-4o deepspider <url>
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
DEEPSPIDER_API_KEY=sk-xxx DEEPSPIDER_BASE_URL=https://api.openai.com/v1 DEEPSPIDER_MODEL=gpt-4o npx deepspider <url>
|
|
49
|
-
|
|
50
|
-
常用供应商配置:
|
|
51
|
-
OpenAI: BASE_URL=https://api.openai.com/v1 MODEL=gpt-4o
|
|
52
|
-
DeepSeek: BASE_URL=https://api.deepseek.com/v1 MODEL=deepseek-chat
|
|
46
|
+
请根据提示补全配置后重试。
|
|
53
47
|
`);
|
|
54
48
|
|
|
55
49
|
return false;
|
|
@@ -465,19 +465,19 @@ export const generatePythonCrypto = tool(
|
|
|
465
465
|
);
|
|
466
466
|
|
|
467
467
|
/**
|
|
468
|
-
* 执行 Python
|
|
468
|
+
* 执行 Python 代码
|
|
469
469
|
*/
|
|
470
470
|
export const executePythonCode = tool(
|
|
471
471
|
async ({ code, timeout }) => {
|
|
472
|
-
const result = await executePython(code, timeout ||
|
|
472
|
+
const result = await executePython(code, timeout || 30000);
|
|
473
473
|
return JSON.stringify(result);
|
|
474
474
|
},
|
|
475
475
|
{
|
|
476
|
-
name: '
|
|
477
|
-
description: '
|
|
476
|
+
name: 'run_python_code',
|
|
477
|
+
description: '执行 Python 代码。可用于加密验证、HTTP 请求、数据处理等任务。环境已预装 pycryptodome、requests 等常用库。',
|
|
478
478
|
schema: z.object({
|
|
479
|
-
code: z.string().describe('
|
|
480
|
-
timeout: z.number().optional().default(
|
|
479
|
+
code: z.string().describe('Python 代码'),
|
|
480
|
+
timeout: z.number().optional().default(30000).describe('超时时间(毫秒)'),
|
|
481
481
|
}),
|
|
482
482
|
}
|
|
483
483
|
);
|
|
@@ -129,9 +129,8 @@ export const saveAnalysisReport = tool(
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
// 保存 Markdown
|
|
132
|
+
// 保存 Markdown(先收集所有路径,最后追加文件列表)
|
|
133
133
|
paths.markdown = join(domainDir, 'analysis.md');
|
|
134
|
-
writeFileSync(paths.markdown, markdown, 'utf-8');
|
|
135
134
|
|
|
136
135
|
// 保存 Python 代码
|
|
137
136
|
if (finalPythonCode) {
|
|
@@ -150,6 +149,13 @@ export const saveAnalysisReport = tool(
|
|
|
150
149
|
const html = generateHtmlPage(title || domain, markdown, finalPythonCode, finalJsCode);
|
|
151
150
|
writeFileSync(paths.html, html, 'utf-8');
|
|
152
151
|
|
|
152
|
+
// 在 markdown 末尾自动追加生成文件列表
|
|
153
|
+
const fileList = Object.entries(paths)
|
|
154
|
+
.map(([type, p]) => `- ${type}: \`${p}\``)
|
|
155
|
+
.join('\n');
|
|
156
|
+
const finalMarkdown = markdown + '\n\n## 生成文件\n\n' + fileList;
|
|
157
|
+
writeFileSync(paths.markdown, finalMarkdown, 'utf-8');
|
|
158
|
+
|
|
153
159
|
console.log('[report] 已保存:', domainDir);
|
|
154
160
|
return JSON.stringify({ success: true, paths, dir: domainDir });
|
|
155
161
|
} catch (e) {
|