Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openclaw/src/cli/   (KI Agentensystem Version 22©)  Datei vom 26.3.2026 mit Größe 3 kB image not shown  

Quelle  command-startup-policy.test.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import { describe, expect, it } from "vitest";
import {
  resolveCliStartupPolicy,
  shouldBypassConfigGuardForCommandPath,
  shouldEnsureCliPathForCommandPath,
  shouldHideCliBannerForCommandPath,
  shouldLoadPluginsForCommandPath,
  shouldSkipRouteConfigGuardForCommandPath,
} from "./command-startup-policy.js";

describe("command-startup-policy", () => {
  it("matches config guard bypass commands", () => {
    expect(shouldBypassConfigGuardForCommandPath(["backup", "create"])).toBe(true);
    expect(shouldBypassConfigGuardForCommandPath(["config", "validate"])).toBe(true);
    expect(shouldBypassConfigGuardForCommandPath(["config", "schema"])).toBe(true);
    expect(shouldBypassConfigGuardForCommandPath(["status"])).toBe(false);
  });

  it("matches route-first config guard skip policy", () => {
    expect(
      shouldSkipRouteConfigGuardForCommandPath({
        commandPath: ["status"],
        suppressDoctorStdout: true,
      }),
    ).toBe(true);
    expect(
      shouldSkipRouteConfigGuardForCommandPath({
        commandPath: ["gateway", "status"],
        suppressDoctorStdout: false,
      }),
    ).toBe(true);
    expect(
      shouldSkipRouteConfigGuardForCommandPath({
        commandPath: ["status"],
        suppressDoctorStdout: false,
      }),
    ).toBe(false);
  });

  it("matches plugin preload policy", () => {
    expect(
      shouldLoadPluginsForCommandPath({
        commandPath: ["status"],
        jsonOutputMode: false,
      }),
    ).toBe(false);
    expect(
      shouldLoadPluginsForCommandPath({
        commandPath: ["status"],
        jsonOutputMode: true,
      }),
    ).toBe(false);
    expect(
      shouldLoadPluginsForCommandPath({
        commandPath: ["health"],
        jsonOutputMode: false,
      }),
    ).toBe(false);
    expect(
      shouldLoadPluginsForCommandPath({
        commandPath: ["channels", "status"],
        jsonOutputMode: false,
      }),
    ).toBe(false);
    expect(
      shouldLoadPluginsForCommandPath({
        commandPath: ["channels", "list"],
        jsonOutputMode: false,
      }),
    ).toBe(false);
    expect(
      shouldLoadPluginsForCommandPath({
        commandPath: ["channels", "add"],
        jsonOutputMode: false,
      }),
    ).toBe(false);
    expect(
      shouldLoadPluginsForCommandPath({
        commandPath: ["agents", "list"],
        jsonOutputMode: false,
      }),
    ).toBe(true);
  });

  it("matches banner suppression policy", () => {
    expect(shouldHideCliBannerForCommandPath(["update", "status"])).toBe(true);
    expect(shouldHideCliBannerForCommandPath(["completion"])).toBe(true);
    expect(
      shouldHideCliBannerForCommandPath(["status"], {
        ...process.env,
        OPENCLAW_HIDE_BANNER: "1",
      }),
    ).toBe(true);
    expect(shouldHideCliBannerForCommandPath(["status"], {})).toBe(false);
  });

  it("matches CLI PATH bootstrap policy", () => {
    expect(shouldEnsureCliPathForCommandPath(["status"])).toBe(false);
    expect(shouldEnsureCliPathForCommandPath(["sessions"])).toBe(false);
    expect(shouldEnsureCliPathForCommandPath(["config", "get"])).toBe(false);
    expect(shouldEnsureCliPathForCommandPath(["models", "status"])).toBe(false);
    expect(shouldEnsureCliPathForCommandPath(["message", "send"])).toBe(true);
    expect(shouldEnsureCliPathForCommandPath([])).toBe(true);
  });

  it("aggregates startup policy for commander and route-first callers", () => {
    expect(
      resolveCliStartupPolicy({
        commandPath: ["status"],
        jsonOutputMode: true,
      }),
    ).toEqual({
      suppressDoctorStdout: true,
      hideBanner: false,
      skipConfigGuard: false,
      loadPlugins: false,
    });

    expect(
      resolveCliStartupPolicy({
        commandPath: ["status"],
        jsonOutputMode: true,
        routeMode: true,
      }),
    ).toEqual({
      suppressDoctorStdout: true,
      hideBanner: false,
      skipConfigGuard: true,
      loadPlugins: false,
    });
  });
});

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.