/
githubmirror
/
angular-cli
Обзор
Документация
Войти
/
githubmirror
/
angular-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/schematics/angular/ai-config/index.ts
112 строк
3 KB
Suguru Inatomi
fix(@schematics/angular): generate CLAUDE.md for Claude Code instead of AGENTS.md
10 авг 2026, 16:22
10 авг 2026, 16:22
1161e6c
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { Rule, chain, noop, strings } from '@angular-devkit/schematics'; import { addBestPracticesMarkdown, addJsonMcpConfig, addTomlMcpConfig } from './file_utils'; import { Schema as ConfigOptions, Tool } from './schema'; import { ContextFileInfo, ContextFileType, FileConfigurationHandlerOptions } from './types'; const AGENTS_MD_CFG: ContextFileInfo = { type: ContextFileType.BestPracticesMd, name: 'AGENTS.md', directory: '.', }; const AI_TOOLS: { [key in Exclude<Tool, Tool.None>]: ContextFileInfo[] } = { ['claude-code']: [ { type: ContextFileType.BestPracticesMd, name: 'CLAUDE.md', directory: '.', }, { type: ContextFileType.McpConfig, name: '.mcp.json', directory: '.', }, ], cursor: [ AGENTS_MD_CFG, { type: ContextFileType.McpConfig, name: 'mcp.json', directory: '.cursor', }, ], ['gemini-cli']: [ { type: ContextFileType.BestPracticesMd, name: 'GEMINI.md', directory: '.gemini', }, { type: ContextFileType.McpConfig, name: 'settings.json', directory: '.gemini', }, ], ['open-ai-codex']: [ AGENTS_MD_CFG, { type: ContextFileType.McpConfig, name: 'config.toml', directory: '.codex', }, ], vscode: [ AGENTS_MD_CFG, { type: ContextFileType.McpConfig, name: 'mcp.json', directory: '.vscode', }, ], }; export default function ({ tool }: ConfigOptions): Rule { return (tree, context) => { if (!tool) { return noop(); } const rules = tool .filter((tool) => tool !== Tool.None) .flatMap((selectedTool) => AI_TOOLS[selectedTool].map((fileInfo) => { const fileCfgOpts: FileConfigurationHandlerOptions = { tree, context, fileInfo, tool: selectedTool, }; switch (fileInfo.type) { case ContextFileType.BestPracticesMd: return addBestPracticesMarkdown(fileCfgOpts); case ContextFileType.McpConfig: switch (selectedTool) { case Tool.ClaudeCode: case Tool.Cursor: case Tool.GeminiCli: return addJsonMcpConfig(fileCfgOpts, 'mcpServers'); case Tool.OpenAiCodex: return addTomlMcpConfig(fileCfgOpts); case Tool.Vscode: return addJsonMcpConfig(fileCfgOpts, 'servers'); default: throw new Error( `Unsupported '${strings.classify(selectedTool)}' MCP server configuraiton.`, ); } } }), ); return chain(rules); }; }