Skip to content

Commit 5900165

Browse files
committed
chore(workspace): create baseline migration scaffold
Why: - establish a verifiable Rust workspace baseline before feature migration - lock environment, git workflow, and AI collaboration rules into the repo What: - add workspace skeleton, environment scripts, githooks, docs, fixtures, and tests - add baseline README and migration/environment documentation Verify: - just env-check - just verify-basic
0 parents  commit 5900165

65 files changed

Lines changed: 4018 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.githooks/commit-msg

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
msg_file="${1:-}"
5+
6+
if [[ -z "$msg_file" || ! -f "$msg_file" ]]; then
7+
echo "[commit-msg] missing commit message file"
8+
exit 1
9+
fi
10+
11+
first_line="$(sed -n '1p' "$msg_file")"
12+
pattern='^(env|docs|rules|chore|test|refactor|migration|fix)\([a-z0-9._/-]+\): .+'
13+
14+
if [[ ! "$first_line" =~ $pattern ]]; then
15+
echo "[commit-msg] invalid commit title"
16+
echo "[commit-msg] expected: <type>(<scope>): <summary>"
17+
echo "[commit-msg] allowed types: env, docs, rules, chore, test, refactor, migration, fix"
18+
echo "[commit-msg] example: migration(config): add fixture-driven loader"
19+
exit 1
20+
fi

.githooks/pre-commit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "[pre-commit] running cargo fmt --all --check"
5+
cargo fmt --all --check

.githooks/pre-push

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "[pre-push] running just verify-basic"
5+
just verify-basic

