update-pi-setting
This commit is contained in:
1 parent
f87918f15b
commit
755f598792
5 files changed
+14
-63
No files matched your search
@@ -50,5 +50,5 @@ rg -n "::dwgInFields|::dwgOutFields|::Draw2d|::Draw3d|::copyFrom|::subTransformB
|
||||
|
||||
## 5. 改动纪律
|
||||
|
||||
- 一次只改一类问题,改完立刻编 + 跑 `verify-utf8`,不要攒。
|
||||
- 一次只改一类问题,改完立刻编 + 确认 `.cpp/.h` 的 UTF-8 BOM 未丢(`head -c 3 文件` 应显示 BOM),不要攒。
|
||||
- 决定"不做"的项也要写进文档并给出理由,避免下一轮重复讨论(仓库里已有多处这种记录)。
|
||||
@@ -46,7 +46,7 @@ git push origin HEAD:refs/for/main/<分支名>
|
||||
|
||||
- [ ] `git status --short` 干净,无临时文件、无 `cmake_output/` 之类产物
|
||||
- [ ] `git diff --numstat` 不是整文件重写
|
||||
- [ ] 改过 `.cpp/.h` → 跑 `verify-utf8` skill
|
||||
- [ ] 改过 `.cpp/.h` → `git diff --numstat` 确认不是整文件重写(BOM 只在整文件重写时才会丢)
|
||||
- [ ] 至少编过受影响的 target(`build-arx` skill)
|
||||
- [ ] **没做过 CAD 实测就在 PR 里写明"仅编译验证"**,并列出待实测项
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
---
|
||||
name: verify-utf8
|
||||
description: Check and repair UTF-8 BOM and Chinese text encoding in SourceCode/Code2026 sources. Use after every edit of a .cpp or .h file in this repo, and before committing.
|
||||
---
|
||||
|
||||
# 编码自检与修复
|
||||
|
||||
仓库约定:`SourceCode/Code2026/**/*.cpp|*.h` 全部是 **UTF-8 with BOM**;
|
||||
`cmakelists.txt` / `CMakeLists.txt` 保持 **ASCII 无 BOM**。
|
||||
|
||||
## 自检
|
||||
|
||||
对每个改动过的文件跑:
|
||||
|
||||
```bash
|
||||
python -c "d=open('路径','rb').read(); print(d[:3], d.count(b'\xef\xbf\xbd'))"
|
||||
```
|
||||
|
||||
判读:
|
||||
|
||||
| 输出 | 含义 | 处理 |
|
||||
| --- | --- | --- |
|
||||
| `b'\xef\xbb\xbf' 0` | 正确 | 通过 |
|
||||
| `b'\xef\xbb\xbf' N`(N>0) | 有 U+FFFD 替换字符,中文已损坏 | **不可逆**,见下 |
|
||||
| 不是 `\xef\xbb\xbf` 开头 | 缺 BOM(或是 GBK/UTF-16 老文件) | 补 BOM / 先探明编码再改 |
|
||||
|
||||
批量检查一次:
|
||||
|
||||
```bash
|
||||
python - <<'EOF'
|
||||
import glob
|
||||
for p in glob.glob('SourceCode/Code2026/**/*.cpp', recursive=True) + \
|
||||
glob.glob('SourceCode/Code2026/**/*.h', recursive=True):
|
||||
d = open(p, 'rb').read()
|
||||
if not d.startswith(b'\xef\xbb\xbf') or b'\xef\xbf\xbd' in d:
|
||||
print(p, d[:3], d.count(b'\xef\xbf\xbd'))
|
||||
EOF
|
||||
```
|
||||
|
||||
## 写坏了怎么办
|
||||
|
||||
1. **不要**在损坏文件上继续改(越改越乱)
|
||||
2. `git checkout HEAD -- <file>` 还原
|
||||
3. 重新用 `edit` 工具做定点替换,不要整体重写文件
|
||||
4. 再跑一次自检
|
||||
|
||||
## 改文件时的注意事项
|
||||
|
||||
- 优先用 `edit`(精确文本替换),避免 `write` 整文件覆盖——整覆盖最容易丢 BOM。
|
||||
- 从旧分支/旧机器检出、仍为 GBK 或 UTF-16 的文件,先探明编码再动,不要假设。
|
||||
- 编辑 `cmakelists.txt` 时确认没有引入 BOM。
|
||||
@@ -5,11 +5,12 @@
|
||||
|
||||
## pi 环境说明
|
||||
|
||||
- 内置工具只有 `read` / `write` / `edit` / `bash`,**没有独立的 grep / glob / web 工具**:
|
||||
搜索一律在 `bash` 里用 `rg`,联网靠 `curl` 或额外插件。
|
||||
- 已启用 `read` / `write` / `edit` / `bash` + `grep` / `find` / `ls` / `powershell`:
|
||||
搜内容/找文件/列目录用 `grep` / `find` / `ls` 工具(尊重 .gitignore、自带输出上限),不要退回 `bash` 里手搓 `rg` / `ls`;
|
||||
Windows 侧命令用 `powershell` 工具(自带 UTF-8 输出),不要从 `bash` 里 spawn `powershell`。联网仍靠 `curl`。
|
||||
- 超长文件用 `read` 的 `offset` / `limit` 分段读:
|
||||
`AecDbEwFitting.cpp` 17453 行、`AecDbEwEquipment.cpp` 14290 行、`AecDbEwPipe.cpp` 5002 行。
|
||||
- 类名与文件名不一定一致,搜之前先 `rg -n "ACRX_DXF_DEFINE_MEMBERS" <文件>` 确认
|
||||
- 类名与文件名不一定一致,搜之前先用 `grep` 工具搜 `ACRX_DXF_DEFINE_MEMBERS` 确认
|
||||
(例:`AecDbSlab.cpp` 里的类叫 `AecDbXSlab`)。
|
||||
|
||||
## 省 token(每次调用都按上下文长度计费,早期内容会被后面每次调用反复付费)
|
||||
@@ -17,6 +18,7 @@
|
||||
- 等进程 / 等图纸加载 / 等构建:用**一次** `bash` 内循环(`for i in $(seq 60); do …; sleep 5; done`),不要反复起调用轮询。
|
||||
- 可能超过 100 行的输出一律收窄:`| head -c 4000`、`grep -c`、`git diff --stat`、`tail -30`;禁止 `cat` 大文件、构建产物、`*.map`。
|
||||
- 查符号先用 `codegraph_explore`(或 `codegraph explore/callers/impact`),不要 `rg` 打十几轮再用 python heredoc 切片源码。
|
||||
- 单文件改写一律用 `edit` 工具(实测保留 UTF-8 BOM);只有跨文件批量正则 / 扫描统计才写 python,并把脚本落到 `%TEMP%` 再执行一次,不要把上百行脚本塞进命令行。
|
||||
|
||||
## 红线(违反了会污染仓库或造成不可逆损坏)
|
||||
|
||||
@@ -52,9 +54,11 @@
|
||||
一键脚本:`tools/run_acad_perf.ps1`
|
||||
|
||||
```powershell
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File tools\run_acad_perf.ps1
|
||||
& tools\run_acad_perf.ps1
|
||||
```
|
||||
|
||||
(`powershell` 工具已自带 `-NoProfile -ExecutionPolicy Bypass`,不要再手写 `powershell -NoProfile …`。)
|
||||
|
||||
它的做法:写一个只含 `ENVIPERFDUMP` 的 `.scr`,用 `/b` 让 AutoCAD 在**图纸载入完成后**执行;
|
||||
报告落 `%TEMP%\aec_section_perf.txt`;收完报告按 PID 结束**本次拉起的** acad,
|
||||
脚本里不写 QUIT,所以不会弹保存对话框、不会回写图纸。
|
||||
@@ -72,7 +76,6 @@ powershell -NoProfile -ExecutionPolicy Bypass -File tools\run_acad_perf.ps1
|
||||
| skill | 用途 |
|
||||
| --- | --- |
|
||||
| `build-arx` | 按 preset 编译、单 target、产物与部署路径 |
|
||||
| `verify-utf8` | UTF-8 BOM 自检、写坏后的回滚 |
|
||||
| `pr-flow` | 分支命名 / 中文 commit / `refs/for/main` 推送 |
|
||||
| `analyze-big-entity` | 万行实体类的分析与改动套路 |
|
||||
| `notify-decision` | 需要用户拍板时主动推送通知(桌面 toast / IM 机器人),不让他干等终端 |
|
||||
@@ -82,7 +85,7 @@ powershell -NoProfile -ExecutionPolicy Bypass -File tools\run_acad_perf.ps1
|
||||
## CodeGraph(代码知识图谱)
|
||||
|
||||
本仓库已 `codegraph init`(索引在 `.codegraph/`,已 gitignore,约 700 MB)。
|
||||
适合回答 rg 做不到的问题:**谁调用 / 改了会影响谁 / 某个流程怎么串起来的**。
|
||||
适合回答 grep 做不到的问题:**谁调用 / 改了会影响谁 / 某个流程怎么串起来的**。
|
||||
|
||||
- MCP 工具 `codegraph_explore`(已挂进 pi,`~/.pi/agent/mcp.json`,exposure=direct);
|
||||
- 命令行等价:`codegraph explore "<问题>"`、`codegraph callers <符号>`、
|
||||
|
||||
+3
-4
@@ -11,7 +11,6 @@
|
||||
```
|
||||
AGENTS.md pi 启动时自动加载的上下文文件
|
||||
.pi/skills/build-arx/ preset / target / 产物路径
|
||||
.pi/skills/verify-utf8/ UTF-8 BOM 自检与回滚
|
||||
.pi/skills/pr-flow/ 分支 / 中文 commit / refs/for/main
|
||||
.pi/skills/analyze-big-entity/ 万行实体类分析套路
|
||||
.pi/prompts/build.md /build [preset] [target]
|
||||
@@ -192,10 +191,10 @@ pi -c :: 1. 先续上会话(或直接 pi 开新的)
|
||||
## 7. 其他已知坑
|
||||
|
||||
1. **pi 不读 `CODEBUDDY.md`**,只认 `AGENTS.override.md` / `AGENTS.md` / `CLAUDE.md`(含大小写变体)。
|
||||
2. **内置工具只有 `read` / `write` / `edit` / `bash`**,没有独立的 grep / glob / web 工具:
|
||||
搜索用 `bash` 调 `rg`,联网靠 `curl` 或插件。
|
||||
2. 内置工具是 `read` / `write` / `edit` / `bash`,另外开了 `grep` / `find` / `ls` / `powershell`:
|
||||
搜内容/找文件用对应工具,Windows 侧命令用 `powershell` 工具(自带 UTF-8 输出)。联网靠 `curl`。
|
||||
3. **源码必须 UTF-8 with BOM**,`cmakelists.txt` 保持 ASCII 无 BOM。中文写坏不可逆,只能
|
||||
`git checkout HEAD -- <file>` 重做。改完照 skill `verify-utf8` 自检。
|
||||
`git checkout HEAD -- <file>` 重做。`edit` 工具实测会保留 BOM,**不要用 `write` 整文件覆盖**。
|
||||
4. **类名与文件名可能不一致**(`AecDbSlab.cpp` 里是 `AecDbXSlab`),搜之前先
|
||||
`rg -n "ACRX_DXF_DEFINE_MEMBERS"`。
|
||||
5. **Windows Terminal 首次启动**会走初始化(接受协议、选配色)。
|
||||
Reference in new issue
Block a user