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

Function configCommand

scripts/sparc2/src/cli/cli.ts:434–505  ·  view source on GitHub ↗

* Config command action

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

Source from the content-addressed store, hash-verified

432 * Config command action
433 */
434async function configCommand(
435 args: Record<string, any>,
436 options: Record<string, any>,
437): Promise<void> {
438 try {
439 const action = options.action;
440
441 switch (action) {
442 case "get": {
443 if (!options.key) {
444 throw new Error("Key is required for 'get' action");
445 }
446
447 const value = await getConfigValue(options.key);
448 console.log(
449 `${options.key} = ${value !== undefined ? JSON.stringify(value) : "undefined"}`,
450 );
451 break;
452 }
453
454 case "set": {
455 if (!options.key || options.value === undefined) {
456 throw new Error("Key and value are required for 'set' action");
457 }
458
459 // Parse value if it's a JSON string
460 let parsedValue = options.value;
461 if (typeof parsedValue === "string") {
462 try {
463 if (parsedValue.startsWith("{") || parsedValue.startsWith("[")) {
464 parsedValue = JSON.parse(parsedValue);
465 } else if (parsedValue === "true") {
466 parsedValue = true;
467 } else if (parsedValue === "false") {
468 parsedValue = false;
469 } else if (!isNaN(Number(parsedValue))) {
470 parsedValue = Number(parsedValue);
471 }
472 } catch {
473 // If parsing fails, use the original string value
474 }
475 }
476
477 await setConfigValue(options.key, parsedValue);
478 console.log(`${options.key} set to ${JSON.stringify(parsedValue)}`);
479 break;
480 }
481
482 case "list": {
483 const configPath = Deno.env.get("SPARC2_CONFIG_PATH") || "config/sparc2-config.toml";
484
485 try {
486 const configContent = await Deno.readTextFile(configPath);
487 const config = parse(configContent);
488
489 console.log("Configuration:");
490 console.log(JSON.stringify(config, null, 2));
491 } catch (error) {

Callers

nothing calls this directly

Calls 3

getConfigValueFunction · 0.85
setConfigValueFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected