This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

211 lines
4.4 KiB
TypeScript

import React, { useState } from 'react';
import {
View,
Text,
StyleSheet,
ScrollView,
TouchableOpacity,
} from 'react-native';
import * as Clipboard from 'expo-clipboard';
import { Colors } from '../../constants/Colors';
// Language mapping for display names
const languageMap: Record<string, string> = {
js: 'JavaScript',
javascript: 'JavaScript',
ts: 'TypeScript',
typescript: 'TypeScript',
py: 'Python',
python: 'Python',
go: 'Go',
golang: 'Go',
rust: 'Rust',
rs: 'Rust',
java: 'Java',
c: 'C',
cpp: 'C++',
'c++': 'C++',
csharp: 'C#',
'c#': 'C#',
cs: 'C#',
ruby: 'Ruby',
rb: 'Ruby',
php: 'PHP',
swift: 'Swift',
kotlin: 'Kotlin',
kt: 'Kotlin',
bash: 'Bash',
sh: 'Shell',
shell: 'Shell',
json: 'JSON',
yaml: 'YAML',
yml: 'YAML',
md: 'Markdown',
markdown: 'Markdown',
sql: 'SQL',
css: 'CSS',
scss: 'SCSS',
sass: 'Sass',
jsx: 'JSX',
tsx: 'TSX',
html: 'HTML',
xml: 'XML',
};
interface CodeBlockProps {
code: string;
language?: string;
showLineNumbers?: boolean;
fileName?: string;
}
export default function CodeBlock({
code,
language = 'text',
showLineNumbers = false,
fileName,
}: CodeBlockProps) {
const [copied, setCopied] = useState(false);
const displayLanguage =
languageMap[language.toLowerCase()] || language.toUpperCase();
const handleCopy = async () => {
try {
await Clipboard.setStringAsync(code);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
} catch (err) {
console.error('Failed to copy code:', err);
}
};
return (
<View style={styles.container}>
{/* Header */}
<View style={styles.header}>
<View style={styles.headerLeft}>
{/* Terminal dots */}
<View style={styles.dots}>
<View style={[styles.dot, styles.dotRed]} />
<View style={[styles.dot, styles.dotYellow]} />
<View style={[styles.dot, styles.dotGreen]} />
</View>
{/* File name or language */}
<Text style={styles.languageLabel}>
{fileName || displayLanguage}
</Text>
</View>
{/* Copy button */}
<TouchableOpacity onPress={handleCopy} style={styles.copyButton}>
<Text style={[styles.copyText, copied && styles.copyTextSuccess]}>
{copied ? 'Copied!' : 'Copy'}
</Text>
</TouchableOpacity>
</View>
{/* Code content */}
<ScrollView
horizontal
showsHorizontalScrollIndicator={true}
style={styles.codeScrollView}
contentContainerStyle={styles.codeContentContainer}
>
<Text selectable style={styles.codeText}>
{code}
</Text>
</ScrollView>
</View>
);
}
// Inline code component for single backticks
export function InlineCode({ children }: { children: string }) {
return (
<Text style={styles.inlineCode}>{children}</Text>
);
}
const styles = StyleSheet.create({
container: {
borderRadius: 8,
overflow: 'hidden',
borderWidth: 1,
borderColor: Colors.border,
backgroundColor: '#0d1117',
marginVertical: 8,
},
header: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
padding: 12,
borderBottomWidth: 1,
borderBottomColor: Colors.border,
backgroundColor: '#161b22',
},
headerLeft: {
flexDirection: 'row',
alignItems: 'center',
gap: 12,
},
dots: {
flexDirection: 'row',
gap: 6,
},
dot: {
width: 12,
height: 12,
borderRadius: 6,
},
dotRed: {
backgroundColor: '#ff5f56',
},
dotYellow: {
backgroundColor: '#ffbd2e',
},
dotGreen: {
backgroundColor: '#27c93f',
},
languageLabel: {
color: Colors.textSecondary,
fontSize: 12,
fontWeight: '600',
},
copyButton: {
paddingHorizontal: 10,
paddingVertical: 4,
borderRadius: 4,
backgroundColor: 'rgba(255, 255, 255, 0.1)',
},
copyText: {
color: Colors.textSecondary,
fontSize: 12,
fontWeight: '500',
},
copyTextSuccess: {
color: '#27c93f',
},
codeScrollView: {
maxHeight: 400,
},
codeContentContainer: {
padding: 16,
},
codeText: {
color: '#e6edf3',
fontFamily: 'monospace',
fontSize: 13,
lineHeight: 20,
},
inlineCode: {
backgroundColor: 'rgba(110, 118, 129, 0.4)',
color: '#f78166',
paddingHorizontal: 6,
paddingVertical: 2,
borderRadius: 4,
fontFamily: 'monospace',
fontSize: 13,
},
});