"use strict";
var import_vitest = require("vitest");
var import_agent_backend = require("./agent-backend.js");
function createAgent(capabilities, options = {}) {
  return {
    capabilities,
    ...options.hasSkillManager ? {
      skillManager: {
        list: async () => [],
        get: async () => null,
        readFile: async () => null,
        invoke: async () => null,
        refresh: async () => {
        }
      }
    } : {}
  };
}
(0, import_vitest.describe)("isCommandSupported", () => {
  (0, import_vitest.it)("blocks capability-gated commands when the capability is disabled", () => {
    const agent = createAgent({ contextStats: false });
    (0, import_vitest.expect)(
      (0, import_agent_backend.isCommandSupported)(agent, "tokens", {
        name: "context",
        aliases: ["ctx", "tokens"]
      })
    ).toBe(false);
  });
  (0, import_vitest.it)("requires both capability support and allowlist support when both are configured", () => {
    const agent = createAgent({
      supportedCommands: ["context"],
      contextStats: false
    });
    (0, import_vitest.expect)((0, import_agent_backend.isCommandSupported)(agent, "context", { name: "context", aliases: [] })).toBe(false);
  });
  (0, import_vitest.it)("still allows unrelated commands when only a different capability is disabled", () => {
    const agent = createAgent({ prompts: false });
    (0, import_vitest.expect)((0, import_agent_backend.isCommandSupported)(agent, "help", { name: "help", aliases: ["h"] })).toBe(true);
  });
  (0, import_vitest.it)("gates skill commands separately from prompt commands", () => {
    const promptlessAgent = createAgent({ prompts: false }, { hasSkillManager: true });
    const skilllessAgent = createAgent({ skills: false }, { hasSkillManager: true });
    (0, import_vitest.expect)((0, import_agent_backend.isCommandSupported)(promptlessAgent, "skills", { name: "skills", aliases: [] })).toBe(
      true
    );
    (0, import_vitest.expect)((0, import_agent_backend.isCommandSupported)(skilllessAgent, "skills", { name: "skills", aliases: [] })).toBe(
      false
    );
  });
  (0, import_vitest.it)("requires a real SkillManager for skill commands", () => {
    const agent = createAgent();
    (0, import_vitest.expect)((0, import_agent_backend.isCommandSupported)(agent, "skills", { name: "skills", aliases: [] })).toBe(false);
  });
});
