MCPcopy Create free account
hub / github.com/agenticsorg/edge-agents / searchCommand

Function searchCommand

scripts/sparc2/src/cli/cli.ts:248–286  ·  view source on GitHub ↗

* Search command action

(
  args: Record<string, any>,
  options: Record<string, any>,
)

Source from the content-addressed store, hash-verified

246 * Search command action
247 */
248async function searchCommand(
249 args: Record<string, any>,
250 options: Record<string, any>,
251): Promise<void> {
252 try {
253 // Search for similar changes
254 const results = await searchDiffEntries(options.query, options["max-results"]);
255
256 // Output results
257 console.log("Search Results:");
258 if (results.length === 0) {
259 console.log("No results found.");
260 return;
261 }
262
263 for (const result of results) {
264 // Check if the entry is a DiffEntry
265 if ("file" in result.entry && "diff" in result.entry) {
266 const diffEntry = result.entry as DiffEntry;
267 console.log(`\nFile: ${diffEntry.file} (Score: ${result.score.toFixed(2)})`);
268 console.log("Diff:");
269 console.log(diffEntry.diff);
270 } else {
271 // Handle LogEntry case
272 const logEntry = result.entry as LogEntry;
273 console.log(
274 `\nLog: ${logEntry.timestamp} [${logEntry.level}] (Score: ${result.score.toFixed(2)})`,
275 );
276 console.log("Message:");
277 console.log(logEntry.message);
278 }
279 console.log("-".repeat(80));
280 }
281 } catch (error: unknown) {
282 const errorMessage = error instanceof Error ? error.message : String(error);
283 console.error(`Error: ${errorMessage}`);
284 Deno.exit(1);
285 }
286}
287
288/**
289 * Checkpoint command action

Callers

nothing calls this directly

Calls 1

searchDiffEntriesFunction · 0.90

Tested by

no test coverage detected