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
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
公文生成对话交互系统
|
|
4
|
+
支持完整的公文要素对话收集
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from enum import Enum
|
|
8
|
+
from typing import List, Dict, Optional, Any
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from datetime import datetime
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class DocumentType(Enum):
|
|
14
|
+
"""公文类型枚举"""
|
|
15
|
+
NOTICE = "通知"
|
|
16
|
+
REPORT = "报告"
|
|
17
|
+
REQUEST = "请示"
|
|
18
|
+
LETTER = "函"
|
|
19
|
+
CIRCULAR = "通报"
|
|
20
|
+
MINUTES = "纪要"
|
|
21
|
+
DECISION = "决定"
|
|
22
|
+
OPINION = "意见"
|
|
23
|
+
REPLY = "批复"
|
|
24
|
+
ORDER = "命令(令)"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class UrgencyLevel(Enum):
|
|
28
|
+
"""紧急程度枚举"""
|
|
29
|
+
EXTRA_URGENT = "特急"
|
|
30
|
+
URGENT = "加急"
|
|
31
|
+
NORMAL_URGENT = "平急"
|
|
32
|
+
NONE = "不需要"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class SecretLevel(Enum):
|
|
36
|
+
"""密级枚举"""
|
|
37
|
+
TOP_SECRET = "绝密"
|
|
38
|
+
SECRET = "机密"
|
|
39
|
+
CONFIDENTIAL = "秘密"
|
|
40
|
+
NONE = "不需要"
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class DialogStep(Enum):
|
|
44
|
+
"""对话步骤枚举"""
|
|
45
|
+
START = "start"
|
|
46
|
+
DOC_TYPE = "doc_type"
|
|
47
|
+
ISSUER = "issuer"
|
|
48
|
+
RECIPIENT = "recipient"
|
|
49
|
+
TITLE = "title"
|
|
50
|
+
DOC_NUMBER = "doc_number"
|
|
51
|
+
DATE = "date"
|
|
52
|
+
SECRET_LEVEL = "secret_level"
|
|
53
|
+
URGENCY_LEVEL = "urgency_level"
|
|
54
|
+
SIGNER = "signer"
|
|
55
|
+
BODY = "body"
|
|
56
|
+
ATTACHMENT = "attachment"
|
|
57
|
+
COPY_TO = "copy_to"
|
|
58
|
+
ISSUER_OFFICE = "issuer_office"
|
|
59
|
+
ISSUE_DATE = "issue_date"
|
|
60
|
+
PREVIEW = "preview"
|
|
61
|
+
CONFIRM = "confirm"
|
|
62
|
+
COMPLETE = "complete"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@dataclass
|
|
66
|
+
class DocumentContent:
|
|
67
|
+
"""公文内容数据结构"""
|
|
68
|
+
doc_type: Optional[str] = None
|
|
69
|
+
issuer: Optional[str] = None
|
|
70
|
+
recipient: Optional[str] = None
|
|
71
|
+
title: Optional[str] = None
|
|
72
|
+
doc_number: Optional[str] = None
|
|
73
|
+
date: Optional[str] = None
|
|
74
|
+
secret_level: Optional[str] = None
|
|
75
|
+
secret_period: Optional[str] = None
|
|
76
|
+
urgency_level: Optional[str] = None
|
|
77
|
+
signer: Optional[str] = None
|
|
78
|
+
body: List[str] = field(default_factory=list)
|
|
79
|
+
attachments: List[str] = field(default_factory=list)
|
|
80
|
+
copy_to: List[str] = field(default_factory=list)
|
|
81
|
+
issuer_office: Optional[str] = None
|
|
82
|
+
issue_date: Optional[str] = None
|
|
83
|
+
notes: Optional[str] = None
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class DocumentDialogManager:
|
|
87
|
+
"""公文对话管理器"""
|
|
88
|
+
|
|
89
|
+
def __init__(self):
|
|
90
|
+
self.content = DocumentContent()
|
|
91
|
+
self.current_step = DialogStep.START
|
|
92
|
+
self.dialog_history = []
|
|
93
|
+
self.required_steps = []
|
|
94
|
+
self.optional_steps = []
|
|
95
|
+
|
|
96
|
+
def get_next_prompt(self) -> Dict[str, Any]:
|
|
97
|
+
"""获取下一个对话提示"""
|
|
98
|
+
|
|
99
|
+
prompts = {
|
|
100
|
+
DialogStep.START: self._prompt_start(),
|
|
101
|
+
DialogStep.DOC_TYPE: self._prompt_doc_type(),
|
|
102
|
+
DialogStep.ISSUER: self._prompt_issuer(),
|
|
103
|
+
DialogStep.RECIPIENT: self._prompt_recipient(),
|
|
104
|
+
DialogStep.TITLE: self._prompt_title(),
|
|
105
|
+
DialogStep.DOC_NUMBER: self._prompt_doc_number(),
|
|
106
|
+
DialogStep.DATE: self._prompt_date(),
|
|
107
|
+
DialogStep.SECRET_LEVEL: self._prompt_secret_level(),
|
|
108
|
+
DialogStep.URGENCY_LEVEL: self._prompt_urgency_level(),
|
|
109
|
+
DialogStep.SIGNER: self._prompt_signer(),
|
|
110
|
+
DialogStep.BODY: self._prompt_body(),
|
|
111
|
+
DialogStep.ATTACHMENT: self._prompt_attachment(),
|
|
112
|
+
DialogStep.COPY_TO: self._prompt_copy_to(),
|
|
113
|
+
DialogStep.ISSUER_OFFICE: self._prompt_issuer_office(),
|
|
114
|
+
DialogStep.ISSUE_DATE: self._prompt_issue_date(),
|
|
115
|
+
DialogStep.PREVIEW: self._prompt_preview(),
|
|
116
|
+
DialogStep.CONFIRM: self._prompt_confirm(),
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return prompts.get(self.current_step, {"type": "text", "message": "未知步骤"})
|
|
120
|
+
|
|
121
|
+
def process_user_input(self, user_input: str) -> bool:
|
|
122
|
+
"""处理用户输入,返回是否继续对话"""
|
|
123
|
+
|
|
124
|
+
self.dialog_history.append({
|
|
125
|
+
"step": self.current_step.value,
|
|
126
|
+
"user_input": user_input,
|
|
127
|
+
"timestamp": datetime.now().isoformat()
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
processors = {
|
|
131
|
+
DialogStep.START: self._process_start,
|
|
132
|
+
DialogStep.DOC_TYPE: self._process_doc_type,
|
|
133
|
+
DialogStep.ISSUER: self._process_issuer,
|
|
134
|
+
DialogStep.RECIPIENT: self._process_recipient,
|
|
135
|
+
DialogStep.TITLE: self._process_title,
|
|
136
|
+
DialogStep.DOC_NUMBER: self._process_doc_number,
|
|
137
|
+
DialogStep.DATE: self._process_date,
|
|
138
|
+
DialogStep.SECRET_LEVEL: self._process_secret_level,
|
|
139
|
+
DialogStep.URGENCY_LEVEL: self._process_urgency_level,
|
|
140
|
+
DialogStep.SIGNER: self._process_signer,
|
|
141
|
+
DialogStep.BODY: self._process_body,
|
|
142
|
+
DialogStep.ATTACHMENT: self._process_attachment,
|
|
143
|
+
DialogStep.COPY_TO: self._process_copy_to,
|
|
144
|
+
DialogStep.ISSUER_OFFICE: self._process_issuer_office,
|
|
145
|
+
DialogStep.ISSUE_DATE: self._process_issue_date,
|
|
146
|
+
DialogStep.CONFIRM: self._process_confirm,
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
processor = processors.get(self.current_step)
|
|
150
|
+
if processor:
|
|
151
|
+
return processor(user_input)
|
|
152
|
+
|
|
153
|
+
return False
|
|
154
|
+
|
|
155
|
+
def _prompt_start(self) -> Dict[str, Any]:
|
|
156
|
+
"""开始提示"""
|
|
157
|
+
return {
|
|
158
|
+
"type": "text",
|
|
159
|
+
"message": "您好!我将帮您生成一份符合GB/T 9704-2012标准的公文。\n\n让我们开始吧!"
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
def _prompt_doc_type(self) -> Dict[str, Any]:
|
|
163
|
+
"""公文类型提示"""
|
|
164
|
+
return {
|
|
165
|
+
"type": "choice",
|
|
166
|
+
"message": "请问您需要生成什么类型的公文?",
|
|
167
|
+
"options": [
|
|
168
|
+
{"value": "notice", "label": "通知", "description": "发布、传达要求下级机关执行的事项"},
|
|
169
|
+
{"value": "report", "label": "报告", "description": "向上级机关汇报工作、反映情况"},
|
|
170
|
+
{"value": "request", "label": "请示", "description": "向上级机关请求指示、批准"},
|
|
171
|
+
{"value": "letter", "label": "函", "description": "不相隶属机关之间商洽工作"},
|
|
172
|
+
{"value": "circular", "label": "通报", "description": "表彰先进、批评错误"},
|
|
173
|
+
{"value": "minutes", "label": "纪要", "description": "记载会议主要情况"},
|
|
174
|
+
{"value": "decision", "label": "决定", "description": "对重要事项作出决策"},
|
|
175
|
+
{"value": "opinion", "label": "意见", "description": "对重要问题提出见解"},
|
|
176
|
+
{"value": "reply", "label": "批复", "description": "答复下级机关请示事项"},
|
|
177
|
+
{"value": "order", "label": "命令(令)", "description": "公布行政法规和规章"}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
def _prompt_issuer(self) -> Dict[str, Any]:
|
|
182
|
+
"""发文机关提示"""
|
|
183
|
+
return {
|
|
184
|
+
"type": "text",
|
|
185
|
+
"message": "请告诉我发文机关的全称:",
|
|
186
|
+
"placeholder": "例如:XXX公司",
|
|
187
|
+
"example": "XXX公司"
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
def _prompt_recipient(self) -> Dict[str, Any]:
|
|
191
|
+
"""主送机关提示"""
|
|
192
|
+
return {
|
|
193
|
+
"type": "text",
|
|
194
|
+
"message": "请告诉我主送机关(接收单位):",
|
|
195
|
+
"placeholder": "例如:各部门、市人民政府",
|
|
196
|
+
"example": "各部门"
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
def _prompt_title(self) -> Dict[str, Any]:
|
|
200
|
+
"""标题提示"""
|
|
201
|
+
return {
|
|
202
|
+
"type": "text",
|
|
203
|
+
"message": f"请简要描述公文事由,我将帮您生成规范的{self.content.doc_type}标题:",
|
|
204
|
+
"placeholder": "例如:开展2026年度安全检查工作",
|
|
205
|
+
"example": "开展2026年度安全检查工作",
|
|
206
|
+
"hint": f"规范标题格式:发文机关 + 关于 + 事由 + {self.content.doc_type}"
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
def _prompt_doc_number(self) -> Dict[str, Any]:
|
|
210
|
+
"""发文字号提示"""
|
|
211
|
+
return {
|
|
212
|
+
"type": "text",
|
|
213
|
+
"message": "请提供发文字号(格式:机关代字〔年份〕序号号):",
|
|
214
|
+
"placeholder": "例如:沈数据〔2026〕1号",
|
|
215
|
+
"example": "沈数据〔2026〕1号",
|
|
216
|
+
"hint": "如果不提供,可以留空稍后填写"
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
def _prompt_date(self) -> Dict[str, Any]:
|
|
220
|
+
"""成文日期提示"""
|
|
221
|
+
today = datetime.now().strftime("%Y年%-m月%-d日")
|
|
222
|
+
return {
|
|
223
|
+
"type": "choice",
|
|
224
|
+
"message": f"成文日期是今天({today})吗?",
|
|
225
|
+
"options": [
|
|
226
|
+
{"value": "today", "label": f"是,使用今天日期({today})"},
|
|
227
|
+
{"value": "custom", "label": "否,我要指定其他日期"}
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
def _prompt_secret_level(self) -> Dict[str, Any]:
|
|
232
|
+
"""密级提示"""
|
|
233
|
+
return {
|
|
234
|
+
"type": "choice",
|
|
235
|
+
"message": "这份公文需要标注密级吗?",
|
|
236
|
+
"options": [
|
|
237
|
+
{"value": "none", "label": "不需要(普通公文)"},
|
|
238
|
+
{"value": "confidential", "label": "秘密"},
|
|
239
|
+
{"value": "secret", "label": "机密"},
|
|
240
|
+
{"value": "top_secret", "label": "绝密"}
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
def _prompt_urgency_level(self) -> Dict[str, Any]:
|
|
245
|
+
"""紧急程度提示"""
|
|
246
|
+
return {
|
|
247
|
+
"type": "choice",
|
|
248
|
+
"message": "这份公文的紧急程度是?",
|
|
249
|
+
"options": [
|
|
250
|
+
{"value": "none", "label": "不需要(普通公文)"},
|
|
251
|
+
{"value": "normal", "label": "平急"},
|
|
252
|
+
{"value": "urgent", "label": "加急"},
|
|
253
|
+
{"value": "extra_urgent", "label": "特急"}
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
def _prompt_signer(self) -> Dict[str, Any]:
|
|
258
|
+
"""签发人提示(仅上行文)"""
|
|
259
|
+
if self.content.doc_type in ["报告", "请示"]:
|
|
260
|
+
return {
|
|
261
|
+
"type": "text",
|
|
262
|
+
"message": "这是一份上行文,请提供签发人姓名:",
|
|
263
|
+
"placeholder": "例如:张三",
|
|
264
|
+
"example": "张三"
|
|
265
|
+
}
|
|
266
|
+
else:
|
|
267
|
+
return self._prompt_body()
|
|
268
|
+
|
|
269
|
+
def _prompt_body(self) -> Dict[str, Any]:
|
|
270
|
+
"""正文内容提示"""
|
|
271
|
+
return {
|
|
272
|
+
"type": "multiline",
|
|
273
|
+
"message": "请描述公文的主要内容要点:",
|
|
274
|
+
"placeholder": "请分点描述主要内容,我将帮您组织成规范的公文语言",
|
|
275
|
+
"hint": "可以输入多个要点,每行一个要点"
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
def _prompt_attachment(self) -> Dict[str, Any]:
|
|
279
|
+
"""附件提示"""
|
|
280
|
+
return {
|
|
281
|
+
"type": "choice",
|
|
282
|
+
"message": "这份公文有附件吗?",
|
|
283
|
+
"options": [
|
|
284
|
+
{"value": "no", "label": "没有附件"},
|
|
285
|
+
{"value": "yes", "label": "有附件"}
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
def _prompt_copy_to(self) -> Dict[str, Any]:
|
|
290
|
+
"""抄送机关提示"""
|
|
291
|
+
return {
|
|
292
|
+
"type": "text",
|
|
293
|
+
"message": "是否需要抄送给其他单位?如果有,请告诉我单位名称:",
|
|
294
|
+
"placeholder": "例如:市应急管理局、市公安局",
|
|
295
|
+
"hint": "多个单位用顿号分隔,如果没有可以留空"
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
def _prompt_issuer_office(self) -> Dict[str, Any]:
|
|
299
|
+
"""印发机关提示"""
|
|
300
|
+
default_office = f"{self.content.issuer}办公室" if self.content.issuer else ""
|
|
301
|
+
return {
|
|
302
|
+
"type": "text",
|
|
303
|
+
"message": f"印发机关是发文机关办公室吗?",
|
|
304
|
+
"placeholder": f"默认:{default_office}",
|
|
305
|
+
"hint": "如果不同,请填写实际印发机关"
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
def _prompt_issue_date(self) -> Dict[str, Any]:
|
|
309
|
+
"""印发日期提示"""
|
|
310
|
+
return {
|
|
311
|
+
"type": "choice",
|
|
312
|
+
"message": f"印发日期与成文日期({self.content.date})相同吗?",
|
|
313
|
+
"options": [
|
|
314
|
+
{"value": "same", "label": f"是,使用相同日期"},
|
|
315
|
+
{"value": "different", "label": "否,我要指定其他日期"}
|
|
316
|
+
]
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
def _prompt_preview(self) -> Dict[str, Any]:
|
|
320
|
+
"""预览提示"""
|
|
321
|
+
preview_text = self._generate_preview()
|
|
322
|
+
return {
|
|
323
|
+
"type": "preview",
|
|
324
|
+
"message": "公文预览:",
|
|
325
|
+
"content": preview_text
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
def _prompt_confirm(self) -> Dict[str, Any]:
|
|
329
|
+
"""确认提示"""
|
|
330
|
+
return {
|
|
331
|
+
"type": "choice",
|
|
332
|
+
"message": "请确认公文内容是否正确?",
|
|
333
|
+
"options": [
|
|
334
|
+
{"value": "confirm", "label": "确认无误,生成文档"},
|
|
335
|
+
{"value": "modify", "label": "需要修改"}
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
def _process_start(self, user_input: str) -> bool:
|
|
340
|
+
"""处理开始"""
|
|
341
|
+
self.current_step = DialogStep.DOC_TYPE
|
|
342
|
+
return True
|
|
343
|
+
|
|
344
|
+
def _process_doc_type(self, user_input: str) -> bool:
|
|
345
|
+
"""处理公文类型"""
|
|
346
|
+
type_mapping = {
|
|
347
|
+
"notice": "通知",
|
|
348
|
+
"report": "报告",
|
|
349
|
+
"request": "请示",
|
|
350
|
+
"letter": "函",
|
|
351
|
+
"circular": "通报",
|
|
352
|
+
"minutes": "纪要",
|
|
353
|
+
"decision": "决定",
|
|
354
|
+
"opinion": "意见",
|
|
355
|
+
"reply": "批复",
|
|
356
|
+
"order": "命令(令)"
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
self.content.doc_type = type_mapping.get(user_input, user_input)
|
|
360
|
+
|
|
361
|
+
self._determine_required_steps()
|
|
362
|
+
|
|
363
|
+
self.current_step = DialogStep.ISSUER
|
|
364
|
+
return True
|
|
365
|
+
|
|
366
|
+
def _process_issuer(self, user_input: str) -> bool:
|
|
367
|
+
"""处理发文机关"""
|
|
368
|
+
self.content.issuer = user_input.strip()
|
|
369
|
+
self.current_step = DialogStep.RECIPIENT
|
|
370
|
+
return True
|
|
371
|
+
|
|
372
|
+
def _process_recipient(self, user_input: str) -> bool:
|
|
373
|
+
"""处理主送机关"""
|
|
374
|
+
self.content.recipient = user_input.strip()
|
|
375
|
+
self.current_step = DialogStep.TITLE
|
|
376
|
+
return True
|
|
377
|
+
|
|
378
|
+
def _process_title(self, user_input: str) -> bool:
|
|
379
|
+
"""处理标题"""
|
|
380
|
+
subject = user_input.strip()
|
|
381
|
+
self.content.title = f"关于{subject}的{self.content.doc_type}"
|
|
382
|
+
self.current_step = DialogStep.DOC_NUMBER
|
|
383
|
+
return True
|
|
384
|
+
|
|
385
|
+
def _process_doc_number(self, user_input: str) -> bool:
|
|
386
|
+
"""处理发文字号"""
|
|
387
|
+
if user_input.strip():
|
|
388
|
+
self.content.doc_number = user_input.strip()
|
|
389
|
+
self.current_step = DialogStep.DATE
|
|
390
|
+
return True
|
|
391
|
+
|
|
392
|
+
def _process_date(self, user_input: str) -> bool:
|
|
393
|
+
"""处理成文日期"""
|
|
394
|
+
if user_input == "today":
|
|
395
|
+
self.content.date = datetime.now().strftime("%Y年%-m月%-d日")
|
|
396
|
+
else:
|
|
397
|
+
self.current_step = DialogStep.SECRET_LEVEL
|
|
398
|
+
return True
|
|
399
|
+
|
|
400
|
+
self.current_step = DialogStep.SECRET_LEVEL
|
|
401
|
+
return True
|
|
402
|
+
|
|
403
|
+
def _process_secret_level(self, user_input: str) -> bool:
|
|
404
|
+
"""处理密级"""
|
|
405
|
+
level_mapping = {
|
|
406
|
+
"none": None,
|
|
407
|
+
"confidential": "秘密",
|
|
408
|
+
"secret": "机密",
|
|
409
|
+
"top_secret": "绝密"
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
self.content.secret_level = level_mapping.get(user_input)
|
|
413
|
+
|
|
414
|
+
if self.content.secret_level:
|
|
415
|
+
self.current_step = DialogStep.URGENCY_LEVEL
|
|
416
|
+
else:
|
|
417
|
+
self.current_step = DialogStep.URGENCY_LEVEL
|
|
418
|
+
|
|
419
|
+
return True
|
|
420
|
+
|
|
421
|
+
def _process_urgency_level(self, user_input: str) -> bool:
|
|
422
|
+
"""处理紧急程度"""
|
|
423
|
+
level_mapping = {
|
|
424
|
+
"none": None,
|
|
425
|
+
"normal": "平急",
|
|
426
|
+
"urgent": "加急",
|
|
427
|
+
"extra_urgent": "特急"
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
self.content.urgency_level = level_mapping.get(user_input)
|
|
431
|
+
|
|
432
|
+
if self.content.doc_type in ["报告", "请示"]:
|
|
433
|
+
self.current_step = DialogStep.SIGNER
|
|
434
|
+
else:
|
|
435
|
+
self.current_step = DialogStep.BODY
|
|
436
|
+
|
|
437
|
+
return True
|
|
438
|
+
|
|
439
|
+
def _process_signer(self, user_input: str) -> bool:
|
|
440
|
+
"""处理签发人"""
|
|
441
|
+
if user_input.strip():
|
|
442
|
+
self.content.signer = user_input.strip()
|
|
443
|
+
self.current_step = DialogStep.BODY
|
|
444
|
+
return True
|
|
445
|
+
|
|
446
|
+
def _process_body(self, user_input: str) -> bool:
|
|
447
|
+
"""处理正文"""
|
|
448
|
+
if user_input.strip():
|
|
449
|
+
self.content.body = [line.strip() for line in user_input.split('\n') if line.strip()]
|
|
450
|
+
self.current_step = DialogStep.ATTACHMENT
|
|
451
|
+
return True
|
|
452
|
+
|
|
453
|
+
def _process_attachment(self, user_input: str) -> bool:
|
|
454
|
+
"""处理附件"""
|
|
455
|
+
if user_input == "yes":
|
|
456
|
+
pass
|
|
457
|
+
self.current_step = DialogStep.COPY_TO
|
|
458
|
+
return True
|
|
459
|
+
|
|
460
|
+
def _process_copy_to(self, user_input: str) -> bool:
|
|
461
|
+
"""处理抄送机关"""
|
|
462
|
+
if user_input.strip():
|
|
463
|
+
self.content.copy_to = [org.strip() for org in user_input.split('、') if org.strip()]
|
|
464
|
+
self.current_step = DialogStep.ISSUER_OFFICE
|
|
465
|
+
return True
|
|
466
|
+
|
|
467
|
+
def _process_issuer_office(self, user_input: str) -> bool:
|
|
468
|
+
"""处理印发机关"""
|
|
469
|
+
if user_input.strip():
|
|
470
|
+
self.content.issuer_office = user_input.strip()
|
|
471
|
+
else:
|
|
472
|
+
self.content.issuer_office = f"{self.content.issuer}办公室"
|
|
473
|
+
self.current_step = DialogStep.ISSUE_DATE
|
|
474
|
+
return True
|
|
475
|
+
|
|
476
|
+
def _process_issue_date(self, user_input: str) -> bool:
|
|
477
|
+
"""处理印发日期"""
|
|
478
|
+
if user_input == "same":
|
|
479
|
+
self.content.issue_date = self.content.date
|
|
480
|
+
self.current_step = DialogStep.PREVIEW
|
|
481
|
+
return True
|
|
482
|
+
|
|
483
|
+
def _process_confirm(self, user_input: str) -> bool:
|
|
484
|
+
"""处理确认"""
|
|
485
|
+
if user_input == "confirm":
|
|
486
|
+
self.current_step = DialogStep.COMPLETE
|
|
487
|
+
return False
|
|
488
|
+
else:
|
|
489
|
+
self.current_step = DialogStep.DOC_TYPE
|
|
490
|
+
return True
|
|
491
|
+
|
|
492
|
+
def _determine_required_steps(self):
|
|
493
|
+
"""根据公文类型确定必需步骤"""
|
|
494
|
+
self.required_steps = [
|
|
495
|
+
DialogStep.DOC_TYPE,
|
|
496
|
+
DialogStep.ISSUER,
|
|
497
|
+
DialogStep.RECIPIENT,
|
|
498
|
+
DialogStep.TITLE,
|
|
499
|
+
DialogStep.DATE,
|
|
500
|
+
DialogStep.BODY
|
|
501
|
+
]
|
|
502
|
+
|
|
503
|
+
if self.content.doc_type in ["报告", "请示"]:
|
|
504
|
+
self.required_steps.append(DialogStep.SIGNER)
|
|
505
|
+
|
|
506
|
+
def _generate_preview(self) -> str:
|
|
507
|
+
"""生成预览文本"""
|
|
508
|
+
preview = []
|
|
509
|
+
preview.append(f"公文类型:{self.content.doc_type}")
|
|
510
|
+
preview.append(f"发文机关:{self.content.issuer}")
|
|
511
|
+
preview.append(f"主送机关:{self.content.recipient}")
|
|
512
|
+
preview.append(f"标题:{self.content.title}")
|
|
513
|
+
|
|
514
|
+
if self.content.doc_number:
|
|
515
|
+
preview.append(f"发文字号:{self.content.doc_number}")
|
|
516
|
+
|
|
517
|
+
preview.append(f"成文日期:{self.content.date}")
|
|
518
|
+
|
|
519
|
+
if self.content.secret_level:
|
|
520
|
+
preview.append(f"密级:{self.content.secret_level}")
|
|
521
|
+
|
|
522
|
+
if self.content.urgency_level:
|
|
523
|
+
preview.append(f"紧急程度:{self.content.urgency_level}")
|
|
524
|
+
|
|
525
|
+
if self.content.signer:
|
|
526
|
+
preview.append(f"签发人:{self.content.signer}")
|
|
527
|
+
|
|
528
|
+
preview.append(f"\n正文内容:")
|
|
529
|
+
for i, para in enumerate(self.content.body, 1):
|
|
530
|
+
preview.append(f"{i}. {para}")
|
|
531
|
+
|
|
532
|
+
if self.content.copy_to:
|
|
533
|
+
preview.append(f"\n抄送机关:{'、'.join(self.content.copy_to)}")
|
|
534
|
+
|
|
535
|
+
preview.append(f"\n印发机关:{self.content.issuer_office}")
|
|
536
|
+
preview.append(f"印发日期:{self.content.issue_date}")
|
|
537
|
+
|
|
538
|
+
return '\n'.join(preview)
|
|
539
|
+
|
|
540
|
+
def get_document_content(self) -> Dict[str, Any]:
|
|
541
|
+
"""获取公文内容"""
|
|
542
|
+
return {
|
|
543
|
+
"doc_type": self.content.doc_type,
|
|
544
|
+
"issuer": self.content.issuer,
|
|
545
|
+
"recipient": self.content.recipient,
|
|
546
|
+
"title": self.content.title,
|
|
547
|
+
"doc_number": self.content.doc_number,
|
|
548
|
+
"date": self.content.date,
|
|
549
|
+
"secret_level": self.content.secret_level,
|
|
550
|
+
"secret_period": self.content.secret_period,
|
|
551
|
+
"urgency_level": self.content.urgency_level,
|
|
552
|
+
"signer": self.content.signer,
|
|
553
|
+
"body": self.content.body,
|
|
554
|
+
"attachments": self.content.attachments,
|
|
555
|
+
"copy_to": self.content.copy_to,
|
|
556
|
+
"issuer_office": self.content.issuer_office,
|
|
557
|
+
"issue_date": self.content.issue_date,
|
|
558
|
+
"notes": self.content.notes
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
def create_dialog_manager():
|
|
563
|
+
"""创建对话管理器实例"""
|
|
564
|
+
return DocumentDialogManager()
|