Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/tools/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ import { cloneRepo, getReposStatus, getNoirCommitFromAztec, getRepoPath, REPOS_D
import { writeSyncMetadata, stampMetadataMcpVersion, readSyncMetadata, SyncMetadata } from "../utils/sync-metadata.js";
import { clearErrorCache } from "../utils/error-lookup.js";

export interface RepoSyncStatus {
name: string;
status: string;
commit?: string;
}

export function isRepoError(repo: RepoSyncStatus): boolean {
return repo.status.startsWith("Error:");
}

export interface SyncResult {
success: boolean;
metadataSafe: boolean;
message: string;
version: string;
repos: {
name: string;
status: string;
commit?: string;
}[];
repos: RepoSyncStatus[];
}

/**
Expand Down Expand Up @@ -105,7 +111,7 @@ export async function syncRepos(options: {
// leaves the old checkout while other repos sync to the new tag, producing a
// mixed-version workspace.
const aztecFailed = results.some(
(r) => r.name === "aztec-packages" && r.status.toLowerCase().includes("error"),
(r) => r.name === "aztec-packages" && isRepoError(r),
);
if (aztecFailed && (force || version)) {
return {
Expand Down Expand Up @@ -160,7 +166,7 @@ export async function syncRepos(options: {
let versionedDocsMissing = false;
for (const repo of syntheticRepos) {
const result = results.find((r) => r.name === repo.name);
if (!result || result.status.toLowerCase().includes("error")) continue;
if (!result || isRepoError(result)) continue;

for (const sparsePath of repo.sparse || []) {
if (!sparsePath.includes(effectiveVersion)) continue;
Expand All @@ -174,7 +180,7 @@ export async function syncRepos(options: {
}

const allSuccess = results.every(
(r) => !r.status.toLowerCase().includes("error")
(r) => !isRepoError(r)
);

log?.(`Sync complete: ${results.length} repos, ${allSuccess ? "all succeeded" : "some failed"}`, "info");
Expand Down
4 changes: 2 additions & 2 deletions src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Formatting utilities for MCP tool responses
*/

import type { SyncResult } from "../tools/sync.js";
import { isRepoError, type SyncResult } from "../tools/sync.js";
import type { SearchResult, FileInfo } from "./search.js";
import type { SyncMetadata } from "./sync-metadata.js";
import type { ErrorLookupResult } from "./error-lookup.js";
Expand All @@ -18,7 +18,7 @@ export function formatSyncResult(result: SyncResult): string {
];

for (const repo of result.repos) {
const icon = repo.status.toLowerCase().includes("error") ? "✗" : "✓";
const icon = isRepoError(repo) ? "✗" : "✓";
lines.push(` ${icon} ${repo.name}: ${repo.status}`);
}

Expand Down