MCPcopy
hub / github.com/mixedbread-ai/mgrep / syncFiles

Function syncFiles

src/commands/search.ts:143–191  ·  view source on GitHub ↗

* Syncs local files to the store with progress indication. * @returns true if the caller should return early (dry-run mode), false otherwise

(
  store: Store,
  storeName: string,
  root: string,
  dryRun: boolean,
  config?: MgrepConfig,
)

Source from the content-addressed store, hash-verified

141 * @returns true if the caller should return early (dry-run mode), false otherwise
142 */
143async function syncFiles(
144 store: Store,
145 storeName: string,
146 root: string,
147 dryRun: boolean,
148 config?: MgrepConfig,
149): Promise<boolean> {
150 const { spinner, onProgress } = createIndexingSpinner(root);
151
152 try {
153 const fileSystem = createFileSystem({
154 ignorePatterns: [...DEFAULT_IGNORE_PATTERNS],
155 });
156 const result = await initialSync(
157 store,
158 fileSystem,
159 storeName,
160 root,
161 dryRun,
162 onProgress,
163 config,
164 );
165
166 while (true) {
167 const info = await store.getInfo(storeName);
168 spinner.text = `Indexing ${info.counts.pending + info.counts.in_progress} file(s)`;
169 if (info.counts.pending === 0 && info.counts.in_progress === 0) {
170 break;
171 }
172 await new Promise((resolve) => setTimeout(resolve, 1000));
173 }
174
175 spinner.succeed("Indexing complete");
176
177 if (dryRun) {
178 console.log(
179 formatDryRunSummary(result, {
180 actionDescription: "would have indexed",
181 }),
182 );
183 return true;
184 }
185
186 return false;
187 } catch (error) {
188 spinner.stop();
189 throw error;
190 }
191}
192
193export const search: Command = new CommanderCommand("search")
194 .description("File pattern searcher")

Callers 1

search.tsFile · 0.85

Calls 5

createIndexingSpinnerFunction · 0.85
createFileSystemFunction · 0.85
initialSyncFunction · 0.85
formatDryRunSummaryFunction · 0.85
getInfoMethod · 0.65

Tested by

no test coverage detected