import React, { useCallback } from 'react' import { logEvent } from 'src/services/analytics/index.js' import { Box, Dialog, Link, Text } from '@anthropic/ink' import type { ExternalClaudeMdInclude } from '../utils/claudemd.js' import { saveCurrentProjectConfig } from '../utils/config.js' import { Select } from './CustomSelect/index.js' type Props = { onDone(): void isStandaloneDialog?: boolean externalIncludes?: ExternalClaudeMdInclude[] } export function ClaudeMdExternalIncludesDialog({ onDone, isStandaloneDialog, externalIncludes, }: Props): React.ReactNode { React.useEffect(() => { // Log when dialog is shown logEvent('tengu_claude_md_includes_dialog_shown', {}) }, []) const handleSelection = useCallback( (value: 'yes' | 'no') => { if (value === 'no') { logEvent('tengu_claude_md_external_includes_dialog_declined', {}) // Mark that we've shown the dialog but it was declined saveCurrentProjectConfig(current => ({ ...current, hasClaudeMdExternalIncludesApproved: false, hasClaudeMdExternalIncludesWarningShown: true, })) } else { logEvent('tengu_claude_md_external_includes_dialog_accepted', {}) saveCurrentProjectConfig(current => ({ ...current, hasClaudeMdExternalIncludesApproved: true, hasClaudeMdExternalIncludesWarningShown: true, })) } onDone() }, [onDone], ) const handleEscape = useCallback(() => { handleSelection('no') }, [handleSelection]) return ( This project's CLAUDE.md imports files outside the current working directory. Never allow this for third-party repositories. {externalIncludes && externalIncludes.length > 0 && ( External imports: {externalIncludes.map((include, i) => ( {' '} {include.path} ))} )} Important: Only use Claude Code with files you trust. Accessing untrusted files may pose security risks{' '} {' '}