# Author 信息获取


本节从原 SKILL.md 的「Step 0.5: 获取 Author 信息」拆分而来，详细说明如何在生成 @UnittestCaseInfo 注解前自动获取并缓存作者信息。


## Step 0.5: 获取 Author 信息

在生成 `@UnittestCaseInfo` 注解前，按以下优先级获取作者信息：

### 优先级 1：从缓存文件读取（快速路径）

尝试读取 `.qoder/skills/cosmic-unittest/author-cache.json`：

```json
{
  "author": "zhang_san <zhang_san@kingdee.com>",
  "lastUpdateAuthor": "zhang_san <zhang_san@kingdee.com>"
}
```

若文件存在且 `author` 字段非空，**直接使用缓存值，跳过 git config 命令**。

### 优先级 2：从 git config 读取并写入缓存

若缓存文件不存在或 `author` 为空，执行：

```bash
git config user.name
git config user.email
```

读取成功后：
1. 按格式拼接：`"<name> <<name>@kingdee.com>"`，例如 `"zhang_san <zhang_san@kingdee.com>"`
2. **将结果写入 `.qoder/skills/cosmic-unittest/author-cache.json`**，供后续直接复用

### 优先级 3：询问用户

若 git config 读取失败，主动询问用户提供姓名和邮箱，填写后同样写入缓存文件。

### .gitignore 检查

首次写入 `author-cache.json` 后，检查项目根目录的 `.gitignore` 是否已包含该文件的忽略规则：

```
.qoder/skills/cosmic-unittest/author-cache.json
```

若未忽略，**提示用户将上述规则添加到 `.gitignore`**，避免个人信息被提交到 git 仓库。

---

> `lastUpdateTime` = 用例编写时的当前时间，格式 `yyyy-MM-dd HH:mm:ss`

---