Files
relicario/extension/src/setup/probe.ts
adlee-was-taken 8e72ed8714 feat(ext/setup): vault-presence probe helper
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 18:12:04 -04:00

24 lines
889 B
TypeScript

import type { GitHost } from '../service-worker/git-host';
export interface VaultProbe {
exists: boolean;
lastCommit?: { sha: string; author: string; date: string };
}
/// Detect whether the configured remote already contains a relicario vault.
/// Considered present if any of: .relicario/salt, .relicario/params.json,
/// manifest.enc exists. Best-effort metadata fetch via lastCommit().
export async function probeVault(host: GitHost): Promise<VaultProbe> {
const [relicarioFiles, rootFiles] = await Promise.all([
host.listDir('.relicario'),
host.listDir(''),
]);
const exists =
relicarioFiles.includes('salt') ||
relicarioFiles.includes('params.json') ||
rootFiles.includes('manifest.enc');
if (!exists) return { exists: false };
const lastCommit = await host.lastCommit('manifest.enc');
return lastCommit ? { exists, lastCommit } : { exists };
}