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

@@ -6,10 +6,13 @@
// reads the person's snippets and passes them in, and it schedules the retry
// and the debounce with the numbers exported here.
//
// Three sources for `/` (the design's §5.3): the built-in commands of the
// agent, the project's own `.claude/commands/*.md` and
// `.claude/skills/*/SKILL.md`, and the person's saved snippets. One source
// for `@`: the files git tracks in the pane's folder.
// Sources for `/` (the design's §5.3): the built-in commands of the agent,
// the person's saved snippets and - for Claude Code only (`isClaudeCode`) -
// the project's own `.claude/commands/*.md` and `.claude/skills/*/SKILL.md`
// and the global commands of `~/.claude` and its plugins. Another agent does
// not understand the `.claude` files, so it gets its built-ins and snippets,
// and nothing is read for it. One source for `@`: the files git tracks in the
// pane's folder.
//
// A read that fails is not an empty list: the failure is reported through
// `onReadError` and the menu keeps what it knows. A caller with no handler
@@ -155,8 +158,22 @@ export function retryDelay(attempt) {
}
/**
* The commands the `/` menu offers: the agent's built-ins, the project's own
* and the person's snippets.
* Is this agent Claude Code (under its name or its alias)? Only its commands
* live in `.claude` files.
*
* @param {string|undefined} agent
* @returns {boolean}
*/
export function isClaudeCode(agent) {
const name = String(agent ?? "");
return (AGENT_ALIASES[name] ?? name) === "claude-code";
}
/**
* The commands the `/` menu offers: the agent's built-ins and the person's
* snippets - and, for Claude Code only, the project's own commands and the
* global ones (`options.global`). For another agent the project is not read
* (no `exec`) and `options.global` is ignored.
*
* A source that cannot be read does not take the others with it: the menu
* shows what is known and the failure goes to `onReadError`, so the caller
@@ -173,6 +190,9 @@ export async function commands(cwd, exec, options = {}) {
const builtins = builtinItems(options.agent);
const snippets = snippetItems(options.snippets);
// The `.claude` files mean something to Claude Code alone.
if (!isClaudeCode(options.agent)) return [...builtins, ...snippets];
let project = [];
try {
project = await projectItems(cwd, exec);
@@ -2215,7 +2215,8 @@ export default class Composer extends View {
this.closeMenu();
return;
}
if (token.trigger === "/") this.refreshGlobal(cx);
// `~/.claude` is read for Claude Code only - no other agent understands it.
if (token.trigger === "/" && catalog.isClaudeCode(agentName(agent))) this.refreshGlobal(cx);
this.scheduleLoad(agent, token, cx);
}