|
| 1 | +/** |
| 2 | + * Copyright 2025 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import { AIToolConfigResult, AIToolModule, InitConfigOptions } from '../types'; |
| 18 | +import { getGenkitContext, updateContentInPlace } from '../utils'; |
| 19 | + |
| 20 | +const RULES_PATH = '.idx/airules.md'; |
| 21 | + |
| 22 | +export const studio: AIToolModule = { |
| 23 | + name: 'studio', |
| 24 | + displayName: 'Firebase Studio', |
| 25 | + |
| 26 | + /** |
| 27 | + * Configures Firebase Studio (Project IDX) with Genkit context. |
| 28 | + * |
| 29 | + * - .idx/airules.md: Updates Firebase section only (preserves user content) |
| 30 | + * |
| 31 | + * Interactive prompts are shown since this file may contain user-defined |
| 32 | + * AI rules and instructions that we must preserve. We only manage the |
| 33 | + * Genkit-specific section marked with our XML tags. |
| 34 | + */ |
| 35 | + async configure(options?: InitConfigOptions): Promise<AIToolConfigResult> { |
| 36 | + const files: AIToolConfigResult['files'] = []; |
| 37 | + const content = getGenkitContext(); |
| 38 | + const { updated } = await updateContentInPlace(RULES_PATH, content); |
| 39 | + files.push({ path: RULES_PATH, updated }); |
| 40 | + return { files }; |
| 41 | + }, |
| 42 | +}; |
0 commit comments