@jayyuen66/dsh-dir-prep-organize 0.1.5 → 0.1.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.
- package/CHANGELOG.md +146 -0
- package/LICENSE +1 -1
- package/README.md +25 -21
- package/README.zh-CN.md +25 -21
- package/THIRD_PARTY_NOTICES.md +3 -1
- package/agents/academic/academic-statistician.md +143 -0
- package/agents/design/design-inclusive-visuals-specialist.md +4 -3
- package/agents/design/design-ui-designer.md +6 -3
- package/agents/design/design-ux-architect.md +20 -7
- package/agents/design/design-whimsy-injector.md +23 -1
- package/agents/engineering/engineering-autonomous-optimization-architect.md +31 -22
- package/agents/engineering/engineering-backend-architect.md +43 -54
- package/agents/engineering/engineering-data-engineer.md +21 -6
- package/agents/engineering/engineering-database-optimizer.md +22 -10
- package/agents/engineering/engineering-devops-automator.md +12 -3
- package/agents/engineering/engineering-email-intelligence-engineer.md +41 -4
- package/agents/engineering/engineering-embedded-firmware-engineer.md +27 -5
- package/agents/engineering/engineering-feishu-integration-developer.md +10 -2
- package/agents/engineering/engineering-frontend-developer.md +24 -18
- package/agents/engineering/engineering-git-workflow-master.md +16 -4
- package/agents/engineering/engineering-incident-response-commander.md +3 -3
- package/agents/engineering/engineering-prompt-engineer.md +7 -2
- package/agents/engineering/engineering-rapid-prototyper.md +7 -3
- package/agents/engineering/engineering-security-engineer.md +2 -0
- package/agents/engineering/engineering-solidity-smart-contract-engineer.md +1 -1
- package/agents/engineering/engineering-technical-writer.md +4 -4
- package/agents/engineering/engineering-threat-detection-engineer.md +2 -0
- package/agents/engineering/engineering-voice-ai-integration-engineer.md +39 -16
- package/agents/engineering/engineering-wechat-mini-program-developer.md +7 -2
- package/agents/game-development/blender/blender-addon-engineer.md +12 -3
- package/agents/game-development/economy-designer.md +155 -0
- package/agents/game-development/godot/godot-gameplay-scripter.md +4 -0
- package/agents/game-development/godot/godot-multiplayer-engineer.md +6 -2
- package/agents/game-development/godot/godot-shader-developer.md +4 -3
- package/agents/game-development/roblox-studio/roblox-experience-designer.md +7 -6
- package/agents/game-development/roblox-studio/roblox-systems-scripter.md +7 -0
- package/agents/game-development/technical-artist.md +4 -0
- package/agents/game-development/unity/unity-multiplayer-engineer.md +67 -0
- package/agents/game-development/unreal-engine/unreal-multiplayer-architect.md +82 -31
- package/agents/game-development/unreal-engine/unreal-systems-engineer.md +13 -1
- package/agents/marketing/marketing-agentic-search-optimizer.md +50 -87
- package/agents/marketing/marketing-carousel-growth-engine.md +49 -35
- package/agents/marketing/marketing-private-domain-operator.md +2 -2
- package/agents/marketing/marketing-seo-specialist.md +22 -0
- package/agents/product/product-behavioral-nudge-engine.md +3 -0
- package/agents/project-management/project-management-jira-workflow-steward.md +5 -2
- package/agents/security/security-appsec-engineer.md +75 -43
- package/agents/security/security-threat-detection-engineer.md +6 -0
- package/agents/security/security-threat-intelligence-analyst.md +32 -15
- package/agents/specialized/accounts-payable-agent.md +39 -45
- package/agents/specialized/grant-writer.md +2 -2
- package/agents/specialized/healthcare-aging-parent-care-companion.md +396 -0
- package/agents/specialized/identity-graph-operator.md +24 -3
- package/agents/specialized/lsp-index-engineer.md +17 -15
- package/agents/specialized/recruitment-specialist.md +17 -11
- package/agents/specialized/specialized-developer-advocate.md +4 -4
- package/agents/specialized/specialized-fedramp-rmf-compliance.md +379 -0
- package/agents/specialized/specialized-focus-music-architect.md +176 -0
- package/agents/specialized/specialized-french-consulting-market.md +17 -15
- package/agents/specialized/specialized-model-qa.md +78 -34
- package/agents/specialized/specialized-salesforce-architect.md +17 -15
- package/agents/specialized/specialized-workflow-architect.md +2 -2
- package/agents/supply-chain/supply-chain-strategist.md +12 -3
- package/agents/support/support-analytics-reporter.md +48 -30
- package/agents/support/support-finance-tracker.md +36 -18
- package/agents/support/support-infrastructure-maintainer.md +2 -2
- package/agents/support/support-support-responder.md +43 -26
- package/agents/testing/testing-api-tester.md +37 -27
- package/agents/testing/testing-performance-benchmarker.md +82 -47
- package/agents/testing/testing-test-results-analyzer.md +37 -18
- package/agents/testing/testing-tool-evaluator.md +30 -10
- package/client.js +470 -287
- package/cordis.patch.yml +4 -23
- package/docs/DETAIL.md +26 -0
- package/docs/DETAIL.zh.md +26 -0
- package/host.js +84 -25
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +61 -52
- package/templates.data.mjs +9 -10
- package/types/host.d.ts +36 -4
- package/types/src/client-entry.d.ts +2 -3
- package/types/src/host-messages.d.ts +2 -0
- package/types/src/input-writeback.d.ts +32 -0
- package/types/src/remote.d.ts +7 -1
- package/types/src/ui-messages.d.ts +19 -6
|
@@ -98,8 +98,14 @@ def fetch_thread(imap_conn, thread_ids):
|
|
|
98
98
|
"""获取并解析原始消息,保留完整 MIME 结构。"""
|
|
99
99
|
messages = []
|
|
100
100
|
for msg_id in thread_ids:
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
status, data = imap_conn.fetch(msg_id, "(RFC822)")
|
|
102
|
+
if status != 'OK':
|
|
103
|
+
raise RuntimeError(f'IMAP fetch failed for message {msg_id}: {status}')
|
|
104
|
+
raw = next((item[1] for item in data or []
|
|
105
|
+
if isinstance(item, tuple) and len(item) == 2
|
|
106
|
+
and isinstance(item[1], bytes)), None)
|
|
107
|
+
if raw is None:
|
|
108
|
+
raise RuntimeError(f'IMAP returned no RFC822 body for message {msg_id}')
|
|
103
109
|
parsed = email.message_from_bytes(raw, policy=policy.default)
|
|
104
110
|
messages.append({
|
|
105
111
|
"message_id": parsed["Message-ID"],
|
|
@@ -127,7 +133,28 @@ def reconstruct_thread(messages):
|
|
|
127
133
|
- 引用回复导致内容重复(20 条消息的线程约产生 4-5 倍 token 膨胀)
|
|
128
134
|
- 当不同人回复链中不同消息时,线程会产生分叉
|
|
129
135
|
"""
|
|
130
|
-
#
|
|
136
|
+
# 在构建或修改回复图之前,先拒绝身份不明确的消息。
|
|
137
|
+
# 缺失或重复的 Message-ID 必须进入隔离/人工处理流程;
|
|
138
|
+
# 悄悄使用 None(或被重复使用的 ID)会覆盖掉一条不相关的消息。
|
|
139
|
+
messages = list(messages) # 继续支持只能遍历一次的消息迭代器
|
|
140
|
+
message_ids = [msg.get("message_id") for msg in messages]
|
|
141
|
+
if any(not isinstance(mid, str) or not mid.strip() for mid in message_ids):
|
|
142
|
+
raise ValueError("Every message needs a nonempty Message-ID")
|
|
143
|
+
if len(set(message_ids)) != len(message_ids):
|
|
144
|
+
raise ValueError("Duplicate Message-ID: resolve identity before reconstruction")
|
|
145
|
+
|
|
146
|
+
parents = {msg["message_id"]: msg["in_reply_to"] for msg in messages}
|
|
147
|
+
checked = set()
|
|
148
|
+
for start in parents:
|
|
149
|
+
path = set()
|
|
150
|
+
current = start
|
|
151
|
+
while current in parents and current not in checked:
|
|
152
|
+
if current in path:
|
|
153
|
+
raise ValueError("Cyclic In-Reply-To headers: quarantine before reconstruction")
|
|
154
|
+
path.add(current)
|
|
155
|
+
current = parents[current]
|
|
156
|
+
checked.update(path)
|
|
157
|
+
|
|
131
158
|
graph = {}
|
|
132
159
|
for msg in messages:
|
|
133
160
|
parent_id = msg["in_reply_to"]
|
|
@@ -160,6 +187,12 @@ def strip_quoted_content(body, parent_bodies):
|
|
|
160
187
|
- Outlook XML 引用:带特定 class 的嵌套 <div> 块
|
|
161
188
|
"""
|
|
162
189
|
lines = body.split("\n")
|
|
190
|
+
parent_lines = {
|
|
191
|
+
line.strip()
|
|
192
|
+
for parent in parent_bodies
|
|
193
|
+
for line in parent.splitlines()
|
|
194
|
+
if line.strip()
|
|
195
|
+
}
|
|
163
196
|
unique_lines = []
|
|
164
197
|
in_quote_block = False
|
|
165
198
|
|
|
@@ -170,7 +203,11 @@ def strip_quoted_content(body, parent_bodies):
|
|
|
170
203
|
if in_quote_block and not line.strip():
|
|
171
204
|
in_quote_block = False
|
|
172
205
|
continue
|
|
173
|
-
if not in_quote_block
|
|
206
|
+
if not in_quote_block:
|
|
207
|
+
# 新出现的引用仍然是这封邮件自己的证据。只有当带前缀的
|
|
208
|
+
# 引用行内容与某条父消息重复时,才把它去掉。
|
|
209
|
+
if line.startswith(">") and line[1:].strip() in parent_lines:
|
|
210
|
+
continue
|
|
174
211
|
unique_lines.append(line)
|
|
175
212
|
|
|
176
213
|
return "\n".join(unique_lines)
|
|
@@ -65,20 +65,42 @@ static void sensor_task(void *arg) {
|
|
|
65
65
|
|
|
66
66
|
void app_main(void) {
|
|
67
67
|
sensor_queue = xQueueCreate(8, sizeof(sensor_data_t));
|
|
68
|
-
|
|
68
|
+
if (sensor_queue == NULL) {
|
|
69
|
+
// 绝不启动一个会向无效队列发送数据的任务。
|
|
70
|
+
return; // 通过应用的故障处理路径上报内存分配失败。
|
|
71
|
+
}
|
|
72
|
+
if (xTaskCreate(sensor_task, "sensor", TASK_STACK_SIZE, NULL,
|
|
73
|
+
TASK_PRIORITY, NULL) != pdPASS) {
|
|
74
|
+
vQueueDelete(sensor_queue);
|
|
75
|
+
sensor_queue = NULL;
|
|
76
|
+
return; // 没有任务持有这个队列;上报故障之前先释放它。
|
|
77
|
+
}
|
|
69
78
|
}
|
|
70
79
|
```
|
|
71
80
|
|
|
72
|
-
### STM32 LL SPI
|
|
81
|
+
### STM32 LL SPI 传输(有超时的轮询,在任务上下文中调用)
|
|
73
82
|
|
|
74
83
|
```c
|
|
75
|
-
|
|
76
|
-
|
|
84
|
+
#include <stdbool.h>
|
|
85
|
+
#include <stdint.h>
|
|
86
|
+
|
|
87
|
+
// 适用于带 TXE/BSY 标志位的 STM32 SPI(例如 STM32F4);这不是可在中断里调用的 API,也不是非阻塞的。
|
|
88
|
+
// 轮询期间 HAL_GetTick 必须持续递增。两次等待共用同一个截止时间。
|
|
89
|
+
bool spi_write_byte(SPI_TypeDef *spi, uint8_t data, uint32_t timeout_ms) {
|
|
90
|
+
const uint32_t started = HAL_GetTick();
|
|
91
|
+
while (!LL_SPI_IsActiveFlag_TXE(spi)) {
|
|
92
|
+
if ((uint32_t)(HAL_GetTick() - started) >= timeout_ms) return false;
|
|
93
|
+
}
|
|
77
94
|
LL_SPI_TransmitData8(spi, data);
|
|
78
|
-
while (LL_SPI_IsActiveFlag_BSY(spi))
|
|
95
|
+
while (LL_SPI_IsActiveFlag_BSY(spi)) {
|
|
96
|
+
if ((uint32_t)(HAL_GetTick() - started) >= timeout_ms) return false;
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
79
99
|
}
|
|
80
100
|
```
|
|
81
101
|
|
|
102
|
+
如果在写入发送数据之后返回 `false`,说明传输是否完成是未知的:重试之前,要依照目标 MCU 的参考手册和勘误表恢复外设,不要盲目重发。调用方必须保持非阻塞时,改用中断或 DMA。
|
|
103
|
+
|
|
82
104
|
### Nordic nRF BLE 广播(nRF Connect SDK / Zephyr)
|
|
83
105
|
|
|
84
106
|
```c
|
|
@@ -472,7 +472,7 @@ async function createApprovalInstance(params: {
|
|
|
472
472
|
// 查询审批实例详情
|
|
473
473
|
async function getApprovalInstance(instanceCode: string) {
|
|
474
474
|
const resp = await client.approval.instance.get({
|
|
475
|
-
|
|
475
|
+
path: { instance_id: instanceCode },
|
|
476
476
|
});
|
|
477
477
|
|
|
478
478
|
if (resp.code !== 0) {
|
|
@@ -510,9 +510,17 @@ router.get('/login/feishu', (req, res) => {
|
|
|
510
510
|
router.get('/callback/feishu', async (req, res) => {
|
|
511
511
|
const { code, state } = req.query;
|
|
512
512
|
|
|
513
|
-
|
|
513
|
+
const expectedState = req.session?.oauthState;
|
|
514
|
+
if (typeof code !== 'string' || !code ||
|
|
515
|
+
typeof state !== 'string' || !state ||
|
|
516
|
+
typeof expectedState !== 'string' || !expectedState ||
|
|
517
|
+
state !== expectedState) {
|
|
514
518
|
return res.status(403).json({ error: 'state 不匹配,可能存在 CSRF 攻击' });
|
|
515
519
|
}
|
|
520
|
+
// 在第一个 await 之前,就消费掉本次请求绑定的 state。
|
|
521
|
+
// 如果回调可能加载到各自独立的会话副本,还要在共享的会话存储中原子地让 state 失效;
|
|
522
|
+
// 仅删除这个对象做不到这一点。
|
|
523
|
+
delete req.session!.oauthState;
|
|
516
524
|
|
|
517
525
|
const tokenResp = await client.authen.oidcAccessToken.create({
|
|
518
526
|
data: {
|
|
@@ -95,24 +95,30 @@ export const DataTable = memo<DataTableProps>(({ data, columns, onRowClick }) =>
|
|
|
95
95
|
role="table"
|
|
96
96
|
aria-label="Data table"
|
|
97
97
|
>
|
|
98
|
-
{rowVirtualizer.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
98
|
+
<div role="rowgroup" style={{ height: rowVirtualizer.getTotalSize(), position: 'relative' }}>
|
|
99
|
+
{rowVirtualizer.getVirtualItems().map((virtualItem) => {
|
|
100
|
+
const row = data[virtualItem.index];
|
|
101
|
+
return (
|
|
102
|
+
<div
|
|
103
|
+
key={virtualItem.key}
|
|
104
|
+
className="flex items-center border-b hover:bg-gray-50 cursor-pointer"
|
|
105
|
+
style={{
|
|
106
|
+
position: 'absolute', top: 0, left: 0, width: '100%',
|
|
107
|
+
height: virtualItem.size, transform: `translateY(${virtualItem.start}px)`,
|
|
108
|
+
}}
|
|
109
|
+
onClick={() => handleRowClick(row)}
|
|
110
|
+
role="row"
|
|
111
|
+
tabIndex={0}
|
|
112
|
+
>
|
|
113
|
+
{columns.map((column) => (
|
|
114
|
+
<div key={column.key} className="px-4 py-2 flex-1" role="cell">
|
|
115
|
+
{row[column.key]}
|
|
116
|
+
</div>
|
|
117
|
+
))}
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
})}
|
|
121
|
+
</div>
|
|
116
122
|
</div>
|
|
117
123
|
);
|
|
118
124
|
});
|
|
@@ -63,16 +63,28 @@ release/1.3 ──────────────●────●──
|
|
|
63
63
|
### 开始工作
|
|
64
64
|
```bash
|
|
65
65
|
git fetch origin
|
|
66
|
-
git
|
|
67
|
-
#
|
|
68
|
-
git
|
|
66
|
+
git switch --no-track -c feat/my-feature origin/main
|
|
67
|
+
# 推送功能分支,并显式设置它的上游:
|
|
68
|
+
git push -u origin feat/my-feature
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
+
并行开发时,用下面的方式**代替**在当前检出中创建分支。Git 不能在两个工作树中检出同一个分支:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
git fetch origin
|
|
75
|
+
git worktree add --no-track -b feat/my-feature ../my-feature origin/main
|
|
76
|
+
cd ../my-feature
|
|
77
|
+
git push -u origin feat/my-feature
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`--no-track` 防止新的功能分支把 `origin/main` 继承为自己的上游。第一次推送之后,它的上游就是 `origin/feat/my-feature`。
|
|
81
|
+
|
|
71
82
|
### PR 前清理
|
|
72
83
|
```bash
|
|
73
84
|
git fetch origin
|
|
74
85
|
git rebase -i origin/main # 合并 fixup,修改提交信息
|
|
75
|
-
|
|
86
|
+
# 只改写你自己的功能分支,并且要征得协作者同意:
|
|
87
|
+
git push --force-with-lease origin HEAD:feat/my-feature
|
|
76
88
|
```
|
|
77
89
|
|
|
78
90
|
### 完成分支
|
|
@@ -89,7 +89,7 @@ color: "#e63946"
|
|
|
89
89
|
|
|
90
90
|
### 故障响应 Runbook 模板
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
````markdown
|
|
93
93
|
# Runbook: [服务/故障场景名称]
|
|
94
94
|
|
|
95
95
|
## 快速参考
|
|
@@ -154,7 +154,7 @@ kubectl autoscale deployment/<service> -n production \
|
|
|
154
154
|
- 内部:在 #incidents Slack 频道发布更新
|
|
155
155
|
- 外部:如涉及客户则更新[状态页链接]
|
|
156
156
|
- 后续:24 小时内创建事后复盘文档
|
|
157
|
-
|
|
157
|
+
````
|
|
158
158
|
|
|
159
159
|
### 事后复盘文档模板
|
|
160
160
|
|
|
@@ -265,7 +265,7 @@ slos:
|
|
|
265
265
|
- severity: page
|
|
266
266
|
short_window: 5m
|
|
267
267
|
long_window: 1h
|
|
268
|
-
burn_rate: 14.4x #
|
|
268
|
+
burn_rate: 14.4x # 预算约 2 天耗尽(每小时消耗 2%)
|
|
269
269
|
- severity: ticket
|
|
270
270
|
short_window: 30m
|
|
271
271
|
long_window: 6h
|
|
@@ -98,6 +98,8 @@ def test_prompt(user_input, expected, desc):
|
|
|
98
98
|
|
|
99
99
|
### Few-Shot 示例构造器
|
|
100
100
|
```python
|
|
101
|
+
from xml.sax.saxutils import escape
|
|
102
|
+
|
|
101
103
|
def build_few_shot_block(examples: list[dict]) -> str:
|
|
102
104
|
"""
|
|
103
105
|
examples = [{"input": "...", "output": "..."}]
|
|
@@ -106,12 +108,15 @@ def build_few_shot_block(examples: list[dict]) -> str:
|
|
|
106
108
|
lines = ["## Examples\n"]
|
|
107
109
|
for i, ex in enumerate(examples, 1):
|
|
108
110
|
lines.append(f"<example id='{i}'>")
|
|
109
|
-
|
|
110
|
-
lines.append(f"
|
|
111
|
+
# 示例中字面形式的 XML/类标签内容必须保持为文本,绝不能变成新的分隔符。
|
|
112
|
+
lines.append(f"Input: {escape(str(ex['input']))}")
|
|
113
|
+
lines.append(f"Output: {escape(str(ex['output']))}")
|
|
111
114
|
lines.append("</example>\n")
|
|
112
115
|
return "\n".join(lines)
|
|
113
116
|
```
|
|
114
117
|
|
|
118
|
+
当输入或输出中含有 `<`、`>` 或 `&` 时,转义能保住示例之间的边界。这只是结构上的编码,并不能防御语义层面的提示词注入;不可信的示例在放进系统提示词之前,仍然需要经过审核。
|
|
119
|
+
|
|
115
120
|
## 🔄 你的工作流程
|
|
116
121
|
|
|
117
122
|
### 阶段一:需求翻译
|
|
@@ -264,9 +264,13 @@ export function trackEvent(eventName: string, properties?: Record<string, any>)
|
|
|
264
264
|
|
|
265
265
|
// 简单的 A/B 测试 hook
|
|
266
266
|
export function useABTest(testName: string, variants: string[]) {
|
|
267
|
+
if (variants.length === 0) throw new Error('An experiment needs at least one variant');
|
|
267
268
|
const [variant, setVariant] = useState<string>('');
|
|
269
|
+
// 内联数组每次渲染都是新的引用;依赖它的实际内容,而不是引用。
|
|
270
|
+
const variantsKey = JSON.stringify(variants);
|
|
268
271
|
|
|
269
272
|
useEffect(() => {
|
|
273
|
+
const experimentVariants: string[] = JSON.parse(variantsKey);
|
|
270
274
|
// 获取或创建用户 ID 以确保一致的体验
|
|
271
275
|
let userId = localStorage.getItem('user_id');
|
|
272
276
|
if (!userId) {
|
|
@@ -280,8 +284,8 @@ export function useABTest(testName: string, variants: string[]) {
|
|
|
280
284
|
return a & a;
|
|
281
285
|
}, 0);
|
|
282
286
|
|
|
283
|
-
const variantIndex = Math.abs(hash) %
|
|
284
|
-
const assignedVariant =
|
|
287
|
+
const variantIndex = Math.abs(hash) % experimentVariants.length;
|
|
288
|
+
const assignedVariant = experimentVariants[variantIndex];
|
|
285
289
|
|
|
286
290
|
setVariant(assignedVariant);
|
|
287
291
|
|
|
@@ -291,7 +295,7 @@ export function useABTest(testName: string, variants: string[]) {
|
|
|
291
295
|
variant: assignedVariant,
|
|
292
296
|
user_id: userId,
|
|
293
297
|
});
|
|
294
|
-
}, [testName,
|
|
298
|
+
}, [testName, variantsKey]);
|
|
295
299
|
|
|
296
300
|
return variant;
|
|
297
301
|
}
|
|
@@ -7,6 +7,8 @@ color: red
|
|
|
7
7
|
|
|
8
8
|
# 安全工程师 Agent
|
|
9
9
|
|
|
10
|
+
> **说明**:上游已将本角色迁至安全部,新版本见 [`security/security-architect.md`](../security/security-architect.md),建议新项目改用新路径。此文件为兼容已有的工作流与旧引用而保留,计划在相关引用迁移完成后删除。
|
|
11
|
+
|
|
10
12
|
你是**安全工程师**,一位专业的应用安全工程师,专长于威胁建模、漏洞评估、安全代码审查、安全架构设计和事件响应。你通过尽早识别风险、将安全融入开发生命周期、并在从客户端代码到云基础设施的每一层确保纵深防御,来保护应用和基础设施。
|
|
11
13
|
|
|
12
14
|
## 你的身份与思维模式
|
|
@@ -492,7 +492,7 @@ main().catch((error) => {
|
|
|
492
492
|
|
|
493
493
|
- **漏洞利用复盘**:每次重大攻击都是一种模式——重入攻击(The DAO)、delegatecall 滥用(Parity)、价格预言机操纵(Mango Markets)、逻辑漏洞(Wormhole)
|
|
494
494
|
- **Gas 基准数据**:熟知 SLOAD(冷读 2100、热读 100)、SSTORE(新写 20000、更新 5000)的确切 Gas 成本,以及它们如何影响合约设计
|
|
495
|
-
- **链特有差异**:Ethereum 主网、Arbitrum、Optimism、Base、Polygon 之间的区别——尤其是 block.timestamp、Gas 定价、预编译合约
|
|
495
|
+
- **链特有差异**:Ethereum 主网、Arbitrum、Optimism、Base、Polygon、XDC 之间的区别——尤其是 block.timestamp、Gas 定价、预编译合约
|
|
496
496
|
- **Solidity 编译器变更**:跟踪各版本的破坏性变更、优化器行为、瞬态存储(EIP-1153)等新特性
|
|
497
497
|
|
|
498
498
|
### 模式识别
|
|
@@ -59,7 +59,7 @@ color: teal
|
|
|
59
59
|
|
|
60
60
|
### 高质量 README 模板
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
````markdown
|
|
63
63
|
# 项目名称
|
|
64
64
|
|
|
65
65
|
> 一句话描述这个项目做什么以及为什么重要。
|
|
@@ -126,7 +126,7 @@ yarn add your-package
|
|
|
126
126
|
## 许可证
|
|
127
127
|
|
|
128
128
|
MIT © [Your Name](https://github.com/yourname)
|
|
129
|
-
|
|
129
|
+
````
|
|
130
130
|
|
|
131
131
|
### OpenAPI 文档示例
|
|
132
132
|
|
|
@@ -209,7 +209,7 @@ paths:
|
|
|
209
209
|
|
|
210
210
|
### 教程结构模板
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
````markdown
|
|
213
213
|
# 教程:[目标成果] [预估时间]
|
|
214
214
|
|
|
215
215
|
**你将构建**:简要描述最终成果,附截图或演示链接。
|
|
@@ -261,7 +261,7 @@ Wrote to /path/to/my-project/package.json: { ... }
|
|
|
261
261
|
- [进阶教程:添加认证](链接)
|
|
262
262
|
- [参考:完整 API 文档](链接)
|
|
263
263
|
- [示例:生产级完整版本](链接)
|
|
264
|
-
|
|
264
|
+
````
|
|
265
265
|
|
|
266
266
|
### Docusaurus 配置
|
|
267
267
|
|
|
@@ -7,6 +7,8 @@ color: "#7b2d8e"
|
|
|
7
7
|
|
|
8
8
|
# 威胁检测工程师
|
|
9
9
|
|
|
10
|
+
> **说明**:上游已将本角色迁至安全部,新版本见 [`security/security-threat-detection-engineer.md`](../security/security-threat-detection-engineer.md),建议新项目改用新路径。此文件为兼容已有的工作流与旧引用而保留,计划在相关引用迁移完成后删除。
|
|
11
|
+
|
|
10
12
|
你是**威胁检测工程师**,负责构建在攻击者绕过预防性控制之后抓住他们的检测层。你编写 SIEM 检测规则、将覆盖度映射到 MITRE ATT&CK、狩猎自动化检测遗漏的威胁、毫不留情地调优告警让 SOC 团队信任他们看到的每一条告警。你知道未被发现的入侵比被发现的代价高 10 倍,你也知道一个噪声缠身的 SIEM 比没有 SIEM 更糟——因为它在训练分析师忽略告警。
|
|
11
13
|
|
|
12
14
|
## 你的身份与记忆
|
|
@@ -101,6 +101,7 @@ color: violet
|
|
|
101
101
|
```python
|
|
102
102
|
import subprocess
|
|
103
103
|
import json
|
|
104
|
+
import math
|
|
104
105
|
from pathlib import Path
|
|
105
106
|
|
|
106
107
|
SUPPORTED_EXTENSIONS = {".wav", ".mp3", ".m4a", ".ogg", ".flac", ".mp4", ".mov", ".webm"}
|
|
@@ -120,11 +121,16 @@ def validate_audio_file(file_path: str) -> dict:
|
|
|
120
121
|
"ffprobe", "-v", "quiet",
|
|
121
122
|
"-print_format", "json",
|
|
122
123
|
"-show_streams", "-show_format",
|
|
123
|
-
str(path)
|
|
124
|
+
"-i", str(path) # 让以短横线开头的文件名也被当作输入,而不是选项。
|
|
124
125
|
], capture_output=True, text=True, check=True)
|
|
125
126
|
|
|
126
127
|
probe = json.loads(result.stdout)
|
|
127
|
-
|
|
128
|
+
try:
|
|
129
|
+
duration = float(probe['format']['duration'])
|
|
130
|
+
except (KeyError, TypeError, ValueError) as error:
|
|
131
|
+
raise ValueError('Audio duration must be known, finite and positive') from error
|
|
132
|
+
if not math.isfinite(duration) or duration <= 0:
|
|
133
|
+
raise ValueError('Audio duration must be known, finite and positive')
|
|
128
134
|
|
|
129
135
|
if duration > MAX_DURATION_SECONDS:
|
|
130
136
|
raise ValueError(f"文件超出最大时长: {duration:.0f}s > {MAX_DURATION_SECONDS}s")
|
|
@@ -170,14 +176,14 @@ def preprocess_audio(input_path: str, output_path: str) -> str:
|
|
|
170
176
|
"-ar", "16000", # 16kHz 采样率
|
|
171
177
|
"-ac", "1", # 单声道
|
|
172
178
|
"-af", "loudnorm=I=-16:TP=-1.5:LRA=11", # EBU R128 响度规范化
|
|
173
|
-
output_path
|
|
179
|
+
str(Path(output_path).absolute()) # 输出路径不能看起来像命令行选项。
|
|
174
180
|
]
|
|
175
181
|
subprocess.run(cmd, check=True, capture_output=True)
|
|
176
182
|
return output_path
|
|
177
183
|
|
|
178
184
|
|
|
179
185
|
def chunk_audio(input_path: str, chunk_dir: str,
|
|
180
|
-
chunk_duration: int = 1800, overlap: int = 30) -> list[
|
|
186
|
+
chunk_duration: int = 1800, overlap: int = 30) -> list[dict]:
|
|
181
187
|
"""
|
|
182
188
|
将长音频拆分为有重叠的分块用于模型处理。
|
|
183
189
|
|
|
@@ -188,11 +194,17 @@ def chunk_audio(input_path: str, chunk_dir: str,
|
|
|
188
194
|
overlap: 重叠窗口秒数(默认 30 秒)
|
|
189
195
|
"""
|
|
190
196
|
import math, os
|
|
197
|
+
if not math.isfinite(chunk_duration) or chunk_duration <= 0:
|
|
198
|
+
raise ValueError("chunk_duration must be finite and positive")
|
|
199
|
+
if not math.isfinite(overlap) or overlap < 0:
|
|
200
|
+
raise ValueError("overlap must be finite and nonnegative")
|
|
191
201
|
result = subprocess.run([
|
|
192
202
|
"ffprobe", "-v", "quiet", "-show_entries", "format=duration",
|
|
193
|
-
"-of", "default=noprint_wrappers=1:nokey=1", input_path
|
|
203
|
+
"-of", "default=noprint_wrappers=1:nokey=1", "-i", input_path
|
|
194
204
|
], capture_output=True, text=True, check=True)
|
|
195
205
|
total_duration = float(result.stdout.strip())
|
|
206
|
+
if not math.isfinite(total_duration) or total_duration <= 0:
|
|
207
|
+
raise ValueError("Audio duration must be finite and positive")
|
|
196
208
|
|
|
197
209
|
chunks = []
|
|
198
210
|
start = 0
|
|
@@ -204,11 +216,12 @@ def chunk_audio(input_path: str, chunk_dir: str,
|
|
|
204
216
|
out_path = f"{chunk_dir}/chunk_{chunk_index:04d}.wav"
|
|
205
217
|
subprocess.run([
|
|
206
218
|
"ffmpeg", "-y",
|
|
207
|
-
"-i", input_path,
|
|
208
219
|
"-ss", str(start),
|
|
209
|
-
"-
|
|
210
|
-
"-
|
|
211
|
-
|
|
220
|
+
"-i", input_path,
|
|
221
|
+
"-t", str(end - start),
|
|
222
|
+
"-map", "0:a:0", "-vn",
|
|
223
|
+
"-acodec", "pcm_s16le", "-ar", "16000", "-ac", "1",
|
|
224
|
+
str(Path(out_path).absolute())
|
|
212
225
|
], check=True, capture_output=True)
|
|
213
226
|
chunks.append({"path": out_path, "start_offset": start, "index": chunk_index})
|
|
214
227
|
start += chunk_duration
|
|
@@ -284,6 +297,7 @@ def assemble_chunks(chunk_results: list[dict],
|
|
|
284
297
|
start=adjusted_start,
|
|
285
298
|
end=seg.end + offset,
|
|
286
299
|
text=seg.text,
|
|
300
|
+
speaker=seg.speaker,
|
|
287
301
|
confidence=seg.confidence
|
|
288
302
|
))
|
|
289
303
|
return merged
|
|
@@ -348,6 +362,7 @@ def assign_speakers(transcript_segments: list[TranscriptSegment],
|
|
|
348
362
|
```python
|
|
349
363
|
import json
|
|
350
364
|
import re
|
|
365
|
+
import math
|
|
351
366
|
|
|
352
367
|
def normalize_transcript(segments: list[TranscriptSegment]) -> list[TranscriptSegment]:
|
|
353
368
|
"""
|
|
@@ -374,20 +389,28 @@ def export_srt(segments: list[TranscriptSegment], output_path: str) -> str:
|
|
|
374
389
|
"""
|
|
375
390
|
将转录文本导出为 SRT 字幕文件。
|
|
376
391
|
|
|
377
|
-
|
|
378
|
-
|
|
392
|
+
以毫秒精度序列化已经过校验的字幕时间。
|
|
393
|
+
阅读速度和行长度的检查属于应用层的适配器;
|
|
394
|
+
这个序列化示例原样保留传入的文本,不做拆分。
|
|
379
395
|
"""
|
|
380
396
|
def format_timestamp(seconds: float) -> str:
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
397
|
+
if not math.isfinite(seconds) or seconds < 0:
|
|
398
|
+
raise ValueError("Subtitle timestamps must be finite and nonnegative")
|
|
399
|
+
milliseconds = round(seconds * 1000)
|
|
400
|
+
h, milliseconds = divmod(milliseconds, 3_600_000)
|
|
401
|
+
m, milliseconds = divmod(milliseconds, 60_000)
|
|
402
|
+
s, ms = divmod(milliseconds, 1000)
|
|
385
403
|
return f"{h:02d}:{m:02d}:{s:02d},{ms:03d}"
|
|
386
404
|
|
|
387
405
|
lines = []
|
|
388
406
|
for i, seg in enumerate(segments, 1):
|
|
407
|
+
if seg.end <= seg.start:
|
|
408
|
+
raise ValueError("Subtitle cues need a positive duration")
|
|
409
|
+
start, end = format_timestamp(seg.start), format_timestamp(seg.end)
|
|
410
|
+
if start == end:
|
|
411
|
+
raise ValueError("Subtitle cue collapses at millisecond precision")
|
|
389
412
|
lines.append(str(i))
|
|
390
|
-
lines.append(f"{
|
|
413
|
+
lines.append(f"{start} --> {end}")
|
|
391
414
|
speaker_prefix = f"[{seg.speaker}] " if seg.speaker else ""
|
|
392
415
|
lines.append(f"{speaker_prefix}{seg.text}")
|
|
393
416
|
lines.append("")
|
|
@@ -133,9 +133,14 @@ const request = (options) => {
|
|
|
133
133
|
// token 过期,重新登录
|
|
134
134
|
refreshToken().then(() => {
|
|
135
135
|
request(options).then(resolve).catch(reject)
|
|
136
|
-
})
|
|
136
|
+
}).catch(reject) // 刷新失败也要结束 Promise,不能让它一直挂起
|
|
137
137
|
} else {
|
|
138
|
-
|
|
138
|
+
// 错误响应体可能是空的、纯文本,或网关返回的 HTML 页面。
|
|
139
|
+
// 不要在 success 回调里抛错,否则 Promise 会一直挂起。
|
|
140
|
+
const message = res.data && typeof res.data === 'object' &&
|
|
141
|
+
typeof res.data.message === 'string' && res.data.message
|
|
142
|
+
? res.data.message : '请求失败'
|
|
143
|
+
reject(new Error(message))
|
|
139
144
|
}
|
|
140
145
|
},
|
|
141
146
|
fail: (err) => {
|
|
@@ -63,6 +63,9 @@ class PIPELINE_OT_validate_assets(bpy.types.Operator):
|
|
|
63
63
|
|
|
64
64
|
def execute(self, context):
|
|
65
65
|
issues = []
|
|
66
|
+
if not context.selected_objects:
|
|
67
|
+
self.report({'WARNING'}, "Select assets before validation/export.")
|
|
68
|
+
return {'CANCELLED'}
|
|
66
69
|
for obj in context.selected_objects:
|
|
67
70
|
if obj.type != "MESH":
|
|
68
71
|
continue
|
|
@@ -73,8 +76,8 @@ class PIPELINE_OT_validate_assets(bpy.types.Operator):
|
|
|
73
76
|
if any(abs(s - 1.0) > 0.0001 for s in obj.scale):
|
|
74
77
|
issues.append(f"{obj.name}: unapplied scale")
|
|
75
78
|
|
|
76
|
-
if
|
|
77
|
-
issues.append(f"{obj.name}: missing material
|
|
79
|
+
if not obj.material_slots or any(slot.material is None for slot in obj.material_slots):
|
|
80
|
+
issues.append(f"{obj.name}: missing assigned material")
|
|
78
81
|
|
|
79
82
|
if issues:
|
|
80
83
|
self.report({'WARNING'}, f"Validation found {len(issues)} issue(s). See system console.")
|
|
@@ -110,6 +113,10 @@ class PIPELINE_OT_export_selected(bpy.types.Operator):
|
|
|
110
113
|
bl_label = "Export Selected"
|
|
111
114
|
|
|
112
115
|
def execute(self, context):
|
|
116
|
+
# 导出按钮必须执行和验证按钮相同的检查关卡。
|
|
117
|
+
if bpy.ops.pipeline.validate_assets() != {'FINISHED'}:
|
|
118
|
+
self.report({'WARNING'}, "Export blocked: resolve asset validation findings.")
|
|
119
|
+
return {'CANCELLED'}
|
|
113
120
|
export_path = context.scene.pipeline_export_path
|
|
114
121
|
bpy.ops.export_scene.gltf(
|
|
115
122
|
filepath=export_path,
|
|
@@ -124,10 +131,12 @@ class PIPELINE_OT_export_selected(bpy.types.Operator):
|
|
|
124
131
|
|
|
125
132
|
### 命名审计报告
|
|
126
133
|
```python
|
|
134
|
+
import re
|
|
135
|
+
|
|
127
136
|
def build_naming_report(objects):
|
|
128
137
|
report = {"ok": [], "problems": []}
|
|
129
138
|
for obj in objects:
|
|
130
|
-
if
|
|
139
|
+
if re.search(r"\.[0-9]{3,}$", obj.name):
|
|
131
140
|
report["problems"].append(f"{obj.name}: Blender duplicate suffix detected")
|
|
132
141
|
elif " " in obj.name:
|
|
133
142
|
report["problems"].append(f"{obj.name}: spaces in name")
|