.github/pull_request_template.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## 变更类型
2+
3+
- [ ] 小型 bug 修复或局部实现修正
4+
- [ ] 中大型变更(模块边界、配置结构、工程约束、迁移策略、公共接口)
5+
6+
## 文档同步检查
7+
8+
- [ ] 本次变更不需要更新文档
9+
- [ ] 本次变更已经同步更新相关文档
10+
- [ ] 本次变更需要后续补文档,原因已写明
11+
12+
## 文档影响说明
13+
14+
请明确回答下面至少一项:
15+
16+
- 影响的文档:
17+
- 不影响文档的原因:
18+
- 延后补文档的原因与计划:
19+
20+
## 自检
21+
22+
- [ ] 我已检查本次变更是否影响 `README.md`
23+
- [ ] 我已检查本次变更是否影响 `docs/architecture.md`
24+
- [ ] 我已检查本次变更是否影响 `docs/migration-strategy.md`
25+
- [ ] 我已检查本次变更是否需要写入 `docs/dev-journal/`

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches: ["main", "master"]
6+
pull_request:
7+
8+
jobs:
9+
verify:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Install Rust toolchain
15+
uses: dtolnay/rust-toolchain@stable
16+
with:
17+
components: rustfmt, clippy
18+
19+
- name: Restore cargo cache
20+
uses: Swatinem/rust-cache@v2
21+
22+
- name: Install cargo-nextest
23+
uses: taiki-e/install-action@cargo-nextest
24+
25+
- name: cargo fmt
26+
run: cargo fmt --all --check
27+
28+
- name: cargo clippy
29+
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
30+
31+
- name: cargo nextest
32+
run: cargo nextest run --workspace --all-features
33+
34+
- name: cargo doc tests
35+
run: cargo test --doc --workspace

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/target
2+
/.idea
3+
/.vscode/*.code-workspace
4+
/coverage
5+
/artifacts
6+
/*.profraw
7+
/lcov.info
8+
/.omc

.gitmessage

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<type>(<scope>): <summary>
2+
3+
Why:
4+
-
5+
6+
What:
7+
-
8+
9+
Verify:
10+
-

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rust-analyzer.check.command": "clippy",
3+
"rust-analyzer.check.allTargets": true,
4+
"rust-analyzer.cargo.targetDir": true
5+
}

AGENTS.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# AGENTS
2+
3+
## 目标
4+
5+
这个文件定义 TrendRadar Rust 仓库内的 AI 协作边界。
6+
7+
目标不是限制正常开发,而是确保 AI 参与时:
8+
9+
- 能读懂当前工程约束
10+
- 能执行固定命令
11+
- 能验证自己的改动
12+
- 不能绕过仓库边界失控修改
13+
14+
## 工作范围
15+
16+
当前阶段只允许进行环境准备、文档完善、测试骨架和工程约束收敛。
17+
18+
在明确进入功能迁移阶段之前,默认不做下面这些事情:
19+
20+
- 不迁移旧系统业务逻辑
21+
- 不扩真实抓取、存储、报告和通知功能
22+
- 不引入与当前迁移阶段无关的外部服务接入
23+
24+
## 默认工作方式
25+
26+
- 先检索和理解,再编辑
27+
- 优先复用现有文档结构和命令入口
28+
- 结构性改动必须同步更新 `README.md``docs/` 或开发日志
29+
- 所有改动都应留在当前 Git 工作树内
30+
- 分支与提交命名应遵循 `docs/git-workflow.md`
31+
32+
## 允许执行的命令
33+
34+
默认允许:
35+
36+
- `cargo fmt --all`
37+
- `cargo fmt --all --check`
38+
- `cargo check --workspace --all-targets`
39+
- `cargo clippy --workspace --all-targets --all-features -- -D warnings`
40+
- `cargo test --workspace`
41+
- `cargo test --doc --workspace`
42+
- `cargo nextest run --workspace --all-features`
43+
- `cargo deny check`
44+
- `cargo llvm-cov nextest --workspace --all-features`
45+
- `just *`
46+
- `./scripts/bootstrap.sh`
47+
- `./scripts/check_environment.sh`
48+
- `./scripts/doc_sync_reminder.sh`
49+
- `git status`
50+
- `git diff`
51+
- `git switch`
52+
- `git branch`
53+
54+
## 禁止范围
55+
56+
默认禁止:
57+
58+
- 修改生产 secrets 或本机敏感凭据
59+
- 修改部署、账务、权限或外部系统管理脚本
60+
- 绕过当前仓库去写无关目录
61+
- 不经说明直接重写大量已有文档或代码
62+
- 在没有验证的情况下声称迁移完成
63+
64+
## 文档同步要求
65+
66+
出现下面任一情况时,必须同步更新文档:
67+
68+
- 调整 workspace 或 crate 边界
69+
- 调整验证命令、脚本或 CI 入口
70+
- 新增或删除迁移基线规则
71+
- 修改 AI 协作方式、任务切分方式或完成标准
72+
73+
优先更新的文档包括:
74+
75+
- `README.md`
76+
- `docs/environment-setup.md`
77+
- `docs/migration-strategy.md`
78+
- `docs/module-map.md`
79+
- `docs/invariants.md`
80+
- `docs/api-contracts.md`
81+
- `docs/dev-journal/`
82+
83+
## 任务切分协议
84+
85+
默认任务单位应为下面之一:
86+
87+
- 一个环境脚本
88+
- 一份规则文档
89+
- 一个验证入口
90+
- 一条系统测试骨架
91+
- 一个 crate 的非业务性工程整理
92+
93+
当前阶段不使用“整仓业务重写”作为任务单位。
94+
95+
## 完成标准
96+
97+
对当前环境准备阶段,一个任务要被视为完成,至少应满足:
98+
99+
- 改动范围清楚
100+
- 对应文档已同步
101+
- 至少运行一条相关验证命令
102+
- 最终结果可以通过 Git diff 审查
103+
- 分支名和提交标题符合仓库 Git 规范
104+
105+
## 进入功能迁移前的门槛
106+
107+
在进入具体功能迁移前,仓库应至少具备:
108+
109+
- Git 工作树和基础分支流程
110+
- 明确的迁移基线文档
111+
- 明确的 AI 协作规则
112+
- 稳定的环境检查和验证命令入口
113+
- 最小系统性测试模板和样例目录

0 commit comments

Comments
 (0)