@liangjiehappy/dsh-plugin-cadpop 0.0.0-stage → 0.1.1
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 +44 -2
- package/README.zh-CN.md +43 -0
- package/cordis.patch.yml +5 -0
- package/lib/core.js +55 -0
- package/lib/index.js +85 -0
- package/package.json +36 -4
package/README.md
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-plugin-cadpop
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Read-only CADPOP entry tools for DeepSeek Harness: parametric templates, help center, DFM entry, online editor, and drawing tools.
|
|
4
|
+
|
|
5
|
+
中文说明见 [README.zh-CN.md](README.zh-CN.md).
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Purpose |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `cadpop_templates` | List parametric templates |
|
|
12
|
+
| `cadpop_help` | Open a help topic |
|
|
13
|
+
| `cadpop_dfm` | DFM manufacturability/quotation entry |
|
|
14
|
+
| `cadpop_app` | Online CAD editor entry |
|
|
15
|
+
| `cadpop_tools` | Drawing tools collection page |
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
dsh plugin --profile web add @liangjiehappy/dsh-plugin-cadpop
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Config
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
- insert:
|
|
27
|
+
- id: dsh-plugin-cadpop
|
|
28
|
+
name: "@liangjiehappy/dsh-plugin-cadpop"
|
|
29
|
+
config:
|
|
30
|
+
baseUrl: "https://cadpop.com"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Zero-config works; the default base URL is `https://cadpop.com`.
|
|
34
|
+
|
|
35
|
+
## Permissions
|
|
36
|
+
|
|
37
|
+
- Outbound HTTPS GET to `cadpop.com` only (configurable `baseUrl`)
|
|
38
|
+
- No file reads or writes, no credential access, no shell
|
|
39
|
+
- Read-only: no drawing upload, no payment
|
|
40
|
+
|
|
41
|
+
## Limitations
|
|
42
|
+
|
|
43
|
+
- No automatic pricing: DFM prices come from the page, never promised by the AI
|
|
44
|
+
- Template list is parsed from `/help/templates/`; page redesigns may affect parsing
|
|
45
|
+
- Drawing generation belongs to the site/other plugins, not this one
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# dsh-plugin-cadpop
|
|
2
|
+
|
|
3
|
+
CADPOP(cadpop.com)只读入口插件:参数化模板清单、帮助中心、DFM 入口、在线编辑器、图纸工具页。
|
|
4
|
+
|
|
5
|
+
English docs: [README.md](README.md).
|
|
6
|
+
|
|
7
|
+
## 工具
|
|
8
|
+
|
|
9
|
+
| 工具 | 作用 |
|
|
10
|
+
|---|---|
|
|
11
|
+
| `cadpop_templates` | 列出参数化模板 |
|
|
12
|
+
| `cadpop_help` | 打开帮助主题 |
|
|
13
|
+
| `cadpop_dfm` | DFM 制造分析/报价入口 |
|
|
14
|
+
| `cadpop_app` | 在线 CAD 编辑器入口 |
|
|
15
|
+
| `cadpop_tools` | 图纸工具集合页 |
|
|
16
|
+
|
|
17
|
+
## 安装
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
dsh plugin --profile web add @liangjiehappy/dsh-plugin-cadpop
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 配置
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
- insert:
|
|
27
|
+
- id: dsh-plugin-cadpop
|
|
28
|
+
name: "@liangjiehappy/dsh-plugin-cadpop"
|
|
29
|
+
config:
|
|
30
|
+
baseUrl: "https://cadpop.com"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 权限声明
|
|
34
|
+
|
|
35
|
+
- 只对 `cadpop.com` 发 HTTPS GET
|
|
36
|
+
- 不读写文件、不读凭证、不执行 shell
|
|
37
|
+
- 只读:不上传图纸、不发起支付
|
|
38
|
+
|
|
39
|
+
## 限制
|
|
40
|
+
|
|
41
|
+
- 不自动报价:DFM 价格以页面结果为准
|
|
42
|
+
- 模板清单从 `/help/templates/` 解析,页面改版可能影响解析
|
|
43
|
+
- 生成图纸等能力属于 cadpop 站内/其它插件,不在本插件范围
|
package/cordis.patch.yml
ADDED
package/lib/core.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// dsh-plugin-cadpop · 纯函数:帮助路径、HTML 标题与模板清单解析
|
|
2
|
+
export const DEFAULT_BASE = 'https://cadpop.com'
|
|
3
|
+
|
|
4
|
+
export function normalizeBase(base) {
|
|
5
|
+
const b = (base || DEFAULT_BASE).trim().replace(/\/+$/, '')
|
|
6
|
+
if (!/^https?:\/\//i.test(b)) throw new Error('baseUrl 必须以 http(s):// 开头')
|
|
7
|
+
return b
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function slugify(s) {
|
|
11
|
+
return String(s || '')
|
|
12
|
+
.trim()
|
|
13
|
+
.toLowerCase()
|
|
14
|
+
.replace(/[\s_]+/g, '-')
|
|
15
|
+
.replace(/[^a-z0-9\u4e00-\u9fa5-]+/g, '')
|
|
16
|
+
.replace(/-+/g, '-')
|
|
17
|
+
.replace(/^-|-$/g, '')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function buildHelpUrl(base, topic) {
|
|
21
|
+
const slug = slugify(topic)
|
|
22
|
+
if (!slug) throw new Error('topic 不能为空')
|
|
23
|
+
return normalizeBase(base) + '/help/' + slug + '/'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function extractTitle(html) {
|
|
27
|
+
const m = String(html || '').match(/<title[^>]*>([\s\S]*?)<\/title>/i)
|
|
28
|
+
if (!m) return ''
|
|
29
|
+
return decodeEntities(m[1]).replace(/\s+/g, ' ').trim().slice(0, 200)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function decodeEntities(s) {
|
|
33
|
+
return String(s)
|
|
34
|
+
.replace(/&/g, '&')
|
|
35
|
+
.replace(/</g, '<')
|
|
36
|
+
.replace(/>/g, '>')
|
|
37
|
+
.replace(/"/g, '"')
|
|
38
|
+
.replace(/'|'/g, "'")
|
|
39
|
+
.replace(/ /g, ' ')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 从 help/templates 页面提取模板清单(<li> 文本) */
|
|
43
|
+
export function parseTemplates(html) {
|
|
44
|
+
const out = []
|
|
45
|
+
const re = /<li[^>]*>([\s\S]*?)<\/li>/gi
|
|
46
|
+
let m
|
|
47
|
+
while ((m = re.exec(String(html || ''))) !== null) {
|
|
48
|
+
const t = decodeEntities(m[1].replace(/<[^>]+>/g, '')).replace(/\s+/g, ' ').trim()
|
|
49
|
+
if (!t || t.length > 120) continue
|
|
50
|
+
if (!/[((]/.test(t)) continue
|
|
51
|
+
out.push(t)
|
|
52
|
+
if (out.length >= 30) break
|
|
53
|
+
}
|
|
54
|
+
return [...new Set(out)]
|
|
55
|
+
}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// dsh-plugin-cadpop · cadpop.com 只读入口与帮助中心工具
|
|
2
|
+
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_BASE, normalizeBase, buildHelpUrl, extractTitle, parseTemplates,
|
|
5
|
+
} from './core.js'
|
|
6
|
+
|
|
7
|
+
export const name = 'dsh-plugin-cadpop'
|
|
8
|
+
export const inject = ['tools']
|
|
9
|
+
|
|
10
|
+
const text = (value) => [{ type: 'text', text: JSON.stringify(value, null, 2) }]
|
|
11
|
+
const headers = { 'user-agent': 'dsh-plugin-cadpop/0.1', accept: 'text/html' }
|
|
12
|
+
|
|
13
|
+
export function apply(ctx, config = {}) {
|
|
14
|
+
const base = normalizeBase(config.baseUrl)
|
|
15
|
+
|
|
16
|
+
async function fetchPage(path, signal) {
|
|
17
|
+
const url = base + path
|
|
18
|
+
const r = await fetch(url, { headers, signal, redirect: 'follow' })
|
|
19
|
+
const html = await r.text()
|
|
20
|
+
return { status: r.status, ok: r.ok, url: r.url || url, title: extractTitle(html), html }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
ctx.tools.register(defineTool({
|
|
24
|
+
name: 'cadpop_templates',
|
|
25
|
+
description: '列出 CADPOP 参数化模板(法兰/支架/外壳/齿轮等),返回模板名与帮助页链接。',
|
|
26
|
+
parameters: {},
|
|
27
|
+
output: { schema: { type: 'json' }, render: (_a, v) => text(v) },
|
|
28
|
+
isConcurrencySafe: () => true,
|
|
29
|
+
async execute(_args, exec) {
|
|
30
|
+
const page = await fetchPage('/help/templates/', exec.signal)
|
|
31
|
+
const templates = parseTemplates(page.html)
|
|
32
|
+
return { status: page.status, ok: page.ok, url: page.url, count: templates.length, templates }
|
|
33
|
+
},
|
|
34
|
+
}))
|
|
35
|
+
|
|
36
|
+
ctx.tools.register(defineTool({
|
|
37
|
+
name: 'cadpop_help',
|
|
38
|
+
description: '打开 CADPOP 帮助中心指定主题(如 templates、getting-started、save-export),返回标题与链接。',
|
|
39
|
+
parameters: {
|
|
40
|
+
topic: { type: 'string', required: true, description: '帮助主题 slug,如 templates' },
|
|
41
|
+
},
|
|
42
|
+
output: { schema: { type: 'json' }, render: (_a, v) => text(v) },
|
|
43
|
+
isConcurrencySafe: () => true,
|
|
44
|
+
async execute(args, exec) {
|
|
45
|
+
const url = buildHelpUrl(base, args.topic)
|
|
46
|
+
const r = await fetch(url, { headers, signal: exec.signal, redirect: 'follow' })
|
|
47
|
+
const html = await r.text()
|
|
48
|
+
return { status: r.status, ok: r.ok, url: r.url || url, title: extractTitle(html) }
|
|
49
|
+
},
|
|
50
|
+
}))
|
|
51
|
+
|
|
52
|
+
ctx.tools.register(defineTool({
|
|
53
|
+
name: 'cadpop_dfm',
|
|
54
|
+
description: '返回 CADPOP DFM 制造分析/报价入口(人工确认价格,不自动报价)。',
|
|
55
|
+
parameters: {},
|
|
56
|
+
output: { schema: { type: 'json' }, render: (_a, v) => text(v) },
|
|
57
|
+
isConcurrencySafe: () => true,
|
|
58
|
+
async execute() {
|
|
59
|
+
return { url: base + '/dfm/', note: '上传 DXF/STEP 获取可制造性检查与报价;价格以页面结果为准,不由 AI 承诺。' }
|
|
60
|
+
},
|
|
61
|
+
}))
|
|
62
|
+
|
|
63
|
+
ctx.tools.register(defineTool({
|
|
64
|
+
name: 'cadpop_app',
|
|
65
|
+
description: '返回 CADPOP 在线 CAD 编辑器入口(浏览器打开,可导入图纸手工修改)。',
|
|
66
|
+
parameters: {},
|
|
67
|
+
output: { schema: { type: 'json' }, render: (_a, v) => text(v) },
|
|
68
|
+
isConcurrencySafe: () => true,
|
|
69
|
+
async execute() {
|
|
70
|
+
return { url: base + '/app/', note: '在编辑器里可打开 DXF/DWG、改图、导出;与对话式生成共用同一套模板概念。' }
|
|
71
|
+
},
|
|
72
|
+
}))
|
|
73
|
+
|
|
74
|
+
ctx.tools.register(defineTool({
|
|
75
|
+
name: 'cadpop_tools',
|
|
76
|
+
description: '返回 CADPOP 工具集合页(DWG→DXF、DXF→PDF、BOM 导出等)标题与链接。',
|
|
77
|
+
parameters: {},
|
|
78
|
+
output: { schema: { type: 'json' }, render: (_a, v) => text(v) },
|
|
79
|
+
isConcurrencySafe: () => true,
|
|
80
|
+
async execute(_args, exec) {
|
|
81
|
+
const page = await fetchPage('/tools/', exec.signal)
|
|
82
|
+
return { status: page.status, ok: page.ok, url: page.url, title: page.title }
|
|
83
|
+
},
|
|
84
|
+
}))
|
|
85
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liangjiehappy/dsh-plugin-cadpop",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "CADPOP 在线 CAD 工具入口:模板清单、帮助中心、DFM 制造分析、编辑器与图纸工具页。只访问 cadpop.com。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"cordis.patch.yml",
|
|
10
|
+
"README.md",
|
|
11
|
+
"README.zh-CN.md"
|
|
12
|
+
],
|
|
13
|
+
"dsh": {
|
|
14
|
+
"bundle": {
|
|
15
|
+
"patch": "./cordis.patch.yml"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"dsh": ">=0.2.0"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@deepseek-ai/cordis": "*",
|
|
23
|
+
"@deepseek-ai/dsh-tools": "*"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"deepseek-harness",
|
|
27
|
+
"dsh",
|
|
28
|
+
"dsh-plugin",
|
|
29
|
+
"cadpop",
|
|
30
|
+
"cad",
|
|
31
|
+
"dxf",
|
|
32
|
+
"dfm"
|
|
33
|
+
],
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"scripts": {
|
|
36
|
+
"test": "node --test"
|
|
37
|
+
}
|
|
38
|
+
}
|