Skip to content

Expose Codex skills as ACP slash commands#279

Open
daniel-agentee wants to merge 1 commit into
zed-industries:mainfrom
daniel-agentee:skills-as-slash-commands
Open

Expose Codex skills as ACP slash commands#279
daniel-agentee wants to merge 1 commit into
zed-industries:mainfrom
daniel-agentee:skills-as-slash-commands

Conversation

@daniel-agentee
Copy link
Copy Markdown

Summary

Adds support for invoking Codex skills via ACP slash commands. Selecting /code-review (or any other locally-installed skill) in an ACP client's slash menu hands Codex the same $code-review text its TUI would have produced when the user types $ and picks the skill.

Why

#190 asked for this. Today, ACP clients only see the hardcoded builtin slash commands. Users who have skills installed locally (~/.codex/skills/<name> or project-level .codex/skills/) can't access them from Zed (or any other ACP client), even though Codex itself loads them at session start and the model can already invoke them via implicit-skill detection.

How

  • ThreadActor now carries an Option<Arc<SkillsManager>> and a cached_skills: Vec<SkillMetadata>.
  • On session Load and on every EventMsg::SkillsUpdateAvailable, the cache is refreshed via SkillsManager::skills_for_cwd and a fresh AvailableCommandsUpdate is emitted with builtins + skills merged.
  • SkillsUpdateAvailable is intercepted at the ThreadActor level (not per-submission) so the slash menu refresh is session-scoped rather than tied to an in-flight prompt.
  • In the slash dispatcher, unknown commands matching a cached skill are rewritten to \$name <rest> and submitted as a normal Op::UserInput. Codex's detect_implicit_skill_invocation_for_command picks them up the same way it does for TUI-typed \$name mentions, so no new Codex-side surface is needed.
  • Skill names that collide with a builtin are dropped with a tracing::warn! so a skill can't shadow /init, /compact, /review, etc.

Known gap

Plugin-supplied skill roots aren't threaded through yet — effective_skill_roots is passed as vec![]. Only user/project/system skills appear in the menu today; plugin-distributed skills do not. A follow-up PR can wire the plugin outcome through to match the TUI's coverage exactly. The hooks are all in place; this is mechanical work waiting on a pattern decision (call into a Codex-side helper vs. replicate the plugin resolution here).

Tests

  • 5 new unit tests for the /name\$name rewrite helper covering with-args, no-args, multi-item prompts, leading-image prompts, and whitespace handling.
  • All 25 tests pass (cargo test).

Manual verification

Built locally with cargo build --release, pointed Zed at the binary via agent_servers.codex-acp.command, opened a Codex thread, and confirmed user-level + system skills appear in the slash menu alongside the builtins. Invoked one and saw the skill execute as expected.

References #190.

Codex skills (loaded via SkillsManager) are now advertised to ACP clients
alongside the existing builtin slash commands. Selecting a skill rewrites
the leading "/name ..." text into Codex's implicit-skill form ("$name ...")
before submission, so invocation goes through the same implicit-skill path
the TUI uses when a user types `$` and picks a skill from the popup.

The cache is refreshed at session load and whenever Codex emits
EventMsg::SkillsUpdateAvailable; the latter is intercepted at the
ThreadActor level (not per-submission) and triggers a session-wide
AvailableCommandsUpdate. Skill names that collide with a builtin
(/init, /compact, /review, etc.) are dropped with a warning so a skill
cannot shadow a builtin.

Plugin-supplied skill roots are not yet threaded through — only
user/project/system skills appear today. Following PR can wire the
plugin outcome through to fully match the TUI's coverage.

References zed-industries#190.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 05777bafd3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/thread.rs
drop(response_tx.send(result));
self.refresh_skills().await;
let client = self.client.clone();
let commands = self.available_commands();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Send command updates from current cache, not a stale snapshot

ThreadMessage::Load snapshots self.available_commands() before the 200ms delayed task runs, so if a SkillsUpdateAvailable event arrives during that window, the actor first sends the fresh command list from handle_event and then overwrites it with this older snapshot. In practice this can make newly added/removed skills disappear from the slash menu until another skills event occurs. Recompute commands at send time (or avoid the delayed stale send) so updates are monotonic.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant