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

104 lines
2.5 KiB
TypeScript

import { useEffect, useCallback, useState } from 'react';
import * as Linking from 'expo-linking';
import { router } from 'expo-router';
type DeepLinkRoute =
| { type: 'post'; id: string }
| { type: 'profile'; username: string }
| { type: 'repo'; owner: string; name: string }
| { type: 'unknown'; url: string };
interface UseDeepLinkReturn {
isReady: boolean;
handleDeepLink: (url: string) => void;
}
function parseDeepLink(url: string): DeepLinkRoute | null {
try {
const parsed = Linking.parse(url);
// Only handle gitgram:// scheme
if (parsed.scheme !== 'gitgram') {
return null;
}
const path = parsed.path ?? '';
const segments = path.replace(/^\//, '').split('/');
// gitgram://post/:id
if (segments[0] === 'post' && segments[1]) {
return { type: 'post', id: segments[1] };
}
// gitgram://profile/:username
if (segments[0] === 'profile' && segments[1]) {
return { type: 'profile', username: segments[1] };
}
// gitgram://repo/:owner/:name
if (segments[0] === 'repo' && segments[1] && segments[2]) {
return { type: 'repo', owner: segments[1], name: segments[2] };
}
return { type: 'unknown', url };
} catch {
return null;
}
}
function navigateToRoute(route: DeepLinkRoute): void {
switch (route.type) {
case 'post':
router.push(`/post/${route.id}` as never);
break;
case 'profile':
router.push(`/profile/${route.username}` as never);
break;
case 'repo':
router.push(`/repo/${route.owner}/${route.name}` as never);
break;
case 'unknown':
// No navigation for unrecognised deep links
break;
}
}
export function useDeepLink(): UseDeepLinkReturn {
const [isReady, setIsReady] = useState(false);
const handleDeepLink = useCallback((url: string) => {
const route = parseDeepLink(url);
if (route !== null) {
navigateToRoute(route);
}
}, []);
useEffect(() => {
let isMounted = true;
// Handle links received while the app is already running
const subscription = Linking.addEventListener('url', ({ url }) => {
if (isMounted) {
handleDeepLink(url);
}
});
// Handle the link that launched the app cold
Linking.getInitialURL().then((url) => {
if (isMounted && url) {
handleDeepLink(url);
}
if (isMounted) {
setIsReady(true);
}
});
return () => {
isMounted = false;
subscription.remove();
};
}, [handleDeepLink]);
return { isReady, handleDeepLink };
}