# plan — 泛微E10计划报告

`plan` 模块把 E10「计划报告」的两套报告侧接口链路（e10 标准版 / e10-ebuilder 版）收敛成一组业务 operation，供人和 Agent 统一调用。源资料为「E10 标准报告和 eb 报告整合 skill」目录下的标准版接口说明、ebuilder 其他接口说明、ebuilder 自定义接口说明与补充说明规则。

## 模块来源

- `e10标准版本计划报告接口说明文档.docx`：新建报告、修改报告、发布报告、撤回报告、按报告 id 或按周期查询单个报告详情、分页查询共享我的报告、发送报告提交提醒、获取某个报告的评论。
- `e10-ebuilder版本计划报告其他接口说明文档.docx`：eb 链路发布报告（secondev 二开接口）、撤回报告（ESB 动作流）。
- `e10-ebuilder版本计划报告自定义接口说明文档.zip`：创建报告、编辑报告、按周期查询单个报告详情、分页查询报告、查询报告版本信息。
- `补充说明规则.txt`：意图判定、版本路由、作业步骤链、eb/标准版专属规则、通用基础规则。

## CLI 结构

```text
weaver-work-cli plan --help
weaver-work-cli plan schema
weaver-work-cli --json plan run <operation> --input-json '<json>'
weaver-work-cli --json plan run <operation> --input <path>
```

便捷子命令（均为薄包装，最终调用同一 operation）：

- `plan route` → `plan.version.check`
- `plan get` → `plan.report.get`
- `plan list` → `plan.report.page`

源码结构：

```text
src/shortcuts/plan/
  index.ts            Commander 命令注册、schema/run、便捷子命令
  manifest.ts         operation 合约清单、链路路由元信息、禁用边界
  operations.ts       run 入口：选择 handler、校验输入、统一执行
  errors.ts           结构化错误（validation/authentication/network/api/policy/confirmation/partial）
  host.ts             E10 请求适配 + 租户级缓存读写
  continuation.ts     prepare/apply 写入链的确认凭据签发与校验
  operations/
    registry.ts       manifest 与 handler 一一对应校验
    types.ts          operation 类型、统一 JSON Schema 片段、报告枚举与标签
    shared.ts         输入校验、字段归一化、报告结构归一化、默认提醒文案
    link.ts           版本路由与租户缓存、eb 表单 id 解析、报告详情查询
    version.ts        plan.version.check、plan.eb.form.resolve
    read.ts           plan.report.get、plan.report.page、plan.comment.list
    write.ts          新建/修改/发布/撤回/提交提醒的 prepare 与 apply
```

## operation 表

| operation | 风险 | 说明 |
| --- | --- | --- |
| `plan.version.check` | read | 判定租户报告链路（缓存 1 天；`ver_name=V2` → eb） |
| `plan.eb.form.resolve` | read | 解析 eb 报告详情表单 id（idobjId），按租户长期缓存 |
| `plan.report.get` | read | 按 id 或按周期查询单份报告详情，附带评论总条数（标准版） |
| `plan.report.page` | read | 分页查询报告列表 |
| `plan.comment.list` | read | 报告评论内容（标准版） |
| `plan.report.create.prepare` / `.apply` | read-before-write / high-risk-write | 新建报告（含周期查重） |
| `plan.report.update.prepare` / `.apply` | read-before-write / high-risk-write | 修改报告 |
| `plan.report.publish.prepare` / `.apply` | read-before-write / high-risk-write | 发布报告 |
| `plan.report.withdraw.prepare` / `.apply` | read-before-write / high-risk-write | 撤回报告（标准版） |
| `plan.report.remind.prepare` / `.apply` | read-before-write / high-risk-write | 发送提交提醒（标准版） |

## 关键设计

- **链路路由由 CLI 负责**：`plan_searchAppver` 读到 `ver_name = V2` 走 eb 链路，其它走标准版；结果按租户缓存 1 天。Agent 只传业务字段，不选接口。
- **输出归一化**：eb 链路的 `f_*` 字段统一归一化为业务键（`reportId` / `title` / `content` / `summary` / `plans` / `year` / `type` / `serialNumber` / `postStatus` / `postTime` / `creator` / `detailUrl`），避免把数据库字段名暴露给 Agent 与用户。
- **详情页链接**：标准版 `/sp/plan/detail/{id}`；eb 版 `/sp/ebdfpage/card/0/{表单id}/{id}`，表单 id 由 `plan.eb.form.resolve` 解析并长期缓存，租户 `tt1pa2w2i3` 使用固定值。
- **写入链**：`prepare` 只读回查 + 预览 + 签发 continuation；`apply` 强制 `confirm=true` 与有效 continuation，并校验登录上下文与链路未变化。写请求发出后网络中断返回 `partial/write_uncertain`，禁止自动重试。
- **查重**：`create.prepare` 与 `create.apply` 都会按周期查重；已存在时 `prepare` 返回 `ALREADY_EXISTS`，`apply` 直接报 `report_exists`，杜绝重复创建。

## 已知限制

- eb 链路「撤回报告」是 ESB 动作流，源资料未提供动作流唯一标识（uniqueIndent），本模块不实现；改用 weaver-e10-customesb-execute skill 执行同名动作流。对应 `plan.report.withdraw.*` 在 eb 链路返回 `policy/link_unsupported`。
- eb 链路未提供报告提交提醒、报告评论接口，`plan.report.remind.*`、`plan.comment.list` 在 eb 链路返回 `policy/link_unsupported`。
- eb 链路没有「按报告 id 查询详情」的接口，只有按周期查询；`prepare` 阶段若缺少 `year`/`type`/`serialNumber` 会跳过写入前校验并在 `warnings` 中说明。
- 标准版分页接口语义为「共享给我的报告」，不支持按创建人筛选，传入 `creatorUserId` 会被忽略并返回警告。

## 安全边界

- 只调用 `/api/` 前缀路径，拒绝跨域、路径逃逸与协议外地址。
- 认证、Cookie、ETEAMSID、User-Agent 由 `src/internal/e10` 统一托管；业务输入不接收凭证。
- 不读取、不打印认证目录与认证文件。
- 租户缓存只落地版本判定结果与 eb 表单 id，不缓存任何凭证或报告正文。
