pdd-skills 3.0.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/README.md +1478 -0
- package/bin/pdd.js +354 -0
- package/config/bpmn-rules.yaml +166 -0
- package/config/checkstyle.xml +105 -0
- package/config/eslint.config.js +48 -0
- package/config/pmd.xml +91 -0
- package/config/prd-rules.yaml +113 -0
- package/config/ruff.toml +45 -0
- package/config/sqlfluff.cfg +82 -0
- package/hooks/hook-executor.js +332 -0
- package/index.js +43 -0
- package/lib/api-routes.js +750 -0
- package/lib/api-server.js +408 -0
- package/lib/cache/cache-config.js +209 -0
- package/lib/cache/system-cache.js +852 -0
- package/lib/config-manager.js +373 -0
- package/lib/generate.js +528 -0
- package/lib/grpc/grpc-routes.js +1134 -0
- package/lib/grpc/grpc-server.js +912 -0
- package/lib/grpc/proto-definitions.js +1033 -0
- package/lib/init.js +172 -0
- package/lib/iteration/auto-fixer.js +1025 -0
- package/lib/iteration/auto-reviewer.js +923 -0
- package/lib/iteration/controller.js +577 -0
- package/lib/list.js +130 -0
- package/lib/mcp-server.js +548 -0
- package/lib/openclaw/api-integration.js +535 -0
- package/lib/openclaw/cli-integration.js +567 -0
- package/lib/openclaw/data-sync.js +845 -0
- package/lib/openclaw/openclaw-adapter.js +783 -0
- package/lib/plugin/example-plugins/code-stats/index.js +332 -0
- package/lib/plugin/example-plugins/code-stats/plugin.json +1 -0
- package/lib/plugin/example-plugins/custom-linter/index.js +472 -0
- package/lib/plugin/example-plugins/custom-linter/plugin.json +1 -0
- package/lib/plugin/example-plugins/hello-world/index.js +86 -0
- package/lib/plugin/example-plugins/hello-world/plugin.json +1 -0
- package/lib/plugin/plugin-manager.js +655 -0
- package/lib/plugin/plugin-sdk.js +565 -0
- package/lib/plugin/sandbox.js +627 -0
- package/lib/quality/rules/maintainability.js +418 -0
- package/lib/quality/rules/performance.js +498 -0
- package/lib/quality/rules/readability.js +441 -0
- package/lib/quality/rules/robustness.js +504 -0
- package/lib/quality/rules/security.js +444 -0
- package/lib/quality/scorer.js +576 -0
- package/lib/report.js +669 -0
- package/lib/sdk-base.js +301 -0
- package/lib/sdk-js.js +446 -0
- package/lib/sdk-python/README.md +546 -0
- package/lib/sdk-python/examples/basic_usage.py +450 -0
- package/lib/sdk-python/pdd_sdk/__init__.py +180 -0
- package/lib/sdk-python/pdd_sdk/client.py +1170 -0
- package/lib/sdk-python/pdd_sdk/events.py +423 -0
- package/lib/sdk-python/pdd_sdk/exceptions.py +158 -0
- package/lib/sdk-python/pdd_sdk/models.py +518 -0
- package/lib/sdk-python/pdd_sdk/utils.py +759 -0
- package/lib/token/budget-alert.js +367 -0
- package/lib/token/budget-manager.js +485 -0
- package/lib/update.js +54 -0
- package/lib/utils/logger.js +88 -0
- package/lib/verify.js +741 -0
- package/lib/version.js +52 -0
- package/lib/vm/README.md +102 -0
- package/lib/vm/dashboard/api-routes.js +669 -0
- package/lib/vm/dashboard/server.js +391 -0
- package/lib/vm/dashboard/sse.js +358 -0
- package/lib/vm/dashboard/static/css/dashboard.css +1378 -0
- package/lib/vm/dashboard/static/index.html +118 -0
- package/lib/vm/dashboard/static/js/app.js +949 -0
- package/lib/vm/dashboard/static/js/charts.js +913 -0
- package/lib/vm/dashboard/static/js/kanban-view.js +1053 -0
- package/lib/vm/dashboard/static/js/pipeline-view.js +463 -0
- package/lib/vm/dashboard/static/js/quality-view.js +598 -0
- package/lib/vm/dashboard/static/js/system-view.js +1021 -0
- package/lib/vm/data-provider.js +1191 -0
- package/lib/vm/event-bus.js +402 -0
- package/lib/vm/hooks/extract-hook.js +307 -0
- package/lib/vm/hooks/generate-hook.js +374 -0
- package/lib/vm/hooks/hook-interface.js +458 -0
- package/lib/vm/hooks/report-hook.js +331 -0
- package/lib/vm/hooks/verify-hook.js +454 -0
- package/lib/vm/models.js +1003 -0
- package/lib/vm/reconciler.js +855 -0
- package/lib/vm/scanner.js +988 -0
- package/lib/vm/state-schema.js +955 -0
- package/lib/vm/state-store.js +733 -0
- package/lib/vm/tui/components/card.js +339 -0
- package/lib/vm/tui/components/progress-bar.js +368 -0
- package/lib/vm/tui/components/sparkline.js +327 -0
- package/lib/vm/tui/components/status-light.js +294 -0
- package/lib/vm/tui/components/table.js +370 -0
- package/lib/vm/tui/input.js +335 -0
- package/lib/vm/tui/renderer.js +548 -0
- package/lib/vm/tui/screens/kanban-screen.js +397 -0
- package/lib/vm/tui/screens/overview-screen.js +357 -0
- package/lib/vm/tui/screens/quality-screen.js +336 -0
- package/lib/vm/tui/screens/system-screen.js +379 -0
- package/lib/vm/tui/tui.js +805 -0
- package/package.json +1 -0
- package/scripts/cso-analyzer.js +198 -0
- package/scripts/eval-runner.js +359 -0
- package/scripts/i18n-checker.js +109 -0
- package/scripts/linter/activiti-linter.js +272 -0
- package/scripts/linter/prd-linter.js +162 -0
- package/scripts/linter/report-generator.js +207 -0
- package/scripts/linter/run-linters.js +285 -0
- package/scripts/linter/sql-linter.js +166 -0
- package/scripts/token-analyzer.js +162 -0
- package/scripts/vm-test.js +180 -0
- package/skills/core/official-doc-writer/LICENSE +21 -0
- package/skills/core/official-doc-writer/README.md +232 -0
- package/skills/core/official-doc-writer/SKILL.md +475 -0
- package/skills/core/official-doc-writer/_meta.json +1 -0
- package/skills/core/official-doc-writer/document_generator.py +580 -0
- package/skills/core/official-doc-writer/evals/default-evals.json +1 -0
- package/skills/core/official-doc-writer/examples.md +150 -0
- package/skills/core/official-doc-writer/fonts/FONTS_LIST.md +45 -0
- package/skills/core/official-doc-writer/fonts/README.md +141 -0
- package/skills/core/official-doc-writer/fonts/SIMFANG.TTF +0 -0
- package/skills/core/official-doc-writer/fonts/SIMHEI.TTF +0 -0
- package/skills/core/official-doc-writer/fonts/SIMKAI.TTF +0 -0
- package/skills/core/official-doc-writer/fonts/SIMSUN.TTC +0 -0
- package/skills/core/official-doc-writer/fonts//346/226/271/346/255/243/345/260/217/346/240/207/345/256/213GBK.TTF +0 -0
- package/skills/core/official-doc-writer/references/GBT_9704-2012_/345/205/232/346/224/277/346/234/272/345/205/263/345/205/254/346/226/207/346/240/274/345/274/217.md +422 -0
- package/skills/core/official-doc-writer/scripts/__pycache__/generate_official_doc.cpython-313.pyc +0 -0
- package/skills/core/official-doc-writer/scripts/dialog_manager.py +564 -0
- package/skills/core/official-doc-writer/scripts/generate_official_doc.py +252 -0
- package/skills/core/official-doc-writer/scripts/install_fonts.py +390 -0
- package/skills/core/official-doc-writer/scripts/smart_prompts.py +363 -0
- package/skills/core/pdd-ba/SKILL.md +305 -0
- package/skills/core/pdd-ba/_meta.json +1 -0
- package/skills/core/pdd-ba/evals/default-evals.json +1 -0
- package/skills/core/pdd-code-reviewer/SKILL.md +378 -0
- package/skills/core/pdd-code-reviewer/_meta.json +1 -0
- package/skills/core/pdd-code-reviewer/evals/default-evals.json +1 -0
- package/skills/core/pdd-doc-change/SKILL.md +350 -0
- package/skills/core/pdd-doc-change/_meta.json +1 -0
- package/skills/core/pdd-doc-change/evals/default-evals.json +1 -0
- package/skills/core/pdd-doc-gardener/SKILL.md +248 -0
- package/skills/core/pdd-doc-gardener/_meta.json +1 -0
- package/skills/core/pdd-doc-gardener/evals/default-evals.json +1 -0
- package/skills/core/pdd-entropy-reduction/SKILL.md +360 -0
- package/skills/core/pdd-entropy-reduction/_meta.json +1 -0
- package/skills/core/pdd-entropy-reduction/evals/default-evals.json +1 -0
- package/skills/core/pdd-entropy-reduction/references/entropy-report-template.md +287 -0
- package/skills/core/pdd-entropy-reduction/references/golden-principles.md +573 -0
- package/skills/core/pdd-entropy-reduction/scripts/entropy_scan.py +712 -0
- package/skills/core/pdd-extract-features/SKILL.md +320 -0
- package/skills/core/pdd-extract-features/_meta.json +1 -0
- package/skills/core/pdd-extract-features/evals/default-evals.json +1 -0
- package/skills/core/pdd-generate-spec/SKILL.md +418 -0
- package/skills/core/pdd-generate-spec/_meta.json +1 -0
- package/skills/core/pdd-generate-spec/evals/default-evals.json +1 -0
- package/skills/core/pdd-implement-feature/SKILL.md +332 -0
- package/skills/core/pdd-implement-feature/_meta.json +1 -0
- package/skills/core/pdd-implement-feature/evals/default-evals.json +1 -0
- package/skills/core/pdd-main/SKILL.md +540 -0
- package/skills/core/pdd-main/_meta.json +1 -0
- package/skills/core/pdd-main/evals/default-evals.json +1 -0
- package/skills/core/pdd-main/evals/evals.json +215 -0
- package/skills/core/pdd-verify-feature/SKILL.md +474 -0
- package/skills/core/pdd-verify-feature/_meta.json +1 -0
- package/skills/core/pdd-verify-feature/evals/default-evals.json +1 -0
- package/skills/core/pdd-vm/evals/default-evals.json +1 -0
- package/skills/core/traffic-accident-assessor/LICENSE +29 -0
- package/skills/core/traffic-accident-assessor/SKILL.md +439 -0
- package/skills/core/traffic-accident-assessor/evals/evals.json +1 -0
- package/skills/core/traffic-accident-assessor/references/accident-types.md +369 -0
- package/skills/core/traffic-accident-assessor/references/liability-rules.md +287 -0
- package/skills/core/traffic-accident-assessor/references/traffic-laws.md +226 -0
- package/skills/core/traffic-accident-assessor/references//351/253/230/345/260/224/345/244/253/350/257/264/346/230/216/344/271/246.pdf +32576 -106
- package/skills/core/traffic-accident-assessor/scripts/generate_official_statement.py +588 -0
- package/skills/core/traffic-accident-assessor/scripts/generate_report.py +495 -0
- package/skills/core/traffic-accident-assessor/scripts/generate_statement.py +528 -0
- package/skills/core/traffic-accident-assessor.zip +0 -0
- package/skills/entropy/expert-arch-enforcer/SKILL.md +292 -0
- package/skills/entropy/expert-arch-enforcer/_meta.json +1 -0
- package/skills/entropy/expert-arch-enforcer/evals/default-evals.json +1 -0
- package/skills/entropy/expert-auto-refactor/SKILL.md +327 -0
- package/skills/entropy/expert-auto-refactor/_meta.json +1 -0
- package/skills/entropy/expert-auto-refactor/evals/default-evals.json +1 -0
- package/skills/entropy/expert-code-quality/SKILL.md +468 -0
- package/skills/entropy/expert-code-quality/_meta.json +1 -0
- package/skills/entropy/expert-code-quality/evals/default-evals.json +1 -0
- package/skills/entropy/expert-code-quality/evals/evals.json +109 -0
- package/skills/entropy/expert-code-quality/references/code-smells.md +605 -0
- package/skills/entropy/expert-code-quality/references/design-patterns.md +1111 -0
- package/skills/entropy/expert-code-quality/references/refactoring-catalog.md +1281 -0
- package/skills/entropy/expert-code-quality/references/solid-principles.md +524 -0
- package/skills/entropy/expert-entropy-auditor/SKILL.md +276 -0
- package/skills/entropy/expert-entropy-auditor/_meta.json +1 -0
- package/skills/entropy/expert-entropy-auditor/evals/default-evals.json +1 -0
- package/skills/expert/expert-activiti/SKILL.md +497 -0
- package/skills/expert/expert-activiti/_meta.json +1 -0
- package/skills/expert/expert-mysql/SKILL.md +832 -0
- package/skills/expert/expert-mysql/_meta.json +1 -0
- package/skills/expert/expert-performance/SKILL.md +379 -0
- package/skills/expert/expert-performance/_meta.json +1 -0
- package/skills/expert/expert-performance/evals/default-evals.json +1 -0
- package/skills/expert/expert-ruoyi/SKILL.md +472 -0
- package/skills/expert/expert-ruoyi/_meta.json +1 -0
- package/skills/expert/expert-security/SKILL.md +1341 -0
- package/skills/expert/expert-security/_meta.json +1 -0
- package/skills/expert/expert-security/evals/default-evals.json +1 -0
- package/skills/expert/software-architect/SKILL.md +350 -0
- package/skills/expert/software-architect/_meta.json +1 -0
- package/skills/expert/software-engineer/SKILL.md +437 -0
- package/skills/expert/software-engineer/_meta.json +1 -0
- package/skills/expert/software-engineer/architecture.md +130 -0
- package/skills/expert/software-engineer/patterns.md +151 -0
- package/skills/expert/software-engineer/testing.md +135 -0
- package/skills/expert/system-architect/SKILL.md +628 -0
- package/skills/expert/system-architect/_meta.json +1 -0
- package/skills/expert/system-architect/assets/templates/ARCHITECTURE.md +25 -0
- package/skills/expert/system-architect/assets/templates/README.md +44 -0
- package/skills/expert/system-architect/references/js-ts-standards.md +18 -0
- package/skills/expert/system-architect/references/python-standards.md +19 -0
- package/skills/expert/system-architect/references/scaffolding.md +61 -0
- package/skills/expert/system-architect/references/security-checklist.md +21 -0
- package/skills/openspec/openspec-apply-change/SKILL.md +156 -0
- package/skills/openspec/openspec-apply-change/_meta.json +1 -0
- package/skills/openspec/openspec-archive-change/SKILL.md +114 -0
- package/skills/openspec/openspec-archive-change/_meta.json +1 -0
- package/skills/openspec/openspec-bulk-archive-change/SKILL.md +246 -0
- package/skills/openspec/openspec-bulk-archive-change/_meta.json +1 -0
- package/skills/openspec/openspec-continue-change/SKILL.md +118 -0
- package/skills/openspec/openspec-continue-change/_meta.json +1 -0
- package/skills/openspec/openspec-explore/SKILL.md +288 -0
- package/skills/openspec/openspec-explore/_meta.json +1 -0
- package/skills/openspec/openspec-ff-change/SKILL.md +101 -0
- package/skills/openspec/openspec-ff-change/_meta.json +1 -0
- package/skills/openspec/openspec-new-change/SKILL.md +74 -0
- package/skills/openspec/openspec-new-change/_meta.json +1 -0
- package/skills/openspec/openspec-onboard/SKILL.md +554 -0
- package/skills/openspec/openspec-onboard/_meta.json +1 -0
- package/skills/openspec/openspec-sync-specs/SKILL.md +138 -0
- package/skills/openspec/openspec-sync-specs/_meta.json +1 -0
- package/skills/openspec/openspec-verify-change/SKILL.md +168 -0
- package/skills/openspec/openspec-verify-change/_meta.json +1 -0
- package/skills/pr/pdd-multi-review/SKILL.md +534 -0
- package/skills/pr/pdd-multi-review/_meta.json +1 -0
- package/skills/pr/pdd-pr-batch/SKILL.md +303 -0
- package/skills/pr/pdd-pr-batch/_meta.json +1 -0
- package/skills/pr/pdd-pr-create/SKILL.md +344 -0
- package/skills/pr/pdd-pr-create/_meta.json +1 -0
- package/skills/pr/pdd-pr-merge/SKILL.md +286 -0
- package/skills/pr/pdd-pr-merge/_meta.json +1 -0
- package/skills/pr/pdd-pr-review/SKILL.md +217 -0
- package/skills/pr/pdd-pr-review/_meta.json +1 -0
- package/skills/pr/pdd-task-manager/SKILL.md +636 -0
- package/skills/pr/pdd-task-manager/_meta.json +1 -0
- package/skills/pr/pdd-template-engine/SKILL.md +306 -0
- package/skills/pr/pdd-template-engine/_meta.json +1 -0
- package/templates/behavior-shaping/iron-law-template.md +87 -0
- package/templates/behavior-shaping/rationalization-template.md +62 -0
- package/templates/behavior-shaping/red-flags-template.md +70 -0
- package/templates/bilingual-template.md +139 -0
- package/templates/config/default.yaml +47 -0
- package/templates/project/default/README.md +31 -0
- package/templates/project/frontend/README.md +46 -0
- package/templates/project/java/README.md +48 -0
package/lib/sdk-base.js
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
// lib/sdk-base.js - PDD SDK Base Class
|
|
2
|
+
// 提供统一的SDK接口,支持Python/JavaScript等多语言扩展
|
|
3
|
+
|
|
4
|
+
import { log } from './utils/logger.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* PDD SDK 基础类
|
|
8
|
+
* 定义了PDD核心API的统一接口,所有语言SDK都应实现这些方法
|
|
9
|
+
*/
|
|
10
|
+
export class PDDSDKBase {
|
|
11
|
+
/**
|
|
12
|
+
* 构造函数
|
|
13
|
+
* @param {Object} config - 配置对象
|
|
14
|
+
* @param {string} config.endpoint - API端点地址
|
|
15
|
+
* @param {string} config.apiKey - API密钥
|
|
16
|
+
* @param {number} config.timeout - 请求超时时间(毫秒)
|
|
17
|
+
* @param {boolean} config.debug - 调试模式
|
|
18
|
+
*/
|
|
19
|
+
constructor(config = {}) {
|
|
20
|
+
this.endpoint = config.endpoint || 'http://localhost:3000';
|
|
21
|
+
this.apiKey = config.apiKey || '';
|
|
22
|
+
this.timeout = config.timeout || 30000;
|
|
23
|
+
this.debug = config.debug || false;
|
|
24
|
+
|
|
25
|
+
// 验证配置
|
|
26
|
+
this._validateConfig();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 验证配置参数
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
_validateConfig() {
|
|
34
|
+
if (!this.endpoint) {
|
|
35
|
+
throw new Error('Endpoint is required');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
new URL(this.endpoint);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
throw new Error(`Invalid endpoint URL: ${this.endpoint}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 构建请求头
|
|
47
|
+
* @private
|
|
48
|
+
* @returns {Object} 请求头对象
|
|
49
|
+
*/
|
|
50
|
+
_buildHeaders() {
|
|
51
|
+
const headers = {
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
'Accept': 'application/json'
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
if (this.apiKey) {
|
|
57
|
+
headers['Authorization'] = `Bearer ${this.apiKey}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return headers;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 发送HTTP请求的通用方法(基类提供默认实现,子类可覆盖)
|
|
65
|
+
* @protected
|
|
66
|
+
* @param {string} method - HTTP方法
|
|
67
|
+
* @param {string} path - API路径
|
|
68
|
+
* @param {Object} data - 请求数据
|
|
69
|
+
* @returns {Promise<Object>} 响应数据
|
|
70
|
+
*/
|
|
71
|
+
async _request(method, path, data = null) {
|
|
72
|
+
const url = `${this.endpoint}${path}`;
|
|
73
|
+
const options = {
|
|
74
|
+
method,
|
|
75
|
+
headers: this._buildHeaders()
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
if (data && method !== 'GET') {
|
|
79
|
+
options.body = JSON.stringify(data);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (this.debug) {
|
|
83
|
+
log('debug', `[SDK] ${method} ${url}`, data || '');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 基类使用fetch API(Node.js 18+内置),子类可根据需要替换为其他HTTP客户端
|
|
87
|
+
const controller = new AbortController();
|
|
88
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
const response = await fetch(url, { ...options, signal: controller.signal });
|
|
92
|
+
|
|
93
|
+
clearTimeout(timeoutId);
|
|
94
|
+
|
|
95
|
+
if (!response.ok) {
|
|
96
|
+
const errorBody = await response.text().catch(() => '');
|
|
97
|
+
throw new Error(
|
|
98
|
+
`HTTP ${response.status}: ${response.statusText} - ${errorBody}`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const result = await response.json();
|
|
103
|
+
|
|
104
|
+
if (this.debug) {
|
|
105
|
+
log('debug', `[SDK] Response from ${path}`, result);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return result;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
clearTimeout(timeoutId);
|
|
111
|
+
|
|
112
|
+
if (error.name === 'AbortError') {
|
|
113
|
+
throw new Error(`Request timeout after ${this.timeout}ms`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
log('error', `[SDK] Request failed: ${method} ${path}`, error.message);
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 生成开发规格文档
|
|
123
|
+
* POST /api/v1/spec
|
|
124
|
+
*
|
|
125
|
+
* @param {Object} featureMatrix - 功能点矩阵
|
|
126
|
+
* @param {string} featureMatrix.id - 功能点ID
|
|
127
|
+
* @param {string} featureMatrix.name - 功能点名称
|
|
128
|
+
* @param {Array} featureMatrix.requirements - 需求列表
|
|
129
|
+
* @param {Object} options - 可选参数
|
|
130
|
+
* @param {string} options.outputPath - 输出路径
|
|
131
|
+
* @param {boolean} options.includeTests - 是否包含测试用例
|
|
132
|
+
* @returns {Promise<Object>} 生成的规格文档
|
|
133
|
+
*/
|
|
134
|
+
async generateSpec(featureMatrix, options = {}) {
|
|
135
|
+
if (!featureMatrix || !featureMatrix.id) {
|
|
136
|
+
throw new Error('Feature matrix with id is required');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const payload = {
|
|
140
|
+
...featureMatrix,
|
|
141
|
+
options: {
|
|
142
|
+
includeTests: true,
|
|
143
|
+
...options
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
return this._request('POST', '/api/v1/spec', payload);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 生成代码
|
|
152
|
+
* POST /api/v1/generate
|
|
153
|
+
*
|
|
154
|
+
* @param {string} specPath - 规格文档路径
|
|
155
|
+
* @param {Object} options - 可选参数
|
|
156
|
+
* @param {string} options.targetDir - 目标目录
|
|
157
|
+
* @param {string} options.language - 编程语言
|
|
158
|
+
* @returns {Promise<Object>} 生成的代码信息
|
|
159
|
+
*/
|
|
160
|
+
async generateCode(specPath, options = {}) {
|
|
161
|
+
if (!specPath) {
|
|
162
|
+
throw new Error('Spec path is required');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return this._request('POST', '/api/v1/generate', {
|
|
166
|
+
specPath,
|
|
167
|
+
...options
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 验证功能点实现
|
|
173
|
+
* POST /api/v1/verify
|
|
174
|
+
*
|
|
175
|
+
* @param {Object} options - 验证选项
|
|
176
|
+
* @param {string} options.specPath - 规格文档路径
|
|
177
|
+
* @param {Array<string>} options.dimensions - 验证维度
|
|
178
|
+
* @param {string} options.targetPath - 目标代码路径
|
|
179
|
+
* @returns {Promise<Object>} 验证结果报告
|
|
180
|
+
*/
|
|
181
|
+
async verifyFeature(options = {}) {
|
|
182
|
+
if (!options.specPath) {
|
|
183
|
+
throw new Error('Spec path is required for verification');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return this._request('POST', '/api/v1/verify', {
|
|
187
|
+
dimensions: ['completeness', 'correctness', 'consistency'],
|
|
188
|
+
...options
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* 代码审查
|
|
194
|
+
* POST /api/v1/review
|
|
195
|
+
*
|
|
196
|
+
* @param {Object} options - 审查选项
|
|
197
|
+
* @param {string} options.targetPath - 审查目标路径
|
|
198
|
+
* @param {string} options.specPath - 规格文档路径(可选)
|
|
199
|
+
* @param {Array<string>} options.rules - 审查规则列表
|
|
200
|
+
* @returns {Promise<Object>} 审查报告
|
|
201
|
+
*/
|
|
202
|
+
async codeReview(options = {}) {
|
|
203
|
+
if (!options.targetPath) {
|
|
204
|
+
throw new Error('Target path is required for code review');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return this._request('POST', '/api/v1/review', {
|
|
208
|
+
rules: ['best-practices', 'security', 'performance'],
|
|
209
|
+
...options
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 获取项目状态
|
|
215
|
+
* GET /api/v1/status
|
|
216
|
+
*
|
|
217
|
+
* @returns {Promise<Object>} 项目状态信息
|
|
218
|
+
*/
|
|
219
|
+
async getStatus() {
|
|
220
|
+
return this._request('GET', '/api/v1/status');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 提取功能点矩阵
|
|
225
|
+
* POST /api/v1/features/extract
|
|
226
|
+
*
|
|
227
|
+
* @param {string} prdPath - PRD文档路径
|
|
228
|
+
* @param {Object} options - 提取选项
|
|
229
|
+
* @returns {Promise<Object>} 提取的功能点矩阵
|
|
230
|
+
*/
|
|
231
|
+
async extractFeatures(prdPath, options = {}) {
|
|
232
|
+
if (!prdPath) {
|
|
233
|
+
throw new Error('PRD path is required for feature extraction');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return this._request('POST', '/api/v1/features/extract', {
|
|
237
|
+
prdPath,
|
|
238
|
+
...options
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* 业务需求分析
|
|
244
|
+
* POST /api/v1/analyze/business
|
|
245
|
+
*
|
|
246
|
+
* @param {string} prdPath - PRD文档路径
|
|
247
|
+
* @param {Object} options - 分析选项
|
|
248
|
+
* @param {string} options.methodology - 分析方法论(5W1H等)
|
|
249
|
+
* @returns {Promise<Object>} 分析结果
|
|
250
|
+
*/
|
|
251
|
+
async analyzeBusiness(prdPath, options = {}) {
|
|
252
|
+
if (!prdPath) {
|
|
253
|
+
throw new Error('PRD path is required for business analysis');
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return this._request('POST', '/api/v1/analyze/business', {
|
|
257
|
+
prdPath,
|
|
258
|
+
methodology: '5W1H',
|
|
259
|
+
...options
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 测试连接是否正常
|
|
265
|
+
* GET /api/v1/health
|
|
266
|
+
*
|
|
267
|
+
* @returns {Promise<boolean>} 连接状态
|
|
268
|
+
*/
|
|
269
|
+
async healthCheck() {
|
|
270
|
+
try {
|
|
271
|
+
const response = await this._request('GET', '/api/v1/health');
|
|
272
|
+
return response.status === 'ok' || response.healthy === true;
|
|
273
|
+
} catch (error) {
|
|
274
|
+
log('error', '[SDK] Health check failed', error.message);
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 获取SDK版本信息
|
|
281
|
+
* @returns {Object} 版本信息
|
|
282
|
+
*/
|
|
283
|
+
getVersion() {
|
|
284
|
+
return {
|
|
285
|
+
name: 'pdd-sdk-base',
|
|
286
|
+
version: '3.0.0',
|
|
287
|
+
endpoint: this.endpoint
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* 创建SDK实例的工厂函数
|
|
294
|
+
* @param {Object} config - 配置对象
|
|
295
|
+
* @returns {PDDSDKBase} SDK实例
|
|
296
|
+
*/
|
|
297
|
+
export function createSDK(config = {}) {
|
|
298
|
+
return new PDDSDKBase(config);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export default PDDSDKBase;
|