|
Download docs/compose/spec/agentlens.md from hongcoding/agentlens: direct link, hf CLI and curl.
- Browser
- Download file 8.5 kB
-
https://huggingface.co/datasets/hongcoding/agentlens/resolve/main/docs/compose/spec/agentlens.md
- Command line
-
hf download hf://datasets/hongcoding/agentlens/docs/compose/spec/agentlens.md
-
curl -L -o agentlens.md https://huggingface.co/datasets/hongcoding/agentlens/resolve/main/docs/compose/spec/agentlens.md
8.5 kB
| feature: agentlens | |
| status: delivered | |
| updated: 2026-11-19 | |
| source: agentlens | |
| # AgentLens — AI 编程 Agent 配置迁移 + 产出体检 | |
| ## Report | |
| **What was built** — AgentLens v0.1.0: a CLI + MCP server for (1) cross-agent config migration (Claude/Cursor/Codex/Windsurf/Copilot), (2) config drift detection, and (3) adversarial code QA. All rules parsed into a unified IR and re-generated per target agent. Pure local, no server dependency. | |
| **Verification** — `npm test`: 46/46 passing across 6 test files. `npx tsc --noEmit`: clean. `npm run build`: dist/ generated. E2E verified: scan (5 agents detected), move (claude→windsurf/cursor), drift (11 issues across 37 rules), check (3 critical vulnerabilities detected), install (auto-detected 3 tools on this machine), mcp (stdio server runs). VS Code extension bundled (32KB) and packaged as agentlens-0.1.0.vsix (30KB). | |
| ## [S1] Problem | |
| 开发者同时使用多个 AI 编程 Agent(Claude Code、Cursor、Codex、Windsurf 等),每个 Agent 有自己的配置格式(CLAUDE.md、.cursor/rules/、AGENTS.md 等)。两个真实痛点: | |
| 1. **配置迁移难**:用户在一个 Agent 里积累的规则、偏好、工作流习惯,换到另一个 Agent 时需要手动重写。规则散落在 N 个位置 × M 个仓库,"知识 90% 相同但维护 N 份"。现有同步工具只管复制文件,不管规则是否已经失效("一模一样的烂规则副本还是烂规则")。 | |
| 2. **产出不信任**:46% 开发者不信任 AI 输出,66% 最大挫败是"几乎正确但不完全对"。开发者自己写 10+ 个 hook 做对抗式审查,但没有现成商业产品。官方文档承认插件评测是空白。 | |
| ## [S2] Design | |
| ### 产品定位 | |
| 一个 CLI + MCP Server,服务两类场景: | |
| - **迁移(Move)**:解析、归一化、转换 AI Agent 的规则配置,一键在 Agent 之间搬运 | |
| - **体检(Check)**:对 Agent 产出的代码/改动做对抗式审查,输出风险报告 | |
| ### [S2.1] 配置迁移引擎(核心差异化) | |
| **输入**:源 Agent 类型 + 路径(自动检测当前项目里有哪些 Agent 配置) | |
| **输出**:目标 Agent 格式的配置文件 | |
| 支持的 Agent 配置格式(MVP 阶段): | |
| | Agent | 配置文件 | 解析 | | |
| |---|---|---| | |
| | Claude Code | CLAUDE.md, .claude/rules/*.md | ✅ | | |
| | Cursor | .cursor/rules/*.mdc | ✅ | | |
| | Codex | AGENTS.md | ✅ | | |
| | Windsurf | .windsurfrules | ✅ | | |
| | 通用 | .editorconfig, .github/copilot-instructions.md | ✅ | | |
| **归一化模型**:所有规则解析为统一中间表示(IR): | |
| ``` | |
| Rule { | |
| id: string | |
| category: "style" | "workflow" | "constraint" | "context" | "tooling" | |
| content: string # 规则正文 | |
| scope: "global" | "project" | "path-glob" | |
| source: { agent, file, line } | |
| status: "active" | "suspect" | "stale" | |
| } | |
| ``` | |
| **漂移检测**(在迁移之外的附加价值): | |
| - 同一规则在多处出现但内容不一致 → 标记 drift | |
| - 规则引用的工具/路径/文件不存在 → 标记 stale | |
| - 输出漂移报告,建议保留哪个版本 | |
| ### [S2.2] Agent 产出体检引擎 | |
| **输入**:代码片段 / git diff / 文件路径 | |
| **输出**:结构化体检报告 | |
| 检查维度(MVP 优先做前三个): | |
| 1. **正确性**:边界条件、空值处理、类型错误、逻辑漏洞 | |
| 2. **安全**:注入、越权、敏感信息泄露、不安全的依赖 | |
| 3. **规范符合**:是否违反用户配置中的规则(与 S2.1 联动) | |
| 4. 性能隐患(后续) | |
| 5. 测试覆盖建议(后续) | |
| **运行方式**: | |
| - CLI: `agentlens check <diff|file>` | |
| - MCP Server: 注册为 MCP 工具,Claude Code / Cursor 等可直接调用 | |
| - Hook: 接入 Agent 的 post-write hook(如 Claude Code hooks) | |
| ### [S2.3] 技术架构 | |
| **跨 Agent 通用策略**(用户核心需求):不为每个 Agent 单独写插件,而是通过 **MCP Server + CLI** 双形态覆盖所有主流工具: | |
| | 目标工具 | 接入方式 | 安装后效果 | | |
| |---|---|---| | |
| | Claude Code | MCP Server | 工具列表出现 agentlens 命令 | | |
| | Cursor | MCP Server | .cursor/mcp.json 注册后可用 | | |
| | Codex | MCP Server | MCP 配置注册后可用 | | |
| | MiMo Desktop | MCP Server | MCP 设置里添加后可用 | | |
| | DSH / WorkBuddy / ZCode | CLI + MCP | 支持 MCP 的走 MCP,否则走 CLI | | |
| | 任何终端 | CLI | `npx agentlens` 直接用 | | |
| **一键安装**:`npx agentlens install --target <agent>` 自动检测本机已装的 Agent,把 MCP 配置写入对应配置文件(.mcp.json / CLAUDE.md / .cursor/settings 等),装完后各 Agent 的工具面板/设置里即出现 AgentLens 命令(scan / move / check / drift)。 | |
| ``` | |
| agentlens/ | |
| ├── src/ | |
| │ ├── core/ # IR 模型、解析器注册表 | |
| │ ├── parsers/ # 各 Agent 配置解析器(claude.ts, cursor.ts, codex.ts, windsurf.ts...) | |
| │ ├── migrator/ # IR → 目标格式生成器 | |
| │ ├── drift/ # 漂移检测引擎 | |
| │ ├── checker/ # 产出体检引擎 | |
| │ ├── mcp/ # MCP Server 入口 | |
| │ ├── install/ # 一键安装到各 Agent 的配置写入器 | |
| │ └── cli/ # CLI 入口 | |
| ├── tests/ | |
| └── docs/ | |
| ``` | |
| - **语言**:TypeScript(Node.js),与 MCP SDK(@modelcontextprotocol/typescript-sdk)天然亲和 | |
| - **分发**:npm 包(`npx agentlens`),MCP Registry 注册 | |
| - **无服务器依赖**:纯本地运行,代码不出机器(隐私卖点) | |
| ### [S2.4] 交互流程 | |
| **迁移流程**: | |
| ``` | |
| $ agentlens scan | |
| 发现 3 个 Agent 配置: | |
| ✅ CLAUDE.md (47 条规则) | |
| ✅ .cursor/rules/ (12 条规则) | |
| ✅ AGENTS.md (8 条规则) | |
| ⚠️ 检测到 3 处漂移、2 条疑似失效规则 | |
| $ agentlens move --from claude --to cursor | |
| 转换 47 条规则 → .cursor/rules/agentlens.mdc | |
| ✅ 完成。预览?(y/n) | |
| $ agentlens drift | |
| 漂移报告:... | |
| ``` | |
| **体检流程**: | |
| ``` | |
| $ agentlens check HEAD~1..HEAD | |
| 检查 12 个文件变更... | |
| 🔴 2 个高危 | 🟡 5 个警告 | ⚪ 8 个通过 | |
| [详细报告] | |
| ``` | |
| ## [S3] Out of Scope | |
| - 不做云端同步/账号系统(纯本地工具) | |
| - 不做 Agent 本身的替代或封装(不做 "又一个 AI 编程助手") | |
| - 不做实时监听/自动修复(MVP 只做检测+报告) | |
| - 不做非编程 Agent(如通用聊天机器人)的配置 | |
| - 不做付费/许可证系统(MVP 开源,后续再加商业版) | |
| ## Tasks | |
| - [x] T1: 项目脚手架 — TypeScript + vitest + MCP SDK 初始化,CLI 骨架可运行 — acceptance: `npx agentlens --help` 输出帮助信息 | |
| - [x] T2: 配置解析器 — 解析 CLAUDE.md / .cursor/rules / AGENTS.md 为统一 IR — acceptance: 对 3 种格式的测试样本,解析出完整规则列表且字段正确 (covers: S2.1) | |
| - [x] T3: 迁移生成器 — IR → 目标 Agent 格式输出 — acceptance: claude→cursor / cursor→claude / codex→claude 三组转换测试通过 (covers: S2.1) | |
| - [x] T4: 漂移检测 — 检测同规则不一致、失效引用 — acceptance: 构造漂移样本能正确报告 drift/stale 项 (covers: S2.1) | |
| - [x] T5: 体检引擎 MVP — 对 diff 做正确性+安全+规范检查 — acceptance: 对含已知漏洞的测试代码,报告能标出注入/越权/空指针 (covers: S2.2) | |
| - [x] T6: MCP Server — 注册 scan/move/check/install 为 MCP 工具 — acceptance: Claude Desktop / Cursor 可通过 MCP 调用 agentlens 工具 (covers: S2.2, S2.3) | |
| - [x] T7: 一键安装器 — `agentlens install` 自动检测本机 Agent 并写入 MCP 配置 — acceptance: 在装有 Claude Code 的机器上运行 install 后,Claude Code 工具列表出现 agentlens 命令 (covers: S2.3) | |
| - [x] T8: CLI 集成 — scan/move/check/drift 子命令完整可用 — acceptance: 端到端跑通扫描→迁移→体检全流程 (covers: S2.4) | |
| - [x] T9: 测试与文档 — 单测覆盖 + README + npm 发布准备 — acceptance: `npm test` 全绿,README 含安装和使用示例 | |
| - [x] T10: App 集成(用户新增需求)— VS Code/Cursor 扩展(.vsix,设置面板可见)+ 自动检测安装器 — acceptance: .vsix 可安装且命令出现在命令面板/设置;`agentlens install` 自动检测并写入各工具 MCP 配置 (covers: S2.3) | |
| ## Journey log | |
| - 2026-11-19: 调研阶段发现"Agent 产出 QA"和"配置漂移检测"是 Agent 工具生态中竞争最少的两个缺口(详见 research/market-gap-opportunities/)。用户决定将两者合并为一个产品。 | |