@jayyuen66/dsh-dir-prep-organize 0.1.5 → 0.1.6
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 +117 -0
- package/LICENSE +1 -1
- package/README.md +5 -5
- package/README.zh-CN.md +5 -5
- 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 +118 -82
- package/cordis.patch.yml +4 -23
- package/host.js +49 -18
- package/package.json +44 -43
- package/templates.data.mjs +9 -10
- package/types/host.d.ts +9 -4
- package/types/src/host-messages.d.ts +2 -0
- package/types/src/remote.d.ts +7 -1
- package/types/src/ui-messages.d.ts +10 -2
|
@@ -128,60 +128,49 @@ CREATE INDEX idx_products_name_search ON products USING gin(to_tsvector('english
|
|
|
128
128
|
```
|
|
129
129
|
|
|
130
130
|
### API 设计规范
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
res.json({
|
|
177
|
-
data: user,
|
|
178
|
-
meta: { timestamp: new Date().toISOString() }
|
|
179
|
-
});
|
|
180
|
-
} catch (error) {
|
|
181
|
-
next(error);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
);
|
|
131
|
+
```yaml
|
|
132
|
+
# 独立的 API 契约示例
|
|
133
|
+
openapi: 3.1.0
|
|
134
|
+
info:
|
|
135
|
+
title: User Service API
|
|
136
|
+
version: 1.0.0
|
|
137
|
+
paths:
|
|
138
|
+
/api/users/{id}:
|
|
139
|
+
get:
|
|
140
|
+
operationId: getUserById
|
|
141
|
+
security:
|
|
142
|
+
- oauth2: [users:read]
|
|
143
|
+
parameters:
|
|
144
|
+
- name: id
|
|
145
|
+
in: path
|
|
146
|
+
required: true
|
|
147
|
+
schema:
|
|
148
|
+
type: string
|
|
149
|
+
format: uuid
|
|
150
|
+
- name: X-Correlation-ID
|
|
151
|
+
in: header
|
|
152
|
+
required: false
|
|
153
|
+
schema:
|
|
154
|
+
type: string
|
|
155
|
+
responses:
|
|
156
|
+
'200':
|
|
157
|
+
description: User found
|
|
158
|
+
'404':
|
|
159
|
+
description: User not found
|
|
160
|
+
'429':
|
|
161
|
+
description: Rate limit exceeded
|
|
162
|
+
'503':
|
|
163
|
+
description: Dependency unavailable
|
|
164
|
+
components:
|
|
165
|
+
securitySchemes:
|
|
166
|
+
oauth2:
|
|
167
|
+
type: oauth2
|
|
168
|
+
flows:
|
|
169
|
+
authorizationCode:
|
|
170
|
+
authorizationUrl: https://auth.example.com/authorize
|
|
171
|
+
tokenUrl: https://auth.example.com/token
|
|
172
|
+
scopes:
|
|
173
|
+
users:read: Read user profiles
|
|
185
174
|
```
|
|
186
175
|
|
|
187
176
|
## 你的沟通风格
|
|
@@ -65,11 +65,12 @@ color: orange
|
|
|
65
65
|
|
|
66
66
|
## 技术交付物
|
|
67
67
|
|
|
68
|
-
### Spark
|
|
68
|
+
### Spark 管线(开源 PySpark + Delta Lake)
|
|
69
69
|
|
|
70
70
|
```python
|
|
71
|
+
from datetime import date
|
|
71
72
|
from pyspark.sql import SparkSession
|
|
72
|
-
from pyspark.sql.functions import col, current_timestamp, sha2, concat_ws, lit
|
|
73
|
+
from pyspark.sql.functions import col, current_timestamp, sha2, concat_ws, lit, input_file_name
|
|
73
74
|
from delta.tables import DeltaTable
|
|
74
75
|
|
|
75
76
|
spark = SparkSession.builder \
|
|
@@ -82,7 +83,7 @@ def ingest_bronze(source_path: str, bronze_table: str, source_system: str) -> in
|
|
|
82
83
|
df = spark.read.format("json").option("inferSchema", "true").load(source_path)
|
|
83
84
|
df = df.withColumn("_ingested_at", current_timestamp()) \
|
|
84
85
|
.withColumn("_source_system", lit(source_system)) \
|
|
85
|
-
.withColumn("_source_file",
|
|
86
|
+
.withColumn("_source_file", input_file_name())
|
|
86
87
|
df.write.format("delta").mode("append").option("mergeSchema", "true").save(bronze_table)
|
|
87
88
|
return df.count()
|
|
88
89
|
|
|
@@ -106,8 +107,18 @@ def upsert_silver(bronze_table: str, silver_table: str, pk_cols: list[str]) -> N
|
|
|
106
107
|
source.write.format("delta").mode("overwrite").save(silver_table)
|
|
107
108
|
|
|
108
109
|
# ── Gold:业务聚合指标 ─────────────────────────────────────────
|
|
109
|
-
def build_gold_daily_revenue(
|
|
110
|
-
|
|
110
|
+
def build_gold_daily_revenue(
|
|
111
|
+
silver_orders: str, gold_table: str, start_date: date, end_date: date
|
|
112
|
+
) -> None:
|
|
113
|
+
# 重新计算一个明确的左闭右开日期窗口,包括没有销售的日期。
|
|
114
|
+
# 如果从已完成的行推导边界,没有数据的那一天会残留过期的收入。
|
|
115
|
+
if start_date >= end_date:
|
|
116
|
+
raise ValueError("start_date must be earlier than end_date")
|
|
117
|
+
predicate = (
|
|
118
|
+
f"order_date >= '{start_date.isoformat()}' "
|
|
119
|
+
f"AND order_date < '{end_date.isoformat()}'"
|
|
120
|
+
)
|
|
121
|
+
df = spark.read.format("delta").load(silver_orders).filter(predicate)
|
|
111
122
|
gold = df.filter(col("status") == "completed") \
|
|
112
123
|
.groupBy("order_date", "region", "product_category") \
|
|
113
124
|
.agg({"revenue": "sum", "order_id": "count"}) \
|
|
@@ -115,10 +126,14 @@ def build_gold_daily_revenue(silver_orders: str, gold_table: str) -> None:
|
|
|
115
126
|
.withColumnRenamed("count(order_id)", "order_count") \
|
|
116
127
|
.withColumn("_refreshed_at", current_timestamp())
|
|
117
128
|
gold.write.format("delta").mode("overwrite") \
|
|
118
|
-
.option("replaceWhere",
|
|
129
|
+
.option("replaceWhere", predicate) \
|
|
119
130
|
.save(gold_table)
|
|
120
131
|
```
|
|
121
132
|
|
|
133
|
+
`_source_file` 必须记录 Spark 实际读取的文件,而不是数据里一个名叫 `_metadata.file_path` 的字段。这个开源 Spark 示例使用 [PySpark `input_file_name`](https://spark.apache.org/docs/3.5.6/api/python/reference/pyspark.sql/api/pyspark.sql.functions.input_file_name.html),这样即使源 JSON 里含有 `_metadata`,也无法冒充物理文件的 URI。请按你实际部署的运行环境调整来源记录方式;[Databricks 文件元数据 API](https://docs.databricks.com/aws/en/ingestion/file-metadata-column) 也说明了它与源数据中名为 `_metadata` 的列之间的冲突。
|
|
134
|
+
|
|
135
|
+
针对请求的日期窗口,要基于完整的 Silver 快照刷新 Gold 层,而不是一批不完整的事件。Delta 的 `replaceWhere` 即使在聚合结果为空时,也会精确地替换这个窗口;窗口之外的日期必须保持不变。保持它默认开启的谓词约束检查。例如,一笔订单退款后刷新 `[2026-09-01, 2026-09-02)`,必须移除 9 月 1 日的旧收入,同时保留 9 月 2 日及之后的结果。参见 [Delta 选择性覆盖写入](https://docs.delta.io/delta-batch/#selective-overwrite)。
|
|
136
|
+
|
|
122
137
|
### dbt 数据质量契约
|
|
123
138
|
|
|
124
139
|
```yaml
|
|
@@ -72,16 +72,23 @@ SELECT * FROM comments WHERE post_id = ?;
|
|
|
72
72
|
EXPLAIN ANALYZE
|
|
73
73
|
SELECT
|
|
74
74
|
p.id, p.title, p.content,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
COALESCE(
|
|
76
|
+
json_agg(json_build_object(
|
|
77
|
+
'id', c.id,
|
|
78
|
+
'content', c.content,
|
|
79
|
+
'author', c.author
|
|
80
|
+
) ORDER BY c.id) FILTER (WHERE c.id IS NOT NULL),
|
|
81
|
+
'[]'::json
|
|
82
|
+
) AS comments
|
|
80
83
|
FROM posts p
|
|
81
84
|
LEFT JOIN comments c ON c.post_id = p.id
|
|
82
85
|
WHERE p.user_id = 123
|
|
83
86
|
GROUP BY p.id;
|
|
84
87
|
|
|
88
|
+
-- 回归用例:没有评论 => [];两条评论 => 两个按顺序排列的对象。
|
|
89
|
+
-- FILTER 去掉 LEFT JOIN 产生的那一行全为 NULL 的合成行;COALESCE 让空聚合
|
|
90
|
+
-- 返回和有数据时相同形状的数组。
|
|
91
|
+
|
|
85
92
|
-- 检查查询计划:
|
|
86
93
|
-- 关注:Seq Scan(差)、Index Scan(好)、Bitmap Heap Scan(尚可)
|
|
87
94
|
-- 对比:实际时间 vs 预估时间,实际行数 vs 预估行数
|
|
@@ -152,11 +159,16 @@ const supabase = createClient(
|
|
|
152
159
|
}
|
|
153
160
|
);
|
|
154
161
|
|
|
155
|
-
// Serverless
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
162
|
+
// Serverless 场景使用服务商提供的事务模式连接池连接串。
|
|
163
|
+
// 只有当服务商使用相同的主机/凭据、且端口为 6543 时才这样做:
|
|
164
|
+
// 修改的是 URL 的端口,绝不能替换凭据或数据库名里恰好匹配的子串。
|
|
165
|
+
function transactionPoolUrl(connectionString?: string): string | undefined {
|
|
166
|
+
if (!connectionString) return undefined;
|
|
167
|
+
const url = new URL(connectionString);
|
|
168
|
+
url.port = '6543';
|
|
169
|
+
return url.toString();
|
|
170
|
+
}
|
|
171
|
+
const pooledUrl = transactionPoolUrl(process.env.DATABASE_URL);
|
|
160
172
|
```
|
|
161
173
|
|
|
162
174
|
## 关键规则
|
|
@@ -89,9 +89,10 @@ jobs:
|
|
|
89
89
|
needs: test
|
|
90
90
|
runs-on: ubuntu-latest
|
|
91
91
|
steps:
|
|
92
|
+
- uses: actions/checkout@v3
|
|
92
93
|
- name: Build and Push
|
|
93
94
|
run: |
|
|
94
|
-
docker build -t app:${{ github.sha }} .
|
|
95
|
+
docker build -t registry/app:${{ github.sha }} .
|
|
95
96
|
docker push registry/app:${{ github.sha }}
|
|
96
97
|
|
|
97
98
|
deploy:
|
|
@@ -170,15 +171,23 @@ resource "aws_cloudwatch_metric_alarm" "high_cpu" {
|
|
|
170
171
|
comparison_operator = "GreaterThanThreshold"
|
|
171
172
|
evaluation_periods = "2"
|
|
172
173
|
metric_name = "CPUUtilization"
|
|
173
|
-
namespace = "AWS/
|
|
174
|
-
|
|
174
|
+
namespace = "AWS/EC2"
|
|
175
|
+
dimensions = {
|
|
176
|
+
AutoScalingGroupName = aws_autoscaling_group.app.name
|
|
177
|
+
}
|
|
178
|
+
# 与 EC2 基础监控每五分钟发布一次数据的间隔保持一致。
|
|
179
|
+
period = "300"
|
|
175
180
|
statistic = "Average"
|
|
176
181
|
threshold = "80"
|
|
182
|
+
# 缺失的遥测数据是"未知",不能当作 CPU 正常的证据。
|
|
183
|
+
treat_missing_data = "missing"
|
|
177
184
|
|
|
178
185
|
alarm_actions = [aws_sns_topic.alerts.arn]
|
|
179
186
|
}
|
|
180
187
|
```
|
|
181
188
|
|
|
189
|
+
在启用告警之前,先对照实际发布的数据点,确认它的命名空间、指标名、维度和采集频率。`CPUUtilization` 属于 [AWS/EC2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/viewing_metrics_with_cloudwatch.html) 命名空间,`AutoScalingGroupName` 用来选中这个应用的实例。`AWS/ApplicationELB` 发布的是负载均衡器的指标,而不是实例的 CPU。EC2 基础监控每五分钟发布一次数据;如果需要一分钟级别的检测,要显式开启详细监控。把缺失的数据视为未知,并单独监控遥测数据的丢失。
|
|
190
|
+
|
|
182
191
|
### 监控与告警配置
|
|
183
192
|
```yaml
|
|
184
193
|
# Prometheus 配置
|
|
@@ -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
|
## 你的身份与记忆
|