完成差旅发票录入流程

This commit is contained in:
wandering
2026-06-11 19:22:34 +08:00
parent cf567c22f2
commit 10115214aa
50 changed files with 3033 additions and 2756 deletions

19
.agents/README.md Normal file
View File

@@ -0,0 +1,19 @@
---
last_reviewed: 2026-06-11
---
# .agents — 项目内部维护目录
本目录存放维护人员与自动化代理相关资料,不属于对外公开的用户文档。
## 目录结构
| 子目录 | 说明 |
|--------|------|
| `docs/` | 维护文档:规范、经验总结、实施方案、操作指南 |
| `skills/` | Cursor Agent 技能:定义自动化工作流和代码检查流程 |
## 文档边界
- 面向开源用户、外部贡献者的公开文档统一放置在项目根目录 `docs/` 下。
- 维护规范、实施方案、经验总结、拉取请求佐证材料与各类内部记录资料,均统一放置在本目录下。

View File

@@ -0,0 +1,36 @@
---
last_reviewed: 2026-06-11
---
# 出现问题好的排查流程
## 出现问题后的排查流程
```
日志报错
├─ 1. 定位错误源码
│ 根据日志标签 + 错误信息 → 找到报错函数和校验条件
├─ 2. 分析日志时间线
│ 对比错误时间与前后事件 → 判断是主流程还是试探性调用
├─ 3. 编写诊断脚本(隔离测试)
│ │
│ ├─ 正常 save/load 循环 → 确认基础路径是否健康
│ ├─ 编码异常检测 → BOM、GBK 混入等
│ ├─ 数据流变更检测 → 前端编辑/外部写入后列结构变化
│ └─ 回退链检测 → glob 扫描到非预期文件
├─ 4. 最小化复现
│ 针对失败的测试用例,提取最简输入证明根因
└─ 5. 修复 + 验证
最小改动修复 → 确认不影响正常输入
```
## 关键判断点
- 错误不影响主流程 → 优先排查试探性调用和回退链
- 列名校验失败但文件肉眼正常 → 优先检查 BOM 和不可见字符
- 错误出现在外部数据入口 → 优先检查编码兼容性和数据清洗

17
.agents/skills/README.md Normal file
View File

@@ -0,0 +1,17 @@
---
last_reviewed: 2026-06-11
---
# .agents/skills — Cursor Agent 技能目录
存放 Cursor Agent 可调用的自动化技能定义。
## 技能清单
| 技能 | 说明 |
|------|------|
| `pre-commit-check/` | 提交前代码质量检查:运行 ruff lint/format、mypy 类型检查、deptry 依赖审计,自动修复可修复问题 |
## 使用方式
Agent 在用户请求提交代码或检查代码质量时自动触发对应技能,无需手动调用。

View File

@@ -0,0 +1,68 @@
---
name: pre-commit-check
description: >-
Run pre-commit code quality checks (ruff lint/format, mypy type check, deptry dependency audit)
and fix any issues before committing. Use when the user wants to commit code, asks to check code
quality, or mentions pre-commit validation. Also use when preparing code for submission or
when the user says "check before commit" or "run checks".
---
# Pre-Commit Code Quality Check
## Workflow
Run all checks in parallel first, then fix any issues iteratively:
```
Step 1: Run checks (parallel)
- uv run ruff check .
- uv run ruff format --check .
- uv run mypy src/
- uv run deptry .
Step 2: If any check fails, fix issues
- ruff check --fix . (auto-fix lint issues)
- ruff format . (auto-format)
- Fix type annotation errors manually
Step 3: Re-run all checks to confirm
Step 4: Report results with table
```
## Common Fixes
| Error | Fix |
|-------|-----|
| `UP038` | Replace `isinstance(e, (X, Y))` with `isinstance(e, X \| Y)` |
| `no-untyped-def` | Add return type annotation (`-> None` for void functions) |
| `I001` | Run `uv run ruff check --fix .` |
| `no-any-return` | Use `cast(Type, expression)` from `typing` |
| `type-arg` missing | Add type arguments: `dict[str, Any]` instead of `dict` |
| `unused-ignore` | Remove stale `# type: ignore` comments |
## Type Annotation Rules
- Functions that modify data in-place and return nothing: `-> None`
- Functions that call untyped external APIs: add `-> Any` return type
- Dicts that hold mixed types (str + float): use `dict[str, Any]`
- Import `Any` from `typing` when needed
- Import `cast` from `typing` when `no-any-return` triggers
## Verification Report
After all checks pass, report:
| 检查项 | 状态 |
|--------|------|
| `ruff check .` | ✅ |
| `ruff format --check .` | ✅ |
| `mypy src/` | ✅ |
| `deptry .` | ✅ |
## Notes
- All commands use `uv run` prefix (project virtual environment)
- `mypy` has `strict = true` in `pyproject.toml` - expect strict type checking
- `ignore_missing_imports = true` is set, so missing third-party stubs are OK
- If `tests.*` override shows "unused section" note, it's normal (no tests dir yet)
- Never skip a check - all four must pass before committing