[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-fjb040911--ai-rules":3,"tool-fjb040911--ai-rules":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",156033,2,"2026-04-14T23:32:00",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,"2026-04-10T11:39:34",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":75,"owner_location":75,"owner_email":76,"owner_twitter":75,"owner_website":75,"owner_url":77,"languages":78,"stars":83,"forks":84,"last_commit_at":85,"license":75,"difficulty_score":32,"env_os":86,"env_gpu":87,"env_ram":87,"env_deps":88,"category_tags":92,"github_topics":93,"view_count":32,"oss_zip_url":75,"oss_zip_packed_at":75,"status":17,"created_at":99,"updated_at":100,"faqs":101,"releases":102},7601,"fjb040911\u002Fai-rules","ai-rules","ai-rules is a governance framework designed to solve \"Architectural Decay\" in AI-driven development. It forces AI Agents (Cursor, Windsurf, Copilot) to respect your project's boundaries, UI libraries, and design patterns.","ai-rules 是一款专为 AI 辅助开发设计的治理框架，旨在解决代码生成过程中的“架构衰退”问题。在使用 Cursor、Windsurf 或 Copilot 等 AI 编程助手时，它们生成的代码虽然语法正确，却常忽视项目特定的架构边界、UI 库规范或设计模式，导致层级混乱或安全隐患。ai-rules 通过将项目的工程标准转化为结构化规则（如 Markdown 配置文件），在代码进入审查或合并前，为 AI 提供明确的“操作契约”。\n\n该工具适合追求高质量代码规范的软件开发团队及资深开发者使用。其核心亮点在于不仅能定义规则，还能利用轻量级本地证据和抽象语法树（AST）技术，对前端 JS\u002FTS\u002FVue 代码进行深度静态分析。它能精准识别诸如 UI 组件直接调用数据层、危险的 HTML 注入、硬编码密钥或违反 React\u002FVue 最佳实践等行为，并生成确定性的审计与修复提示。这使得 AI 生成的代码从源头就符合架构要求，大幅减少人工复查成本，让自动化编码流程更加稳定可靠。","\u003Cp align=\"center\">\n  \u003Cimg src=\"assets\u002Flogo.svg\" alt=\"AI-RULES logo\" width=\"720\">\n\u003C\u002Fp>\n\n# AI-RULES\n\nAI-RULES is a rule-aware CLI for AI-assisted coding governance. It turns project rules in Markdown into structured rule metadata, lightweight local evidence, and deterministic audit\u002Ffix prompts so AI coding agents follow your architecture, design patterns, and UI standards more consistently.\n\n## Why AI-RULES\n\nAI coding agents are powerful, but they often write \"generally correct\" code instead of code that fits your repository's real architecture. They may call data layers from UI components, bypass service boundaries, ignore project-specific directories, leak secrets in logs, or return audit reports in shapes that downstream repair flows cannot reliably consume.\n\nAI-RULES gives those agents a project-local operating contract before code reaches review, CI, or merge gates. It packages your engineering standards into `.ai-rules.md`, `rules-config.json`, and `config.json`, then turns them into rule-aware audit and fix prompts with enabled rules, severity thresholds, local evidence, path aliases, exceptions, and repair guidance.\n\nThe practical benefits are:\n\n- AI-generated code is more likely to follow your architecture and layering rules from the start.\n- Reviews become faster because repeated violations are encoded once instead of explained every time.\n- Prompts become more deterministic because rules, paths, severity, and report schema are structured.\n- Non-standard repository layouts are handled through `config.json` path aliases instead of editing every rule.\n- Audit and repair workflows become more stable across Codex, Cursor, Claude Code, or any prompt-driven coding setup.\n\nIn short: repository governance tools protect the merge boundary; AI-RULES guides the AI while it is still writing and repairing code.\n\n## What It Does\n\n- Initializes reusable rule templates for different stacks\n- Parses `.ai-rules\u002F.ai-rules.md` and `rules-config.json`\n- Merges `extends` chains for rules and config\n- Resolves high-level AST config from template defaults, detected project config, and local AI-RULES overrides\n- Collects lightweight local evidence for `regex` and `import\u002Finclude` style rules\n- Collects lightweight local evidence for minimal `count` rules such as `function-lines` and `params-count`\n- Collects AST-backed local evidence for a first supported slice of frontend JS\u002FTS\u002FVue rules\n- Supports config-level `thresholds` for active parameterized rule behavior\n- Supports config-level `exceptions` to suppress known-safe files per rule pattern\n- Generates rule-aware audit prompts instead of static prompt text\n- Normalizes and validates `ai-rule-report.json`\n- Generates stronger fix prompts using both the report and local rule metadata\n\n## High-Value Built-In Coverage\n\nCurrent templates already cover a first batch of high-priority engineering rules in addition to the original architecture baseline.\n\n### Frontend \u002F React \u002F Vue\n\n- First AST-backed frontend local evidence is now supported for selected JS\u002FTS rules\n- UI code must not call network or data layers directly\n- Raw HTML injection via `innerHTML` \u002F `dangerouslySetInnerHTML` is flagged and can now produce AST-backed local evidence\n- Semantic XSS flows from untrusted rich content into DOM sinks are called out\n- Dynamic execution via `eval()` \u002F `Function()` is flagged and can now produce AST-backed local evidence\n- Hardcoded frontend secrets \u002F API keys are flagged\n- Third-party HTML script tags without SRI are flagged\n- Hooks must follow React hook call rules\n- React lists should not use array index as `key`, with AST-backed local evidence for supported React files\n- React effect-driven remote requests should use stable dependency control\n- Vue `computed` must stay pure\n- Vue props must not be mutated directly, with AST-backed local evidence for supported `.vue` files\n- Vue lists should not use loop index as `:key`, with AST-backed local evidence for supported `.vue` files\n- Direct DOM access in Vue components is discouraged\n\n### Python Base \u002F FastAPI\n\n- Bare `except` and broad swallowed exceptions are discouraged\n- Mutable default arguments are flagged\n- Weak password hashing algorithms such as MD5\u002FSHA1 are flagged\n- Logging patterns that may leak sensitive values are flagged\n- External HTTP calls should define explicit timeouts\n- Python functions should stay below configured line-count thresholds\n- Python function signatures should stay below configured parameter-count thresholds\n- FastAPI routes should not access repositories or DB sessions directly\n- SQL built through interpolation\u002Fconcatenation in FastAPI code is flagged\n- FastAPI request logging must avoid tokens, cookies, auth headers, and raw credentials\n- FastAPI endpoints should use Pydantic input models\n- FastAPI endpoints should declare explicit `response_model`\n- List-style FastAPI endpoints should enforce pagination or limit bounds\n- Async paths should avoid blocking HTTP clients and `time.sleep`\n\n### Java \u002F Spring\n\n- Controllers should not depend on repositories directly\n- Controllers should stay thin and avoid business branching\u002Forchestration\n- `@Valid` should guard `@RequestBody` inputs\n- Overly permissive CORS is flagged\n- Exception handlers that may leak stack traces are flagged\n- Logging patterns that may expose credentials are flagged\n- Sensitive Spring endpoints should have explicit authn\u002Fauthz coverage\n- Overly permissive Spring Security config such as broad `permitAll()` or global protection disablement is flagged\n- Write paths should define transaction boundaries\n- `@Transactional` should not live on controllers\n- Write-oriented service logic should keep explicit transaction semantics\n- Loops should not perform unbounded remote calls without batching, timeouts, and concurrency control\n- Business exceptions should stay distinct from system\u002Finfrastructure failures\n\n## Current Scope\n\nAI-RULES is not a full static analysis engine yet.\n\n- `regex` and `import\u002Finclude` detection can collect local evidence\n- minimal `count` detection can collect local evidence for `function-lines` and `params-count`\n- selected frontend `ast` rules can now produce parser-backed local evidence\n- unsupported `ast` rules and `semantic` rules remain AI-guided and treated as `ai-only`\n- The CLI helps structure context and outputs, while the AI still makes the final audit decision\n\n## Language Support\n\nBuilt-in locale files are available for:\n\n- `zh-CN`: Simplified Chinese, complete\n- `en`: English, complete\n- `zh-TW`: Traditional Chinese, partial, falls back to English\n- `ja`: Japanese, partial, falls back to English\n- `ko`: Korean, partial, falls back to English\n- `es`: Spanish, partial, falls back to English\n- `fr`: French, partial, falls back to English\n\nThe partial locales currently translate the core template names and prompt instructions. Missing rule-level text automatically falls back to English so new languages remain usable while translations are expanded over time.\n\n## Installation\n\nRequires Node.js `>=18`.\n\nInstall globally:\n\n```bash\nnpm install -g ai-law\n```\n\nOr for local development in this repository:\n\n```bash\nnpm install\nnpm test\n```\n\n## Quick Start\n\n```bash\ncd your-project\n\n# 1. Initialize rules in the current project\nai-law init\n\n# 2. Check that rules\u002Fconfig are valid\nai-law doctor\n\n# 3. Generate a rule-aware audit prompt\nai-law audit\n\n# 4. `audit` also writes local helper files by default\n#    - .ai-rules\u002Fcache\u002Faudit-context.json\n#    - .ai-rules\u002Fcache\u002Fai-rule-report.template.json\n\n# 5. Or inspect the structured audit context directly\nai-law audit --json\n\n# 6. Optionally force a fresh context dump\nai-law audit --dump-context\n\n# 7. After your AI tool produces ai-rule-report.json, validate it\nai-law validate-report\n\n# 8. Generate a fix prompt for one issue\nai-law fix --issueId ISSUE-001\n\n# 9. Or generate a grouped fix prompt for the whole report\nai-law fix --all --group-by-rule\n```\n\n## Workflow\n\n### 1. Initialize\n\n`ai-law init` creates a `.ai-rules\u002F` directory in your project and materializes the selected template.\n\nExample layout:\n\n```text\n.ai-rules\u002F\n├── .ai-rules.md\n├── rules-config.json\n├── config.json\n├── base\u002F\n│   ├── .ai-rules.md\n│   ├── rules-config.json\n│   └── config.json\n└── cache\u002F\n    ├── audit-context.json\n    └── ai-rule-report.template.json\n```\n\n### 2. Validate Local Rule Setup\n\n`ai-law doctor` validates:\n\n- `.ai-rules\u002F` exists\n- `rules-config.json` can be loaded and merged through `extends`\n- the rules file can be parsed\n- `enabledRuleIds` point to real rules\n- rule scopes match config scopes\n- required rule fields exist\n\nUse `ai-law doctor --strict` to treat warnings as failures.\n\n### 3. Generate Audit Context\n\n`ai-law audit` now reads the current project rules and builds a prompt from:\n\n- merged config\n- parsed rules\n- enabled rule IDs\n- local evidence candidates\n- strict report schema requirements\n\nUseful variants:\n\n```bash\nai-law audit --locale zh-CN\nai-law audit --json\nai-law audit --summary\nai-law audit --dry-run\nai-law audit --dump-context\n```\n\n`--json` prints the structured audit context instead of a prompt.\n\nBy default, `ai-law audit` writes:\n\n- `.ai-rules\u002Fcache\u002Faudit-context.json`\n- `.ai-rules\u002Fcache\u002Fai-rule-report.template.json`\n\nUse the generated prompt with your AI tool, then save the AI result as `ai-rule-report.json` in the project root.\n\n`--dump-context` forces a fresh write of `.ai-rules\u002Fcache\u002Faudit-context.json`.\n`--summary` prints enabled-rule counts, local-vs-AI coverage, suppressed files, and configured thresholds.\n`--dry-run` prints include\u002Fexclude patterns, rule IDs that can run locally, AI-only rule IDs, and active exception patterns.\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ffjb040911_ai-rules_readme_f436f3ba2ad0.png\" alt=\"Example AI-RULES audit report output\" width=\"880\">\n\u003C\u002Fp>\n\nAudit report example: the AI returns a structured `ai-rule-report.json` that can be validated and fed into the next repair step.\n\n### 4. Validate The AI Report\n\nAfter your AI tool returns `ai-rule-report.json`, run:\n\n```bash\nai-law validate-report\n```\n\nThis command normalizes legacy or drifted report shapes into a stable structure and checks for issues like:\n\n- missing `issueId`\n- missing `ruleId`\n- duplicate `issueId`\n- invalid `severity`\n\nYou can inspect the normalized report with:\n\n```bash\nai-law validate-report --json\n```\n\n### 5. Generate Fix Prompts\n\n`ai-law fix` now combines:\n\n- normalized report data\n- local rule metadata from `.ai-rules`\n- rule intent \u002F requirement \u002F fix guidance\n- context assets\n- report evidence and snippets when present\n\nExamples:\n\n```bash\nai-law fix --issueId ISSUE-001\nai-law fix --id ARCH-101\nai-law fix --all\nai-law fix --all --group-by-rule\n```\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ffjb040911_ai-rules_readme_17be1352f5b5.png\" alt=\"Example AI-RULES fix prompt output\" width=\"880\">\n\u003C\u002Fp>\n\nFix prompt example: `ai-law fix` turns one or more report entries into a focused, patch-oriented repair prompt with rule context and evidence.\n\n## Rule Model\n\nRules are defined in `.ai-rules.md` using `RULE` blocks. The CLI currently parses fields such as:\n\n- `RULE`\n- `severity`\n- `scope`\n- `intent`\n- `fix`\n- `detect`\n- `prompt`\n- `context`\n- `extends`\n\nExample:\n\n```md\n### RULE: ARCH-101\nseverity: FATAL\nscope: ui\nintent: UI components must not initiate network requests directly.\n\ndetect:\n  regex: \"fetch\\\\(|axios\\\\.\"\n  where: filePath in src\u002Fcomponents\u002F**\nfix: Move request logic into a service layer.\nprompt:\n  violation: Detected direct request logic in UI layer.\n  requirement: UI components must not contain request logic.\n  solution: Move requests to a service and reuse shared clients.\ncontext:\n  - src\u002Fservices\u002F\n  - src\u002Fapi\u002Fclient.ts\n```\n\n## Project Path Config\n\nTemplates can provide an optional `.ai-rules\u002Fconfig.json` file for user-specific project layout overrides. This file is merged on top of `rules-config.json`, so users can adjust directory conventions without editing every rule.\n\nExample:\n\n```json\n{\n  \"pathAliases\": {\n    \"@controller\": \"app\u002Fcontrollers\",\n    \"@service\": \"app\u002Fservices\",\n    \"@repository\": \"app\u002Frepositories\",\n    \"@config\": \"app\u002Fconfig\"\n  }\n}\n```\n\nRules can reference those aliases in `context`, `detect.where`, `detect.import`, and `detect.include`:\n\n```md\ndetect:\n  include: \"@repository\u002F**\"\n  where: filePath in @controller\u002F**\ncontext:\n  - @service\n```\n\nAt audit\u002Ffix time, the CLI resolves aliases before collecting evidence or building prompts.\n\n`ai-law doctor` and `ai-law audit` warn prominently when a configured alias points to a path that does not exist. If this happens, open `.ai-rules\u002Fconfig.json` and adjust `pathAliases` to match your repository layout.\n\n## Detection Support\n\nCurrent support in the CLI:\n\n- `detect.regex`: local evidence collection supported\n- `detect.import`: local evidence collection supported\n- `detect.include`: local evidence collection supported\n- `detect.ast`: first frontend AST-backed rules now support local evidence\n- `detect.semantic`: AI-only for now\n\nCurrent AST-backed local evidence focuses on frontend JS\u002FTS projects and covers the first narrow batch of rules:\n\n- direct network calls from UI entry code such as `fetch()` \u002F `axios.*`\n- raw HTML injection such as `dangerouslySetInnerHTML` \u002F `innerHTML`\n- dynamic code execution such as `eval()` \u002F `Function()`\n- React list rendering keyed by loop index\n- Vue props mutation in `.vue` script blocks\n- Vue list rendering keyed by loop index in `.vue` templates\n- TypeScript `any` usage in TS\u002FTSX files\n\nThis means the CLI can now attach concrete local evidence for regex\u002Fimport\u002Finclude\u002Fcount and a first slice of AST-backed frontend rules across React and Vue, while still allowing AI-guided review for higher-level semantic constraints and unsupported AST rules.\n\nThe current templates intentionally mix:\n\n- fast local rules for obvious anti-patterns\n- semantic AI-guided rules for higher-level architectural or transactional reasoning\n\n## Config Extensions\n\nThe config model now supports two rule-aware extensions:\n\n### `ast`\n\nUsed for high-level AST backend orchestration. AI-RULES keeps this config intentionally small and merges it with detected project config at runtime.\n\nExample:\n\n```json\n{\n  \"ast\": {\n    \"provider\": \"babel\",\n    \"target\": \"react\",\n    \"useProjectConfig\": true,\n    \"parserOptions\": {\n      \"sourceType\": \"module\",\n      \"plugins\": [\"jsx\", \"typescript\"]\n    }\n  }\n}\n```\n\nAt runtime, AI-RULES resolves AST settings in this order:\n\n1. template defaults\n2. detected project config such as `tsconfig.json` \u002F `.babelrc` \u002F `package.json#babel`\n3. local `.ai-rules\u002Fconfig.json` overrides\n\n### `thresholds`\n\nUsed for configurable numeric limits that active local count rules can reference.\n\nExample:\n\n```json\n{\n  \"thresholds\": {\n    \"maxFunctionLines\": 80,\n    \"maxParamsCount\": 5,\n    \"maxListLimit\": 100\n  }\n}\n```\n\n### `exceptions`\n\nUsed to suppress known-safe files for matching rule IDs or rule ID patterns during local evidence collection.\n\nExample:\n\n```json\n{\n  \"exceptions\": {\n    \"ARCH-101\": [\n      \"src\u002Fintegrations\u002F**\"\n    ],\n    \"SEC-*\": [\n      \"__mocks__\u002F**\",\n      \"**\u002F*.stories.tsx\"\n    ]\n  }\n}\n```\n\nThese exceptions currently affect local evidence collection for supported local detect modes.\n\n## Report Shape\n\nThe audit prompt requests strict JSON with a normalized structure like:\n\n```json\n{\n  \"version\": \"1.1\",\n  \"generatedAt\": \"2026-03-30T12:00:00Z\",\n  \"project\": {\n    \"cwd\": \".\",\n    \"stack\": \"react-ts\"\n  },\n  \"summary\": {\n    \"total\": 1,\n    \"fatal\": 0,\n    \"warn\": 1,\n    \"info\": 0\n  },\n  \"violations\": [\n    {\n      \"issueId\": \"ISSUE-001\",\n      \"ruleId\": \"ARCH-101\",\n      \"severity\": \"WARN\",\n      \"confidence\": 0.82,\n      \"file\": \"src\u002Fpages\u002FHome.tsx\",\n      \"line\": 12,\n      \"snippet\": \"const data = fetch('\u002Fapi')\",\n      \"description\": \"Direct network request found in UI layer.\",\n      \"fixSuggestion\": \"Move request logic into services.\",\n      \"repairPrompt\": \"Provide a minimal patch...\",\n      \"evidence\": {\n        \"source\": \"local-regex\",\n        \"matchedBy\": \"detect.regex\"\n      },\n      \"context\": [\n        \"src\u002Fservices\u002F\"\n      ]\n    }\n  ]\n}\n```\n\n## Templates\n\nCurrent templates:\n\n- `frontend-base`\n  - `react-js`\n  - `react-ts`\n  - `vue`\n- `python-base`\n  - `python-fastapi`\n- `java-base`\n  - `java-spring`\n- `c-cpp`\n\nBranch templates inherit from base templates through `extends`.\n\n## CLI Commands\n\n```bash\nai-law init\nai-law audit [--locale \u003Ccode>] [--json] [--summary] [--dry-run] [--dump-context]\nai-law fix --issueId \u003Cissue_id>\nai-law fix --id \u003Crule_id>\nai-law fix --all [--group-by-rule]\nai-law doctor [--strict]\nai-law validate-report [--json] [--path \u003Cfile>]\nai-law setup [--locale \u003Ccode>] [--provider \u003Cname>] [--write]\nai-law -v\nai-law -h\n```\n\n## Development Notes\n\nCurrent implementation layers:\n\n- `cli\u002Fsrc\u002Fcore\u002Fconfig`: config loading and `extends` merge\n- `cli\u002Fsrc\u002Fcore\u002Frules`: rule parsing and validation\n- `cli\u002Fsrc\u002Fcore\u002Fevidence`: local evidence collection\n- `cli\u002Fsrc\u002Fcore\u002Fprompt`: audit prompt assembly\n- `cli\u002Fsrc\u002Fcore\u002Freport`: report normalization and schema\n\nRun tests:\n\n```bash\nnpm test\n```\n\n## Docs\n\n- English design spec: [design\u002Fdesign-spec-en.md](design\u002Fdesign-spec-en.md)\n- 中文设计文档: [design\u002Fdesign-spec-zh.md](design\u002Fdesign-spec-zh.md)\n","\u003Cp align=\"center\">\n  \u003Cimg src=\"assets\u002Flogo.svg\" alt=\"AI-RULES logo\" width=\"720\">\n\u003C\u002Fp>\n\n# AI-RULES\n\nAI-RULES 是一款具备规则感知能力的命令行工具，专为 AI 辅助的代码治理而设计。它能够将 Markdown 格式的项目规则转化为结构化的规则元数据、轻量级本地证据以及确定性的审计与修复提示，从而帮助 AI 编码助手更一致地遵循你的架构、设计模式和 UI 标准。\n\n## 为什么选择 AI-RULES\n\nAI 编码助手功能强大，但它们往往生成的是“大致正确”的代码，而非完全符合你仓库实际架构的代码。例如，它们可能会从 UI 组件中直接调用数据层、绕过服务边界、忽略项目特定的目录结构，在日志中泄露敏感信息，或者返回下游修复流程无法可靠处理的审计报告格式。\n\nAI-RULES 在代码进入评审、CI 或合并门禁之前，为这些助手提供一份针对项目的操作契约。它将你的工程标准打包成 `.ai-rules.md`、`rules-config.json` 和 `config.json` 文件，然后将其转化为具有规则感知能力的审计和修复提示，包括启用的规则、严重性阈值、本地证据、路径别名、例外情况以及修复指导。\n\n其实际好处包括：\n\n- AI 生成的代码从一开始就更有可能遵循你的架构和分层规则。\n- 代码评审速度加快，因为重复出现的违规行为只需在规则中定义一次，而无需每次都进行解释。\n- 提示更加确定性，因为规则、路径、严重性和报告格式都经过结构化处理。\n- 非标准的仓库布局可以通过 `config.json` 中的路径别名来处理，而无需修改每一条规则。\n- 审计和修复工作流在 Codex、Cursor、Claude Code 或任何基于提示的编码环境中都更加稳定。\n\n简而言之：仓库治理工具保护的是合并边界；而 AI-RULES 则是在 AI 编写和修复代码的过程中对其进行引导。\n\n## 功能概述\n\n- 初始化适用于不同技术栈的可复用规则模板\n- 解析 `.ai-rules\u002F.ai-rules.md` 和 `rules-config.json`\n- 合并规则和配置中的 `extends` 链\n- 根据模板默认值、检测到的项目配置以及本地的 AI-RULES 覆盖，解析高级 AST 配置\n- 收集用于 `regex` 和 `import\u002Finclude` 类型规则的轻量级本地证据\n- 收集用于 `function-lines` 和 `params-count` 等最小化计数规则的轻量级本地证据\n- 收集支持的前端 JS\u002FTS\u002FVue 规则的 AST 支持的本地证据\n- 支持配置级别的 `thresholds`，以实现参数化的规则行为\n- 支持配置级别的 `exceptions`，用于按规则模式抑制已知安全的文件\n- 生成具有规则感知能力的审计提示，而非静态提示文本\n- 对 `ai-rule-report.json` 进行规范化和验证\n- 结合报告和本地规则元数据，生成更强的修复提示\n\n## 高价值内置覆盖范围\n\n当前的模板除了原始的架构基线之外，还覆盖了一批高优先级的工程规则。\n\n### 前端 \u002F React \u002F Vue\n\n- 现已支持部分 JS\u002FTS 规则的 AST 支持的本地证据\n- UI 代码不得直接调用网络或数据层\n- 通过 `innerHTML` 或 `dangerouslySetInnerHTML` 直接注入 HTML 的行为会被标记，并可生成 AST 支持的本地证据\n- 从不受信任的富内容流向 DOM 汇的语义 XSS 流会被指出\n- 通过 `eval()` 或 `Function()` 进行动态执行的行为会被标记，并可生成 AST 支持的本地证据\n- 硬编码的前端密钥或 API 密钥会被标记\n- 未使用 SRI 的第三方 HTML 脚本标签会被标记\n- Hooks 必须遵守 React Hook 调用规则\n- React 列表不应使用数组索引作为 `key`，对于支持的 React 文件，可生成 AST 支持的本地证据\n- React 基于 Effect 的远程请求应使用稳定的依赖控制\n- Vue `computed` 属性必须保持纯函数特性\n- Vue props 不得被直接修改，对于支持的 `.vue` 文件，可生成 AST 支持的本地证据\n- Vue 列表不应使用循环索引作为 `:key`，对于支持的 `.vue` 文件，可生成 AST 支持的本地证据\n- 不建议在 Vue 组件中直接访问 DOM\n\n### Python 基础 \u002F FastAPI\n\n- 建议避免使用裸 `except` 和广泛捕获异常\n- 可变默认参数会被标记\n- 弱密码哈希算法如 MD5\u002FSHA1 会被标记\n- 可能泄露敏感信息的日志记录模式会被标记\n- 外部 HTTP 调用应明确设置超时时间\n- Python 函数的行数应低于配置的阈值\n- Python 函数的参数数量应低于配置的阈值\n- FastAPI 路由不应直接访问数据库会话或存储库\n- 在 FastAPI 代码中通过插值或拼接构建的 SQL 查询会被标记\n- FastAPI 请求日志应避免记录令牌、Cookie、认证头和明文凭据\n- FastAPI 端点应使用 Pydantic 输入模型\n- FastAPI 端点应明确声明 `response_model`\n- 列表形式的 FastAPI 端点应强制实施分页或限制返回结果的数量\n- 异步路径应避免阻塞 HTTP 客户端和使用 `time.sleep`\n\n### Java \u002F Spring\n\n- 控制器不应直接依赖于存储库\n- 控制器应保持精简，避免业务分支和编排逻辑\n- `@Valid` 应用于 `@RequestBody` 输入校验\n- 过于宽松的 CORS 配置会被标记\n- 可能泄露堆栈跟踪的异常处理器会被标记\n- 可能暴露凭证的日志记录模式会被标记\n- 敏感的 Spring 端点应有明确的认证和授权保护\n- 过于宽松的 Spring Security 配置，如广泛的 `permitAll()` 或全局保护关闭，会被标记\n- 写操作应明确事务边界\n- `@Transactional` 注解不应出现在控制器上\n- 写操作相关的服务逻辑应保持明确的事务语义\n- 循环不应在没有批处理、超时和并发控制的情况下进行无限制的远程调用\n- 业务异常应与系统或基础设施故障区分开\n\n## 当前范围\n\nAI-RULES 尚未成为完整的静态分析引擎。\n\n- `regex` 和 `import\u002Finclude` 检测可以收集本地证据\n- 最小化计数检测可以收集 `function-lines` 和 `params-count` 的本地证据\n- 部分前端 `ast` 规则现在可以生成解析器支持的本地证据\n- 不支持的 `ast` 规则和语义规则仍然由 AI 引导，并被视为 `ai-only`\n- CLI 帮助组织上下文和输出，而最终的审计决策仍由 AI 做出。\n\n## 语言支持\n\n内置的本地化文件支持以下语言：\n\n- `zh-CN`: 简体中文，完整\n- `en`: 英文，完整\n- `zh-TW`: 繁体中文，部分支持，回退至英文\n- `ja`: 日文，部分支持，回退至英文\n- `ko`: 韩文，部分支持，回退至英文\n- `es`: 西班牙文，部分支持，回退至英文\n- `fr`: 法文，部分支持，回退至英文\n\n目前，这些部分支持的语言仅翻译核心模板名称和提示说明。缺失的规则级别文本会自动回退到英文，以便在翻译逐步完善的同时，新语言也能继续使用。\n\n## 安装\n\n需要 Node.js `>=18`。\n\n全局安装：\n\n```bash\nnpm install -g ai-law\n```\n\n或者在本仓库中进行本地开发时：\n\n```bash\nnpm install\nnpm test\n```\n\n## 快速入门\n\n```bash\ncd your-project\n\n# 1. 在当前项目中初始化规则\nai-law init\n\n# 2. 检查规则\u002F配置是否有效\nai-law doctor\n\n# 3. 生成一个基于规则的审计提示\nai-law audit\n\n# 4. 默认情况下，`audit` 还会写入本地辅助文件：\n#    - .ai-rules\u002Fcache\u002Faudit-context.json\n#    - .ai-rules\u002Fcache\u002Fai-rule-report.template.json\n\n# 5. 或者直接检查结构化的审计上下文\nai-law audit --json\n\n# 6. 也可以选择强制刷新上下文转储\nai-law audit --dump-context\n\n# 7. 当您的 AI 工具生成 `ai-rule-report.json` 后，对其进行验证\nai-law validate-report\n\n# 8. 为某个问题生成修复提示\nai-law fix --issueId ISSUE-001\n\n# 9. 或者为整个报告生成分组修复提示\nai-law fix --all --group-by-rule\n```\n\n## 工作流程\n\n### 1. 初始化\n\n`ai-law init` 会在您的项目中创建 `.ai-rules\u002F` 目录，并根据所选模板生成相关文件。\n\n示例目录结构：\n\n```text\n.ai-rules\u002F\n├── .ai-rules.md\n├── rules-config.json\n├── config.json\n├── base\u002F\n│   ├── .ai-rules.md\n│   ├── rules-config.json\n│   └── config.json\n└── cache\u002F\n    ├── audit-context.json\n    └── ai-rule-report.template.json\n```\n\n### 2. 验证本地规则设置\n\n`ai-law doctor` 会验证以下内容：\n\n- `.ai-rules\u002F` 目录是否存在\n- `rules-config.json` 是否可以加载并支持 `extends` 继承\n- 规则文件是否可以正确解析\n- `enabledRuleIds` 是否指向有效的规则\n- 规则的作用范围与配置范围是否匹配\n- 规则中是否包含必需字段\n\n使用 `ai-law doctor --strict` 可将警告视为错误。\n\n### 3. 生成审计上下文\n\n`ai-law audit` 现在会读取当前项目的规则，并基于以下内容构建提示：\n\n- 合并后的配置\n- 解析后的规则\n- 启用的规则 ID\n- 本地证据候选\n- 严格的报告格式要求\n\n常用选项：\n\n```bash\nai-law audit --locale zh-CN\nai-law audit --json\nai-law audit --summary\nai-law audit --dry-run\nai-law audit --dump-context\n```\n\n`--json` 会输出结构化的审计上下文，而不是提示文本。\n\n默认情况下，`ai-law audit` 会写入：\n\n- `.ai-rules\u002Fcache\u002Faudit-context.json`\n- `.ai-rules\u002Fcache\u002Fai-rule-report.template.json`\n\n您可以将生成的提示提交给您的 AI 工具，并将 AI 的结果保存为 `ai-rule-report.json` 文件到项目根目录下。\n\n`--dump-context` 会强制重新写入 `.ai-rules\u002Fcache\u002Faudit-context.json`。\n`--summary` 会打印启用的规则数量、本地与 AI 的覆盖情况、被抑制的文件以及配置的阈值。\n`--dry-run` 会打印包含\u002F排除模式、可在本地运行的规则 ID、仅由 AI 处理的规则 ID 以及生效的异常模式。\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ffjb040911_ai-rules_readme_f436f3ba2ad0.png\" alt=\"AI-RULES 审计报告示例输出\" width=\"880\">\n\u003C\u002Fp>\n\n审计报告示例：AI 返回一个结构化的 `ai-rule-report.json` 文件，该文件可以被验证，并用于下一步的修复工作。\n\n### 4. 验证 AI 报告\n\n当您的 AI 工具返回 `ai-rule-report.json` 后，运行以下命令：\n\n```bash\nai-law validate-report\n```\n\n此命令会将旧版或偏离标准的报告格式规范化为稳定的结构，并检查是否存在以下问题：\n\n- 缺少 `issueId`\n- 缺少 `ruleId`\n- 重复的 `issueId`\n- 无效的 `severity`\n\n您可以通过以下命令查看规范化的报告：\n\n```bash\nai-law validate-report --json\n```\n\n### 5. 生成修复提示\n\n`ai-law fix` 现在会结合以下内容：\n\n- 规范化的报告数据\n- 来自 `.ai-rules` 的本地规则元数据\n- 规则的意图\u002F要求\u002F修复指导\n- 上下文资产\n- 报告中的证据和代码片段（如果存在）\n\n示例：\n\n```bash\nai-law fix --issueId ISSUE-001\nai-law fix --id ARCH-101\nai-law fix --all\nai-law fix --all --group-by-rule\n```\n\n\u003Cp align=\"center\">\n  \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ffjb040911_ai-rules_readme_17be1352f5b5.png\" alt=\"AI-RULES 修复提示示例输出\" width=\"880\">\n\u003C\u002Fp>\n\n修复提示示例：`ai-law fix` 将报告中的一个或多个条目转化为专注于修复的提示，其中包含规则上下文和证据。\n\n## 规则模型\n\n规则在 `.ai-rules.md` 中以 `RULE` 块的形式定义。CLI 目前会解析以下字段：\n\n- `RULE`\n- `severity`\n- `scope`\n- `intent`\n- `fix`\n- `detect`\n- `prompt`\n- `context`\n- `extends`\n\n示例：\n\n```md\n### RULE: ARCH-101\nseverity: FATAL\nscope: ui\nintent: UI 组件不得直接发起网络请求。\n\ndetect:\n  regex: \"fetch\\\\(|axios\\\\.\"\n  where: filePath in src\u002Fcomponents\u002F**\nfix: 将请求逻辑移至服务层。\nprompt:\n  violation: 在 UI 层检测到直接请求逻辑。\n  requirement: UI 组件不应包含请求逻辑。\n  solution: 将请求移到服务层，并复用共享的客户端。\ncontext:\n  - src\u002Fservices\u002F\n  - src\u002Fapi\u002Fclient.ts\n```\n\n## 项目路径配置\n\n模板可以提供一个可选的 `.ai-rules\u002Fconfig.json` 文件，用于用户自定义的项目布局覆盖。该文件会与 `rules-config.json` 合并，因此用户可以在不修改每条规则的情况下调整目录约定。\n\n示例：\n\n```json\n{\n  \"pathAliases\": {\n    \"@controller\": \"app\u002Fcontrollers\",\n    \"@service\": \"app\u002Fservices\",\n    \"@repository\": \"app\u002Frepositories\",\n    \"@config\": \"app\u002Fconfig\"\n  }\n}\n```\n\n规则可以在 `context`、`detect.where`、`detect.import` 和 `detect.include` 中引用这些别名：\n\n```md\ndetect:\n  include: \"@repository\u002F**\"\n  where: filePath in @controller\u002F**\ncontext:\n  - @service\n```\n\n在审计或修复时，CLI 会在收集证据或构建提示之前解析这些别名。\n\n`ai-law doctor` 和 `ai-law audit` 会在配置的别名指向不存在的路径时发出显著警告。如果发生这种情况，请打开 `.ai-rules\u002Fconfig.json` 并调整 `pathAliases` 以匹配您的仓库布局。\n\n## 检测支持\n\n目前 CLI 支持的功能包括：\n\n- `detect.regex`：支持本地证据收集\n- `detect.import`：支持本地证据收集\n- `detect.include`：支持本地证据收集\n- `detect.ast`：首批基于前端 AST 的规则现已支持本地证据收集\n- `detect.semantic`：目前仅由 AI 处理\n\n当前基于 AST 的本地证据主要针对前端 JS\u002FTS 项目，涵盖第一批狭窄范围的规则：\n\n- UI 入口代码中直接发起的网络请求，如 `fetch()` \u002F `axios.*`\n- 原生 HTML 注入，如 `dangerouslySetInnerHTML` \u002F `innerHTML`\n- 动态代码执行，如 `eval()` \u002F `Function()`\n- React 列表渲染时使用循环索引作为 key\n- Vue 在 `.vue` 脚本块中修改 props\n- Vue 在 `.vue` 模板中使用循环索引作为列表 key\n- TypeScript 文件中使用 `any` 类型\n\n这意味着 CLI 现在可以为正则表达式\u002F导入\u002F包含\u002F计数等规则以及第一批基于 AST 的前端规则附上具体的本地证据，同时仍然允许通过 AI 引导来审查更高层次的语义约束和不支持 AST 的规则。\n\n当前的模板有意混合了：\n\n- 针对明显反模式的快速本地规则\n- 针对更高层次架构或事务性推理的语义 AI 引导规则\n\n## 配置扩展\n\n配置模型现在支持两种规则感知的扩展：\n\n### `ast`\n\n用于高级 AST 后端编排。AI-RULES 有意将此配置保持得尽可能小，并在运行时将其与检测到的项目配置合并。\n\n示例：\n\n```json\n{\n  \"ast\": {\n    \"provider\": \"babel\",\n    \"target\": \"react\",\n    \"useProjectConfig\": true,\n    \"parserOptions\": {\n      \"sourceType\": \"module\",\n      \"plugins\": [\"jsx\", \"typescript\"]\n    }\n  }\n}\n```\n\n在运行时，AI-RULES 按以下顺序解析 AST 设置：\n\n1. 模板默认值\n2. 检测到的项目配置，例如 `tsconfig.json`、`.babelrc` 或 `package.json#babel`\n3. 本地 `.ai-rules\u002Fconfig.json` 中的覆盖设置\n\n### `thresholds`\n\n用于可配置的数值限制，本地计数规则可以引用这些限制。\n\n示例：\n\n```json\n{\n  \"thresholds\": {\n    \"maxFunctionLines\": 80,\n    \"maxParamsCount\": 5,\n    \"maxListLimit\": 100\n  }\n}\n```\n\n### `exceptions`\n\n用于在本地证据收集过程中，针对匹配的规则 ID 或规则 ID 模式，抑制已知安全的文件。\n\n示例：\n\n```json\n{\n  \"exceptions\": {\n    \"ARCH-101\": [\n      \"src\u002Fintegrations\u002F**\"\n    ],\n    \"SEC-*\": [\n      \"__mocks__\u002F**\",\n      \"**\u002F*.stories.tsx\"\n    ]\n  }\n}\n```\n\n这些异常目前会影响支持的本地检测模式下的本地证据收集。\n\n## 报告结构\n\n审计提示要求使用严格的 JSON 格式，并采用规范化的结构，如下所示：\n\n```json\n{\n  \"version\": \"1.1\",\n  \"generatedAt\": \"2026-03-30T12:00:00Z\",\n  \"project\": {\n    \"cwd\": \".\",\n    \"stack\": \"react-ts\"\n  },\n  \"summary\": {\n    \"total\": 1,\n    \"fatal\": 0,\n    \"warn\": 1,\n    \"info\": 0\n  },\n  \"violations\": [\n    {\n      \"issueId\": \"ISSUE-001\",\n      \"ruleId\": \"ARCH-101\",\n      \"severity\": \"WARN\",\n      \"confidence\": 0.82,\n      \"file\": \"src\u002Fpages\u002FHome.tsx\",\n      \"line\": 12,\n      \"snippet\": \"const data = fetch('\u002Fapi')\",\n      \"description\": \"在 UI 层中发现了直接的网络请求。\",\n      \"fixSuggestion\": \"将请求逻辑移至服务层。\",\n      \"repairPrompt\": \"提供一个最小的补丁……\",\n      \"evidence\": {\n        \"source\": \"local-regex\",\n        \"matchedBy\": \"detect.regex\"\n      },\n      \"context\": [\n        \"src\u002Fservices\u002F\"\n      ]\n    }\n  ]\n}\n```\n\n## 模板\n\n当前模板：\n\n- `frontend-base`\n  - `react-js`\n  - `react-ts`\n  - `vue`\n- `python-base`\n  - `python-fastapi`\n- `java-base`\n  - `java-spring`\n- `c-cpp`\n\n分支模板通过 `extends` 继承自基础模板。\n\n## CLI 命令\n\n```bash\nai-law init\nai-law audit [--locale \u003Ccode>] [--json] [--summary] [--dry-run] [--dump-context]\nai-law fix --issueId \u003Cissue_id>\nai-law fix --id \u003Crule_id>\nai-law fix --all [--group-by-rule]\nai-law doctor [--strict]\nai-law validate-report [--json] [--path \u003Cfile>]\nai-law setup [--locale \u003Ccode>] [--provider \u003Cname>] [--write]\nai-law -v\nai-law -h\n```\n\n## 开发说明\n\n当前实现层次：\n\n- `cli\u002Fsrc\u002Fcore\u002Fconfig`: 配置加载和 `extends` 合并\n- `cli\u002Fsrc\u002Fcore\u002Frules`: 规则解析和验证\n- `cli\u002Fsrc\u002Fcore\u002Fevidence`: 本地证据收集\n- `cli\u002Fsrc\u002Fcore\u002Fprompt`: 审计提示组装\n- `cli\u002Fsrc\u002Fcore\u002Freport`: 报告规范化和模式\n\n运行测试：\n\n```bash\nnpm test\n```\n\n## 文档\n\n- 英文设计规范：[design\u002Fdesign-spec-en.md](design\u002Fdesign-spec-en.md)\n- 中文设计文档：[design\u002Fdesign-spec-zh.md](design\u002Fdesign-spec-zh.md)","# AI-RULES 快速上手指南\n\nAI-RULES 是一款面向 AI 辅助编程的治理工具。它能将项目规范（Markdown 格式）转化为结构化的规则元数据和本地证据，生成确定性的审计与修复提示词，确保 AI 生成的代码严格遵循您的架构设计、分层原则及 UI 标准。\n\n## 环境准备\n\n- **Node.js**: 版本需 `>=18`\n- **包管理器**: npm, yarn 或 pnpm\n- **项目依赖**: 无特殊前置依赖，直接安装即可使用\n\n> **国内加速建议**：若下载缓慢，可配置淘宝镜像源：\n> ```bash\n> npm config set registry https:\u002F\u002Fregistry.npmmirror.com\n> ```\n\n## 安装步骤\n\n推荐全局安装以便在任何项目中直接使用：\n\n```bash\nnpm install -g ai-law\n```\n\n若需在本地开发或调试，可在项目根目录执行：\n\n```bash\nnpm install\n```\n\n## 基本使用\n\n以下是从零开始集成 AI-RULES 的核心工作流：\n\n### 1. 初始化规则\n在项目根目录运行以下命令，生成 `.ai-rules\u002F` 目录及默认规则模板（包含 `.ai-rules.md`, `rules-config.json` 等）：\n\n```bash\ncd your-project\nai-law init\n```\n\n### 2. 检查配置有效性\n验证规则文件语法、依赖链及配置项是否正确：\n\n```bash\nai-law doctor\n```\n\n### 3. 生成审计提示词\n读取当前项目规则与代码特征，生成包含本地证据的结构化审计提示词。同时会缓存上下文文件至 `.ai-rules\u002Fcache\u002F`：\n\n```bash\nai-law audit\n```\n\n*可选：查看结构化 JSON 上下文*\n```bash\nai-law audit --json\n```\n\n> **操作指引**：将 `ai-law audit` 输出的提示词发送给您的 AI 编程助手（如 Cursor, Claude Code 等），要求 AI 返回符合规范的 `ai-rule-report.json` 报告文件。\n\n### 4. 验证 AI 报告\n当 AI 生成 `ai-rule-report.json` 后，运行此命令校验报告格式（如 issueId 唯一性、严重等级合法性等）并标准化数据结构：\n\n```bash\nai-law validate-report\n```\n\n### 5. 生成修复提示词\n基于验证后的报告，生成针对性的代码修复提示词。\n\n*修复单个问题：*\n```bash\nai-law fix --issueId ISSUE-001\n```\n\n*批量修复所有问题（按规则分组）：*\n```bash\nai-law fix --all --group-by-rule\n```\n\n将生成的修复提示词再次发送给 AI，即可完成符合项目规范的代码修正。","某电商团队的前端组正利用 Cursor 和 Copilot 快速迭代新版商品详情页，需要在高压下保证代码符合严格的架构规范。\n\n### 没有 ai-rules 时\n- AI 助手常为了“跑通功能”，直接在 React 组件内发起 HTTP 请求或操作 DOM，破坏了既定的分层架构。\n- 生成的代码频繁使用 `dangerouslySetInnerHTML` 渲染富文本或直接用数组索引作为列表 `key`，埋下 XSS 攻击和渲染性能隐患。\n- 每次代码审查（Code Review）都要重复指出相同的架构违规问题，资深工程师被迫花费大量时间解释基础规范。\n- 不同 AI 工具输出的修复建议格式混乱，难以集成到自动化流水线中，导致违规代码反复合并进主分支。\n\n### 使用 ai-rules 后\n- ai-rules 将团队的架构约束转化为 `.ai-rules.md` 规则文件，强制 AI 在生成代码前就知晓“UI 层严禁直接调用数据层”，从源头杜绝越界。\n- 基于 AST 的本地证据检测能精准识别并拦截 `innerHTML` 滥用及错误的列表 `key` 用法，同时提供符合项目标准的具体修复提示。\n- 审查流程大幅提速，因为通用违规行为已被规则编码并自动修正，评审者只需关注核心业务逻辑而非基础规范。\n- 无论使用 Cursor 还是 Copilot，ai-rules 都能输出标准化的审计报告和确定性修复指令，确保治理策略在多工具环境下保持一致。\n\nai-rules 的核心价值在于它将事后被动的代码审查，转变为 AI 编码过程中的主动架构守护，确保生成的每一行代码都天然契合项目规范。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Ffjb040911_ai-rules_a003caa4.png","fjb040911","Jianbing Fang","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Ffjb040911_1d1085ca.jpg",null,"83546766@qq.com","https:\u002F\u002Fgithub.com\u002Ffjb040911",[79],{"name":80,"color":81,"percentage":82},"JavaScript","#f1e05a",100,1065,19,"2026-04-14T07:01:17","Linux, macOS, Windows","未说明",{"notes":89,"python":87,"dependencies":90},"该工具是一个基于 Node.js 的命令行界面 (CLI)，不依赖 Python 或 GPU。安装需通过 npm 全局安装 'ai-law' 包。支持多种语言本地化（包括简体中文），部分语言缺失内容会自动回退到英文。",[91],"Node.js>=18",[14,13,52],[94,95,96,97,98],"ai-code-review","ai-coding","code-review","code-rules","repair-prompt","2026-03-27T02:49:30.150509","2026-04-15T08:10:20.810617",[],[]]