fix: the / menu reads .claude sources only for Claude Code

Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
FactorandOvis Fast committed 2026-11-19 20:36:57 +01:00
1 parent 3f78fe912d
commit f1102524cc
3 files changed
+65 -7

No files matched your search

+37
View File
@@ -3,6 +3,7 @@ import assert from "node:assert/strict";
import {
BUILTINS,
commands,
isClaudeCode,
globalCommands,
} from "../herdr/herdr-composer/mods/herdr-composer/catalog.js";
import {
@@ -184,3 +185,39 @@ test("commands: options.global joins after the project, first key wins", async (
);
assert.ok(items.some((item) => item.key === "handoff"));
});
test("isClaudeCode: claude-code and its alias only", () => {
assert.equal(isClaudeCode("claude-code"), true);
assert.equal(isClaudeCode("claude"), true);
for (const name of ["codex", "kiro-cli", "", undefined]) assert.equal(isClaudeCode(name), false, String(name));
});
test("commands: another agent gets its builtins and snippets - no project, no global, no exec", async () => {
let calls = 0;
const exec = async () => {
calls += 1;
return { code: 0, stdout: "", stderr: "" };
};
const global = [{ key: "handoff", desc: "h", group: GROUP_USER, insert: "/handoff " }];
const items = await commands("/x", exec, {
agent: "codex",
global,
snippets: [{ key: "mine", desc: "s" }],
});
assert.equal(calls, 0);
const keys = items.map((item) => item.key);
assert.deepEqual(keys, [...BUILTINS.codex.map((item) => item.key), "mine"]);
assert.ok(!keys.includes("handoff"));
});
test("commands: claude-code still reads the project and takes the global ones", async () => {
const exec = async (command) => {
if (command === "sh") return { code: 0, stdout: ".claude/commands/p.md\n", stderr: "" };
return { code: 1, stdout: "", stderr: "" };
};
const global = [{ key: "handoff", desc: "h", group: GROUP_USER, insert: "/handoff " }];
const items = await commands("/x", exec, { agent: "claude", global });
const keys = items.map((item) => item.key);
assert.ok(keys.includes("handoff"));
assert.ok(keys.includes("clear"));
});