import { useState, useEffect } from 'react'; import { Button } from './ui/button'; import { Check } from './icons'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from './ui/dialog'; const ModalHelpText = () => (

.goosehints is a text file used to provide additional context about your project and improve the communication with Goose.

Please make sure Developer extension is enabled in the settings page. This extension is required to use .goosehints. You'll need to restart your session for .goosehints updates to take effect.

See{' '} {' '} for more information.

); const ModalError = ({ error }: { error: Error }) => (
Error reading .goosehints file: {JSON.stringify(error)}
); const ModalFileInfo = ({ filePath, found }: { filePath: string; found: boolean }) => (
{found ? (
.goosehints file found at: {filePath}
) : (
Creating new .goosehints file at: {filePath}
)}
); const getGoosehintsFile = async (filePath: string) => await window.electron.readFile(filePath); type GoosehintsModalProps = { directory: string; setIsGoosehintsModalOpen: (isOpen: boolean) => void; }; export const GoosehintsModal = ({ directory, setIsGoosehintsModalOpen }: GoosehintsModalProps) => { const goosehintsFilePath = `${directory}/.goosehints`; const [goosehintsFile, setGoosehintsFile] = useState(''); const [goosehintsFileFound, setGoosehintsFileFound] = useState(false); const [goosehintsFileReadError, setGoosehintsFileReadError] = useState(''); useEffect(() => { const fetchGoosehintsFile = async () => { try { const { file, error, found } = await getGoosehintsFile(goosehintsFilePath); setGoosehintsFile(file); setGoosehintsFileFound(found); // Only set error if file was found but there was an actual read error // If file is not found, treat it as creating a new file (no error) setGoosehintsFileReadError(found && error ? error : ''); } catch (error) { console.error('Error fetching .goosehints file:', error); setGoosehintsFileReadError('Failed to access .goosehints file'); } }; if (directory) fetchGoosehintsFile(); }, [directory, goosehintsFilePath]); const writeFile = async () => { await window.electron.writeFile(goosehintsFilePath, goosehintsFile); setIsGoosehintsModalOpen(false); }; const handleClose = () => { setIsGoosehintsModalOpen(false); }; return ( Configure .goosehints Configure your project's .goosehints file to provide additional context to Goose.
{goosehintsFileReadError ? ( ) : (