From 587a215d880a004c16e419628e180a1aaaf4e636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9A=E9=80=9A?= Date: Fri, 12 Jun 2026 22:37:46 +0800 Subject: [PATCH] =?UTF-8?q?docs(agents.md):=E4=BC=98=E5=8C=96=20agent.md?= =?UTF-8?q?=E5=8F=8A=EF=BC=8Ccode-comments.mdc=E5=8D=87=E7=BA=A7=EF=BC=9B?= =?UTF-8?q?=20=E8=A7=84=E5=88=92=E4=B8=89=E5=B1=82=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=EF=BC=88=E6=96=87=E4=BB=B6=E3=80=81=E5=87=BD=E6=95=B0=E3=80=81?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=89=EF=BC=9B=E6=B3=A8=E9=87=8A=E4=B8=8D?= =?UTF-8?q?=E4=BB=85=E7=BB=99=E4=BA=BA=E7=9C=8B=EF=BC=8C=E6=9B=B4=E5=86=99?= =?UTF-8?q?=E7=BB=99=20AI=20=E7=9C=8B=EF=BC=8C=E7=9B=B4=E6=8E=A5=E5=86=B3?= =?UTF-8?q?=E5=AE=9A=E5=A4=A7=E6=A8=A1=E5=9E=8B=E7=9A=84=E5=88=A4=E6=96=AD?= =?UTF-8?q?=EF=BC=9B=E5=BA=9F=E9=99=A4=E6=97=A0=E6=84=8F=E4=B9=89=E7=9A=84?= =?UTF-8?q?=E9=80=90=E8=A1=8C=E8=AF=AD=E6=B3=95=E7=BF=BB=E8=AF=91=E3=80=82?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E7=A4=BA=E8=AF=8D=E6=88=96=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=8F=82=E6=95=B0=E6=97=B6=EF=BC=8C=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=20[PROMPT=5FUPDATE]=20=E7=AD=89=E4=B8=93?= =?UTF-8?q?=E5=B1=9E=E6=A0=87=E7=AD=BE=E8=AE=B0=E5=BD=95=E2=80=9C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=8E=9F=E5=9B=A0=E2=80=9D=EF=BC=8C=E5=91=8A=E5=88=AB?= =?UTF-8?q?=E7=8E=84=E5=AD=A6=E8=B0=83=E5=8F=82=EF=BC=9B=E7=BB=86=E5=88=99?= =?UTF-8?q?=E5=B7=B2=E5=86=99=E5=85=A5=20.cursor/rules=EF=BC=8CAI=20?= =?UTF-8?q?=E5=8A=A9=E6=89=8B=E5=B0=86=E8=87=AA=E5=8A=A8=E8=AF=BB=E5=8F=96?= =?UTF-8?q?=E5=B9=B6=E8=BE=85=E5=8A=A9=E6=89=A7=E8=A1=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cursor/rules/code-comments copy.mdc | 70 ++++++++++ .cursor/rules/code-comments.mdc | 74 +++++++--- .gitignore | 2 + AGENTS copy.md | 196 +++++++++++++++++++++++++++ AGENTS.md | 62 ++++----- 5 files changed, 351 insertions(+), 53 deletions(-) create mode 100644 .cursor/rules/code-comments copy.mdc create mode 100644 AGENTS copy.md diff --git a/.cursor/rules/code-comments copy.mdc b/.cursor/rules/code-comments copy.mdc new file mode 100644 index 00000000..ecd5edf3 --- /dev/null +++ b/.cursor/rules/code-comments copy.mdc @@ -0,0 +1,70 @@ +--- +description: 文件层与函数层注释强制规范(撰写与调整代码时均适用) +alwaysApply: true +--- + +# 代码注释(强制) + +撰写或**修改**代码时,必须补齐或更新两层注释。完整说明见 `AGENTS.md` §5。 + +## 文件层(文件顶部) + +块注释须包含:**用途**、**主要 import/依赖**、**与上下游文件的逻辑关系**。 + +```typescript +/** + * features/kb/composables/useKbWorkspace.ts + * 用途:知识库作业面编排入口,组合 state / computed / data 等子模块。 + * 依赖:kb-workspace/* composables、kb.api、kb-display.utils。 + * 逻辑:KbWorkspaceView 调用本 composable;本文件再分发至 useKbWorkspaceData 等子模块。 + */ +``` + +```python +""" +services/kb_sync.py + +用途:知识库文档与 Dify 之间的同步编排。 +依赖:dify_service、models.KbDocument、minio_service。 +逻辑:由 api/knowledge_base 路由调用;内部委托 chunking 与 job 状态机。 +""" +``` + +## 函数层(每个函数定义上方) + +须说明:**用途**、**核心逻辑与实现方式**、**参数**与**返回值**(及异常)。 + +```typescript +/** + * 加载当前分组下的文档列表,并在静默刷新时合并 stable 项避免闪烁。 + * 核心逻辑:调用 getKbGroupFilesSafe,按 mergeStableItems 策略合并新旧列表。 + * @param options.silent - 为 true 时不切换 loading,用于轮询刷新 + * @returns 是否成功拉取到数据 + */ +async function loadDocuments(options?: LoadListOptions): Promise { ... } +``` + +```python +def sync_document_to_dify(document_id: int, *, force: bool = False) -> SyncResult: + """ + 将指定文档切片同步至 Dify 知识库。 + + 核心逻辑:读 MinIO 原文 → 切块 → 调 Dify API upsert;失败写入 KbJob 供重试。 + + Args: + document_id: 本地 KbDocument 主键。 + force: 为 True 时忽略已完成状态强制重同步。 + + Returns: + SyncResult: 含 dify_document_id 与分段数。 + + Raises: + KbNotFoundError: 文档不存在或无权限。 + """ +``` + +## 修改既有文件时 + +- 改函数逻辑/签名 → 同步改该函数注释。 +- 改 import 或模块协作关系 → 同步改文件头注释。 +- Vue SFC:`