audit-e2w 1.11.2 → 1.11.7

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.
Files changed (76) hide show
  1. package/README.md +152 -148
  2. package/dsh_plugins/audit-e2w/lib/index.js +9 -1
  3. package/dsh_plugins/audit-e2w/lib/skill.js +3 -2
  4. package/excel_word/README.md +45 -37
  5. package/excel_word/qoder_engine.py +10 -11
  6. package/excel_word/wesync/__init__.py +1 -1
  7. package/excel_word/wesync/ai/__init__.py +52 -0
  8. package/excel_word/wesync/ai/actions.py +369 -0
  9. package/excel_word/wesync/ai/client.py +340 -0
  10. package/excel_word/wesync/ai/config.py +291 -0
  11. package/excel_word/wesync/ai/docs.py +177 -0
  12. package/excel_word/wesync/ai/prompts.py +288 -0
  13. package/excel_word/wesync/ai/tasks/__init__.py +26 -0
  14. package/excel_word/wesync/ai/tasks/actions_task.py +97 -0
  15. package/excel_word/wesync/ai/tasks/combined.py +123 -0
  16. package/excel_word/wesync/ai/tasks/diff_note.py +61 -0
  17. package/excel_word/wesync/ai/tasks/headings.py +119 -0
  18. package/excel_word/wesync/ai/tasks/help_task.py +69 -0
  19. package/excel_word/wesync/ai/tasks/roles.py +128 -0
  20. package/excel_word/wesync/align.py +1 -0
  21. package/excel_word/wesync/api.py +544 -92
  22. package/excel_word/wesync/backup_history.py +44 -9
  23. package/excel_word/wesync/cli.py +19 -1
  24. package/excel_word/wesync/commands/blank_cmd.py +59 -30
  25. package/excel_word/wesync/commands/bookmark_cmd.py +41 -10
  26. package/excel_word/wesync/commands/clear_cmd.py +5 -3
  27. package/excel_word/wesync/commands/export_cmd.py +270 -220
  28. package/excel_word/wesync/commands/incremental_cmd.py +157 -0
  29. package/excel_word/wesync/commands/marks_cmd.py +24 -16
  30. package/excel_word/wesync/commands/placeholders_cmd.py +12 -7
  31. package/excel_word/wesync/commands/writeback_cmd.py +72 -116
  32. package/excel_word/wesync/config.py +3 -2
  33. package/excel_word/wesync/console.py +9 -2
  34. package/excel_word/wesync/docx_bookmarks.py +12 -5
  35. package/excel_word/wesync/docx_columns.py +1 -1
  36. package/excel_word/wesync/docx_marks.py +183 -75
  37. package/excel_word/wesync/docx_placeholders.py +65 -26
  38. package/excel_word/wesync/excel_blocks.py +144 -185
  39. package/excel_word/wesync/excel_export.py +15 -8
  40. package/excel_word/wesync/excel_marks.py +265 -193
  41. package/excel_word/wesync/fsops.py +11 -6
  42. package/excel_word/wesync/gui/__init__.py +21 -2
  43. package/excel_word/wesync/gui/app.py +243 -29
  44. package/excel_word/wesync/gui/manual.py +5 -3
  45. package/excel_word/wesync/gui/pages/__init__.py +53 -4
  46. package/excel_word/wesync/gui/pages/_page.py +129 -7
  47. package/excel_word/wesync/gui/pages/ai_page.py +854 -0
  48. package/excel_word/wesync/gui/pages/batch_page.py +64 -31
  49. package/excel_word/wesync/gui/pages/blank_page.py +529 -464
  50. package/excel_word/wesync/gui/pages/bookmark_page.py +97 -37
  51. package/excel_word/wesync/gui/pages/export_page.py +140 -87
  52. package/excel_word/wesync/gui/pages/feedback_page.py +196 -0
  53. package/excel_word/wesync/gui/pages/format_page.py +551 -429
  54. package/excel_word/wesync/gui/pages/help_page.py +73 -7
  55. package/excel_word/wesync/gui/pages/history_page.py +167 -144
  56. package/excel_word/wesync/gui/pages/marks_page.py +210 -177
  57. package/excel_word/wesync/gui/pages/settings_page.py +450 -0
  58. package/excel_word/wesync/gui/pages/writeback_page.py +167 -146
  59. package/excel_word/wesync/gui/runner.py +29 -13
  60. package/excel_word/wesync/gui/store.py +23 -7
  61. package/excel_word/wesync/gui/theme.py +220 -49
  62. package/excel_word/wesync/gui/widgets/ai_config.py +362 -0
  63. package/excel_word/wesync/gui/widgets/cards.py +124 -5
  64. package/excel_word/wesync/gui/widgets/chips.py +565 -0
  65. package/excel_word/wesync/gui/widgets/filebar.py +1 -1
  66. package/excel_word/wesync/gui/widgets/logpane.py +24 -8
  67. package/excel_word/wesync/gui/widgets/nav.py +267 -12
  68. package/excel_word/wesync/gui/widgets/theme_choice.py +93 -0
  69. package/excel_word/wesync/report_format.py +9 -1
  70. package/excel_word/wesync/settings.py +35 -0
  71. package/excel_word/wesync/sort_rules.py +75 -26
  72. package/excel_word/wesync/valuefmt.py +40 -17
  73. package/package.json +53 -51
  74. package/packaging//344/275/277/347/224/250/350/257/264/346/230/216.txt +247 -0
  75. package/qoder_plugins/audit-toolbox/README.md +159 -156
  76. package/qoder_plugins/audit-toolbox/catalog.mjs +13 -13
