test: pin the / menu of Claude Code before profiles
Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
1 parent
1a78b5dcf3
commit
0263eca263
1 file changed
+118
@@ -55,6 +55,62 @@ function plugins(enabled, installed) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One fake machine for the project (relative paths, `cwd` given) and the
|
||||||
|
* person's home (absolute paths). It answers the POSIX scripts of catalog.js:
|
||||||
|
* the old fixed project listing, and the listing by (index, kind, path)
|
||||||
|
* triples; PowerShell is "not installed".
|
||||||
|
*/
|
||||||
|
function ccMachine(files) {
|
||||||
|
const inner = machine(files);
|
||||||
|
const match = (index, kind, path) => {
|
||||||
|
const lines = [];
|
||||||
|
for (const file of Object.keys(files)) {
|
||||||
|
const name = file.slice(file.lastIndexOf("/") + 1);
|
||||||
|
const dir = file.slice(0, file.lastIndexOf("/"));
|
||||||
|
if (kind === "file" && file === path) lines.push(`${index}\t${file}`);
|
||||||
|
if (kind === "md" && dir === path && name.endsWith(".md")) lines.push(`${index}\t${file}`);
|
||||||
|
if (kind === "skills" && name === "SKILL.md" && dir.slice(0, dir.lastIndexOf("/")) === path)
|
||||||
|
lines.push(`${index}\t${file}`);
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
};
|
||||||
|
const exec = async (command, args, options = {}) => {
|
||||||
|
if (command !== "sh") throw new Error("not found");
|
||||||
|
const rest = args.slice(3);
|
||||||
|
// the new listing of a profile's project sources: the same triples
|
||||||
|
if (options.cwd && rest.length > 0 && rest.length % 3 === 0 && /^\d+$/.test(rest[0])) {
|
||||||
|
const lines = [];
|
||||||
|
for (let i = 0; i < rest.length; i += 3) lines.push(...match(rest[i], rest[i + 1], rest[i + 2]));
|
||||||
|
return { code: 0, stdout: lines.join("\n"), stderr: "" };
|
||||||
|
}
|
||||||
|
// the old fixed listing of the project
|
||||||
|
if (options.cwd && rest.length === 0) {
|
||||||
|
const stdout = Object.keys(files)
|
||||||
|
.filter((f) => /^\.claude\/(commands\/[^/]+\.md|skills\/[^/]+\/SKILL\.md)$/.test(f))
|
||||||
|
.join("\n");
|
||||||
|
return { code: 0, stdout, stderr: "" };
|
||||||
|
}
|
||||||
|
// a read of one file
|
||||||
|
if (rest.length === 1) {
|
||||||
|
const text = files[rest[0]];
|
||||||
|
return text === undefined ? { code: 1, stdout: "", stderr: "" } : { code: 0, stdout: text, stderr: "" };
|
||||||
|
}
|
||||||
|
return inner.exec(command, args, options);
|
||||||
|
};
|
||||||
|
return { exec, readText: inner.readText };
|
||||||
|
}
|
||||||
|
|
||||||
|
const CC_FILES = {
|
||||||
|
".claude/commands/a.md": "---\ndescription: Komenda a\n---\nTreść\n",
|
||||||
|
".claude/skills/s/SKILL.md": skill("inna"),
|
||||||
|
[`${HOME}/.claude/commands/handoff.md`]: "---\ndescription: Przekazanie\n---\nTreść\n",
|
||||||
|
...plugins({ "sp@official": true }, { "sp@official": "C:\\p\\sp" }),
|
||||||
|
"C:/p/sp/skills/brainstorming/SKILL.md": skill("brainstorming"),
|
||||||
|
};
|
||||||
|
|
||||||
|
const ccRow = (item) => ({ key: item.key, group: item.group, insert: item.insert, desc: item.desc });
|
||||||
|
|
||||||
test("GROUPS has Pluginy right after Użytkownik", () => {
|
test("GROUPS has Pluginy right after Użytkownik", () => {
|
||||||
assert.equal(GROUPS[GROUPS.indexOf(GROUP_USER) + 1], "Pluginy");
|
assert.equal(GROUPS[GROUPS.indexOf(GROUP_USER) + 1], "Pluginy");
|
||||||
assert.equal(GROUP_PLUGIN, "Pluginy");
|
assert.equal(GROUP_PLUGIN, "Pluginy");
|
||||||
@@ -221,3 +277,65 @@ test("commands: claude-code still reads the project and takes the global ones",
|
|||||||
assert.ok(keys.includes("handoff"));
|
assert.ok(keys.includes("handoff"));
|
||||||
assert.ok(keys.includes("clear"));
|
assert.ok(keys.includes("clear"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const EXPECTED_CC = [
|
||||||
|
{"key":"add-dir","group":"Wbudowane","insert":"/add-dir ","desc":"Dodaje katalog roboczy."},
|
||||||
|
{"key":"agents","group":"Wbudowane","insert":"/agents ","desc":"Zarządza subagentami."},
|
||||||
|
{"key":"bashes","group":"Wbudowane","insert":"/bashes ","desc":"Pokazuje zadania w tle."},
|
||||||
|
{"key":"bug","group":"Wbudowane","insert":"/bug ","desc":"Zgłasza błąd Claude Code."},
|
||||||
|
{"key":"clear","group":"Wbudowane","insert":"/clear ","desc":"Czyści historię rozmowy."},
|
||||||
|
{"key":"code-review","group":"Wbudowane","insert":"/code-review ","desc":"Przegląd zmian pod kątem błędów."},
|
||||||
|
{"key":"compact","group":"Wbudowane","insert":"/compact ","desc":"Zwija historię do podsumowania."},
|
||||||
|
{"key":"config","group":"Wbudowane","insert":"/config ","desc":"Otwiera ustawienia."},
|
||||||
|
{"key":"context","group":"Wbudowane","insert":"/context ","desc":"Pokazuje zużycie kontekstu."},
|
||||||
|
{"key":"cost","group":"Wbudowane","insert":"/cost ","desc":"Pokazuje koszt i zużycie tokenów."},
|
||||||
|
{"key":"doctor","group":"Wbudowane","insert":"/doctor ","desc":"Sprawdza instalację Claude Code."},
|
||||||
|
{"key":"exit","group":"Wbudowane","insert":"/exit ","desc":"Kończy sesję."},
|
||||||
|
{"key":"export","group":"Wbudowane","insert":"/export ","desc":"Eksportuje rozmowę."},
|
||||||
|
{"key":"fast","group":"Wbudowane","insert":"/fast ","desc":"Przełącza tryb szybki."},
|
||||||
|
{"key":"feedback","group":"Wbudowane","insert":"/feedback ","desc":"Wysyła opinię o Claude Code."},
|
||||||
|
{"key":"fewer-permission-prompts","group":"Wbudowane","insert":"/fewer-permission-prompts ","desc":"Dodaje bezpieczne komendy do listy dozwolonych."},
|
||||||
|
{"key":"help","group":"Wbudowane","insert":"/help ","desc":"Pomoc."},
|
||||||
|
{"key":"hooks","group":"Wbudowane","insert":"/hooks ","desc":"Zarządza hookami."},
|
||||||
|
{"key":"ide","group":"Wbudowane","insert":"/ide ","desc":"Łączy z IDE."},
|
||||||
|
{"key":"init","group":"Wbudowane","insert":"/init ","desc":"Tworzy CLAUDE.md dla projektu."},
|
||||||
|
{"key":"install-github-app","group":"Wbudowane","insert":"/install-github-app ","desc":"Instaluje aplikację GitHub."},
|
||||||
|
{"key":"keybindings","group":"Wbudowane","insert":"/keybindings ","desc":"Ustawia skróty klawiszowe."},
|
||||||
|
{"key":"login","group":"Wbudowane","insert":"/login ","desc":"Logowanie."},
|
||||||
|
{"key":"logout","group":"Wbudowane","insert":"/logout ","desc":"Wylogowanie."},
|
||||||
|
{"key":"loop","group":"Wbudowane","insert":"/loop ","desc":"Uruchamia polecenie cyklicznie."},
|
||||||
|
{"key":"mcp","group":"Wbudowane","insert":"/mcp ","desc":"Zarządza serwerami MCP."},
|
||||||
|
{"key":"memory","group":"Wbudowane","insert":"/memory ","desc":"Edytuje pliki pamięci."},
|
||||||
|
{"key":"model","group":"Wbudowane","insert":"/model ","desc":"Wybiera model."},
|
||||||
|
{"key":"output-style","group":"Wbudowane","insert":"/output-style ","desc":"Ustawia styl odpowiedzi."},
|
||||||
|
{"key":"permissions","group":"Wbudowane","insert":"/permissions ","desc":"Ustawia uprawnienia narzędzi."},
|
||||||
|
{"key":"plugin","group":"Wbudowane","insert":"/plugin ","desc":"Zarządza pluginami."},
|
||||||
|
{"key":"pr-comments","group":"Wbudowane","insert":"/pr-comments ","desc":"Pokazuje komentarze PR."},
|
||||||
|
{"key":"privacy-settings","group":"Wbudowane","insert":"/privacy-settings ","desc":"Ustawienia prywatności."},
|
||||||
|
{"key":"release-notes","group":"Wbudowane","insert":"/release-notes ","desc":"Pokazuje informacje o wydaniu."},
|
||||||
|
{"key":"resume","group":"Wbudowane","insert":"/resume ","desc":"Wznawia wcześniejszą sesję."},
|
||||||
|
{"key":"review","group":"Wbudowane","insert":"/review ","desc":"Przegląd pull requesta."},
|
||||||
|
{"key":"rewind","group":"Wbudowane","insert":"/rewind ","desc":"Cofa rozmowę lub kod."},
|
||||||
|
{"key":"schedule","group":"Wbudowane","insert":"/schedule ","desc":"Planuje zadania w chmurze."},
|
||||||
|
{"key":"security-review","group":"Wbudowane","insert":"/security-review ","desc":"Przegląd bezpieczeństwa zmian."},
|
||||||
|
{"key":"simplify","group":"Wbudowane","insert":"/simplify ","desc":"Upraszcza zmieniony kod."},
|
||||||
|
{"key":"status","group":"Wbudowane","insert":"/status ","desc":"Pokazuje stan sesji."},
|
||||||
|
{"key":"statusline","group":"Wbudowane","insert":"/statusline ","desc":"Ustawia linię statusu."},
|
||||||
|
{"key":"terminal-setup","group":"Wbudowane","insert":"/terminal-setup ","desc":"Konfiguruje terminal."},
|
||||||
|
{"key":"todos","group":"Wbudowane","insert":"/todos ","desc":"Pokazuje listę zadań."},
|
||||||
|
{"key":"upgrade","group":"Wbudowane","insert":"/upgrade ","desc":"Zmienia plan."},
|
||||||
|
{"key":"usage","group":"Wbudowane","insert":"/usage ","desc":"Pokazuje limity użycia."},
|
||||||
|
{"key":"vim","group":"Wbudowane","insert":"/vim ","desc":"Przełącza tryb vim."},
|
||||||
|
{"key":"workflows","group":"Wbudowane","insert":"/workflows ","desc":"Pokazuje przebieg workflow."},
|
||||||
|
{"key":"a","group":"Projekt","insert":"/a ","desc":"Komenda a"},
|
||||||
|
{"key":"s","group":"Projekt","insert":"/s ","desc":"Opis inna"},
|
||||||
|
{"key":"handoff","group":"Użytkownik","insert":"/handoff ","desc":"Przekazanie"},
|
||||||
|
{"key":"sp:brainstorming","group":"Pluginy","insert":"/sp:brainstorming ","desc":"Opis brainstorming"},
|
||||||
|
];
|
||||||
|
|
||||||
|
test("the / menu of Claude Code stays as it was (pinned before profiles)", async () => {
|
||||||
|
const { exec, readText } = ccMachine(CC_FILES);
|
||||||
|
const global = await globalCommands(HOME, exec, readText);
|
||||||
|
const items = await commands("/proj", exec, { agent: "claude-code", global });
|
||||||
|
assert.deepEqual(items.map(ccRow), EXPECTED_CC);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user