@@ -1,178 +1,211 @@
1
- """标注与占位页:链接标注(高亮标记)与正文 {字段名} 占位符的导出/同步。"""
2
-
3
- from __future__ import annotations
4
-
5
- from PySide6.QtWidgets import QHBoxLayout, QPushButton, QTabWidget, QVBoxLayout, QWidget
6
-
7
- from ... import api
8
- from ..widgets.cards import make_checkbutton
9
- from ._page import BasePage
10
-
11
-
12
- class MarksPage(BasePage):
13
- title = "标注与占位"
14
- subtitle = "高亮标注与正文 {字段名} 占位符:导出到 Excel,填好后一键写回。"
15
-
16
- def build(self, body: QWidget) -> None:
17
- card = self.card(body)
18
- tabs = QTabWidget()
19
- card.layout().addWidget(tabs)
20
- tabs.addTab(self._build_marks_tab(), "链接标注")
21
- tabs.addTab(self._build_placeholder_tab(), "正文占位符")
22
-
23
- # ---------- 链接标注 tab ----------
24
-
25
- def _build_marks_tab(self) -> QWidget:
26
- tab = QWidget()
27
- layout = QVBoxLayout(tab)
28
- layout.setContentsMargins(12, 12, 12, 12)
29
- layout.setSpacing(10)
30
- # 默认勾选“同步后保留高亮”:便于同步后在 Word 里复核,需要自动去色时手动取消。
31
- self.keep_highlight = make_checkbutton(tab, "同步后保留高亮(不去色,便于复核)", True)
32
- layout.addWidget(self.keep_highlight)
33
- layout.addWidget(self._marks_buttons())
34
- layout.addStretch(1)
35
- return tab
36
-
37
- def _marks_buttons(self) -> QWidget:
38
- row = QWidget()
39
- layout = QHBoxLayout(row)
40
- layout.setContentsMargins(0, 0, 0, 0)
41
- layout.setSpacing(12)
42
- btn = QPushButton("导出/刷新标注")
43
- btn.clicked.connect(lambda _checked=False: self._export_marks())
44
- layout.addWidget(btn)
45
- btn = QPushButton("仅预演同步")
46
- btn.clicked.connect(lambda _checked=False: self._sync_marks(True))
47
- layout.addWidget(btn)
48
- btn = QPushButton("开始同步")
49
- btn.setObjectName("Primary")
50
- btn.clicked.connect(lambda _checked=False: self._sync_marks(False))
51
- layout.addWidget(btn)
52
- layout.addStretch(1)
53
- return row
54
-
55
- def _export_marks(self) -> None:
56
- if not self.ctx.require_docx():
57
- return
58
- xlsx = self.ctx.workbook_path()
59
- if xlsx.exists():
60
- steps = [("导出/刷新标注", lambda: api.run_marks(self.ctx.docx, self.ctx.excel))]
61
- else:
62
- if not self.ctx.confirm(
63
- "尚未生成工作簿",
64
- f"未找到工作簿:\n{xlsx}\n\n是否现在先执行一次完整导出(表格 + 链接标注)?",
65
- ):
66
- self.ctx.log("已取消导出。", "muted")
67
- return
68
- steps = [("导出表格到 Excel(含链接标注)", lambda: api.run_export(self.ctx.docx, self.ctx.excel))]
69
- self.ctx.run_steps(steps)
70
-
71
- def _sync_marks(self, dry_run: bool) -> None:
72
- if not self.ctx.require_docx():
73
- return
74
- xlsx = self.ctx.workbook_path()
75
- keep_highlight = self.keep_highlight.isChecked()
76
- if not xlsx.exists():
77
- self.ctx.log(f"未找到工作簿:{xlsx}\n请先执行“导出/刷新标注”。", "error")
78
- return
79
- if not dry_run:
80
- message = (
81
- f"将把「链接标注」工作表里填写的内容写回 Word:\n\nWord:{self.ctx.docx}\nExcel:{xlsx}\n\n"
82
- + ("同步后保留高亮。\n" if keep_highlight else "同步后自动去掉该处高亮。\n")
83
- + "\n"
84
- "写盘前会自动备份,确认开始同步?"
85
- )
86
- if not self.ctx.confirm("确认同步标注", message):
87
- self.ctx.log("已取消标注同步。", "muted")
88
- return
89
- self.ctx.run_steps(
90
- [
91
- (
92
- ("同步标注(预演)" if dry_run else "同步标注") + ("·保留高亮" if keep_highlight else ""),
93
- lambda: api.run_marks_sync(
94
- self.ctx.docx,
95
- self.ctx.excel,
96
- dry_run=dry_run,
97
- keep_highlight=keep_highlight,
98
- ),
99
- )
100
- ]
101
- )
102
-
103
- # ---------- 正文占位符 tab ----------
104
-
105
- def _build_placeholder_tab(self) -> QWidget:
106
- tab = QWidget()
107
- layout = QVBoxLayout(tab)
108
- layout.setContentsMargins(12, 12, 12, 12)
109
- layout.setSpacing(10)
110
- self.tip_label(
111
- tab,
112
- "扫描 Word 正文与表格里的 {字段名} 占位符,在工作簿「正文信息」表生成填写骨架"
113
- "(A 列字段名、B 列填值,已填的值不会被覆盖)。填好后同步回 Word;"
114
- "未填值的占位符保留原样并逐条警告。该表与「模板生成」共用。",
115
- )
116
- row = QWidget()
117
- hl = QHBoxLayout(row)
118
- hl.setContentsMargins(0, 0, 0, 0)
119
- hl.setSpacing(12)
120
- btn = QPushButton("导出/刷新占位符")
121
- btn.clicked.connect(lambda _checked=False: self._export_placeholders())
122
- hl.addWidget(btn)
123
- btn = QPushButton("仅预演同步")
124
- btn.clicked.connect(lambda _checked=False: self._sync_placeholders(True))
125
- hl.addWidget(btn)
126
- btn = QPushButton("开始同步")
127
- btn.setObjectName("Primary")
128
- btn.clicked.connect(lambda _checked=False: self._sync_placeholders(False))
129
- hl.addWidget(btn)
130
- hl.addStretch(1)
131
- layout.addWidget(row)
132
- layout.addStretch(1)
133
- return tab
134
-
135
- def _export_placeholders(self) -> None:
136
- if not self.ctx.require_docx():
137
- return
138
- xlsx = self.ctx.workbook_path()
139
- if xlsx.exists():
140
- steps = [("导出/刷新占位符", lambda: api.run_placeholder_export(self.ctx.docx, self.ctx.excel))]
141
- else:
142
- if not self.ctx.confirm(
143
- "尚未生成工作簿",
144
- f"未找到工作簿:\n{xlsx}\n\n是否现在先执行一次完整导出(表格 + 链接标注),再补齐占位符骨架?",
145
- ):
146
- self.ctx.log("已取消导出。", "muted")
147
- return
148
- steps = [
149
- ("导出表格到 Excel(含链接标注)", lambda: api.run_export(self.ctx.docx, self.ctx.excel)),
150
- ("导出/刷新占位符", lambda: api.run_placeholder_export(self.ctx.docx, self.ctx.excel)),
151
- ]
152
- self.ctx.run_steps(steps)
153
-
154
- def _sync_placeholders(self, dry_run: bool) -> None:
155
- if not self.ctx.require_docx():
156
- return
157
- xlsx = self.ctx.workbook_path()
158
- if not xlsx.exists():
159
- self.ctx.log(f"未找到工作簿:{xlsx}\n请先执行“导出/刷新占位符”。", "error")
160
- return
161
- if not dry_run:
162
- message = (
163
- f"将按「正文信息」表填写的值替换 Word 里的 {{字段名}} 占位符:\n\n"
164
- f"Word:{self.ctx.docx}\nExcel:{xlsx}\n\n"
165
- "未填值的占位符保留原样并逐条警告。\n"
166
- "写盘前会自动备份,确认开始同步?"
167
- )
168
- if not self.ctx.confirm("确认同步占位符", message):
169
- self.ctx.log("已取消占位符同步。", "muted")
170
- return
171
- self.ctx.run_steps(
172
- [
173
- (
174
- "同步占位符(预演)" if dry_run else "同步占位符",
175
- lambda: api.run_placeholder_sync(self.ctx.docx, self.ctx.excel, dry_run=dry_run),
176
- )
177
- ]
1
+ """标注与占位页:链接标注(高亮标记)与正文 {字段名} 占位符的导出/同步。"""
2
+
3
+ from __future__ import annotations
4
+
5
+ from PySide6.QtWidgets import QTabWidget, QVBoxLayout, QWidget
6
+
7
+ from ... import api
8
+ from ..widgets.cards import make_action_bar, make_checkbutton
9
+ from ..widgets.chips import ChipRow
10
+ from ._page import BasePage
11
+
12
+
13
+ class MarksPage(BasePage):
14
+ title = "标注与占位"
15
+ subtitle = "高亮标注与正文 {字段名} 占位符:导出到 Excel,填好后一键写回。"
16
+
17
+ def build(self, body: QWidget) -> None:
18
+ card = self.card(body)
19
+ tabs = QTabWidget()
20
+ card.layout().addWidget(tabs)
21
+ tabs.addTab(self._build_marks_tab(), "链接标注")
22
+ tabs.addTab(self._build_placeholder_tab(), "正文占位符")
23
+
24
+ # ---------- 链接标注 tab ----------
25
+
26
+ def _build_marks_tab(self) -> QWidget:
27
+ tab = QWidget()
28
+ layout = QVBoxLayout(tab)
29
+ layout.setContentsMargins(12, 12, 12, 12)
30
+ layout.setSpacing(10)
31
+ self.options = ChipRow([
32
+ ("keep_highlight", "保留标注高亮", True, "便于人工复核"),
33
+ ("backup", "同步前备份", True, "关闭则直接覆盖", True),
34
+ ])
35
+ tab.layout().addWidget(self.options)
36
+ self.keep_highlight = self.options["keep_highlight"]
37
+ self.marks_backup = self.options["backup"]
38
+ mark_controls = {}
39
+ self.bind_defaults(layout, {
40
+ "keep_highlight": self.keep_highlight,
41
+ "auto_backup": self.marks_backup,
42
+ }, [("标注", "mark_zero")], mark_controls)
43
+ self.mark_zero = mark_controls["mark_zero"]
44
+ layout.addWidget(self._marks_buttons())
45
+ layout.addStretch(1)
46
+ return tab
47
+
48
+ def _marks_buttons(self) -> QWidget:
49
+ return make_action_bar(
50
+ self,
51
+ "开始同步",
52
+ lambda: self._sync_marks(False),
53
+ secondary=[
54
+ ("导出/刷新标注", self._export_marks),
55
+ ("仅预演同步", lambda: self._sync_marks(True)),
56
+ ],
57
+ primary_index=2,
58
+ )
59
+
60
+ def _export_marks(self) -> None:
61
+ if not self.ctx.require_docx():
62
+ return
63
+ docx, custom_excel = self.ctx.docx, self.ctx.excel
64
+ backup = self.marks_backup.isChecked()
65
+ links = self.ctx.global_settings()["excel_links"]
66
+ totals = self.ctx.global_settings()["totals_formula"]
67
+ xlsx = api.workbook_path(docx, custom_excel)
68
+ if xlsx.exists():
69
+ steps = [("导出/刷新标注", lambda: api.run_marks(docx, custom_excel, backup=backup))]
70
+ else:
71
+ if not self.ctx.confirm(
72
+ "尚未生成工作簿",
73
+ f"未找到工作簿:\n{xlsx}\n\n是否现在先执行一次完整导出(表格 + 链接标注)?",
74
+ ):
75
+ self.ctx.log("已取消导出。", "muted")
76
+ return
77
+ steps = [("导出表格到 Excel(含链接标注)", lambda: api.run_export(
78
+ docx, custom_excel, backup=backup,
79
+ with_excel_links=links, totals_formula=totals,
80
+ ))]
81
+ self.ctx.run_steps(steps)
82
+
83
+ def _sync_marks(self, dry_run: bool) -> None:
84
+ if not self.ctx.require_docx():
85
+ return
86
+ docx, custom_excel = self.ctx.docx, self.ctx.excel
87
+ xlsx = api.workbook_path(docx, custom_excel)
88
+ keep_highlight = self.keep_highlight.isChecked()
89
+ backup = self.marks_backup.isChecked()
90
+ mark_zero = self.mark_zero.currentData()
91
+ if not xlsx.exists():
92
+ self.ctx.log(f"未找到工作簿:{xlsx}\n请先执行“导出/刷新标注”。", "error")
93
+ return
94
+ if not dry_run:
95
+ message = (
96
+ f"将把「链接标注」工作表里填写的内容写回 Word:\n\nWord:{docx}\nExcel:{xlsx}\n\n"
97
+ + ("同步后保留高亮。\n" if keep_highlight else "同步后自动去掉该处高亮。\n")
98
+ + "\n"
99
+ + ("写盘前会自动备份,确认开始同步?" if backup else "本次已取消备份,确认开始同步?")
100
+ )
101
+ if not self.ctx.confirm("确认同步标注", message):
102
+ self.ctx.log("已取消标注同步。", "muted")
103
+ return
104
+ self.ctx.run_steps(
105
+ [
106
+ (
107
+ ("同步标注(预演)" if dry_run else "同步标注") + ("·保留高亮" if keep_highlight else ""),
108
+ lambda: api.run_marks_sync(
109
+ docx, custom_excel,
110
+ dry_run=dry_run,
111
+ keep_highlight=keep_highlight,
112
+ backup=backup, mark_zero=mark_zero,
113
+ ),
114
+ )
115
+ ]
116
+ )
117
+
118
+ # ---------- 正文占位符 tab ----------
119
+
120
+ def _build_placeholder_tab(self) -> QWidget:
121
+ tab = QWidget()
122
+ layout = QVBoxLayout(tab)
123
+ layout.setContentsMargins(12, 12, 12, 12)
124
+ layout.setSpacing(10)
125
+ self.placeholder_backup = make_checkbutton(tab, "同步前备份;关闭则直接覆盖", True)
126
+ layout.addWidget(self.placeholder_backup)
127
+ placeholder_controls = {}
128
+ self.bind_defaults(
129
+ layout,
130
+ {"auto_backup": self.placeholder_backup},
131
+ [("占位符", "placeholder_zero")],
132
+ placeholder_controls,
133
+ )
134
+ self.placeholder_zero = placeholder_controls["placeholder_zero"]
135
+ self.tip_label(
136
+ tab,
137
+ "导出 {字段名} 到「正文信息」,填写后同步;未填保留并警告。该表与模板生成共用。",
138
+ )
139
+ actions = make_action_bar(
140
+ tab,
141
+ "开始同步",
142
+ lambda: self._sync_placeholders(False),
143
+ secondary=[
144
+ ("导出/刷新占位符", self._export_placeholders),
145
+ ("仅预演同步", lambda: self._sync_placeholders(True)),
146
+ ],
147
+ primary_index=2,
148
+ )
149
+ layout.addWidget(actions)
150
+ layout.addStretch(1)
151
+ return tab
152
+
153
+ def _export_placeholders(self) -> None:
154
+ if not self.ctx.require_docx():
155
+ return
156
+ docx, custom_excel = self.ctx.docx, self.ctx.excel
157
+ backup = self.placeholder_backup.isChecked()
158
+ links = self.ctx.global_settings()["excel_links"]
159
+ totals = self.ctx.global_settings()["totals_formula"]
160
+ xlsx = api.workbook_path(docx, custom_excel)
161
+ if xlsx.exists():
162
+ steps = [("导出/刷新占位符", lambda: api.run_placeholder_export(docx, custom_excel, backup=backup))]
163
+ else:
164
+ if not self.ctx.confirm(
165
+ "尚未生成工作簿",
166
+ f"未找到工作簿:\n{xlsx}\n\n是否现在先执行一次完整导出(表格 + 链接标注),再补齐占位符骨架?",
167
+ ):
168
+ self.ctx.log("已取消导出。", "muted")
169
+ return
170
+ steps = [
171
+ ("导出表格到 Excel(含链接标注)", lambda: api.run_export(
172
+ docx, custom_excel, backup=backup,
173
+ with_excel_links=links, totals_formula=totals,
174
+ )),
175
+ ("导出/刷新占位符", lambda: api.run_placeholder_export(
176
+ docx, custom_excel, backup=backup,
177
+ )),
178
+ ]
179
+ self.ctx.run_steps(steps)
180
+
181
+ def _sync_placeholders(self, dry_run: bool) -> None:
182
+ if not self.ctx.require_docx():
183
+ return
184
+ docx, custom_excel = self.ctx.docx, self.ctx.excel
185
+ xlsx = api.workbook_path(docx, custom_excel)
186
+ backup = self.placeholder_backup.isChecked()
187
+ placeholder_zero = self.placeholder_zero.currentData()
188
+ if not xlsx.exists():
189
+ self.ctx.log(f"未找到工作簿:{xlsx}\n请先执行“导出/刷新占位符”。", "error")
190
+ return
191
+ if not dry_run:
192
+ message = (
193
+ f"将按「正文信息」表填写的值替换 Word 里的 {{字段名}} 占位符:\n\n"
194
+ f"Word:{docx}\nExcel:{xlsx}\n\n"
195
+ "未填值的占位符保留原样并逐条警告。\n"
196
+ + ("写盘前会自动备份,确认开始同步?" if backup else "本次已取消备份,确认开始同步?")
197
+ )
198
+ if not self.ctx.confirm("确认同步占位符", message):
199
+ self.ctx.log("已取消占位符同步。", "muted")
200
+ return
201
+ self.ctx.run_steps(
202
+ [
203
+ (
204
+ "同步占位符(预演)" if dry_run else "同步占位符",
205
+ lambda: api.run_placeholder_sync(
206
+ docx, custom_excel, dry_run=dry_run,
207
+ backup=backup, placeholder_zero=placeholder_zero,
208
+ ),
209
+ )
210
+ ]
178
211
  )