Skip to content

feat: support inline skill references with $ autocomplete #282

Closed as not planned

Description

@somewan820

Problem

Pi currently exposes loaded skills as /skill:name slash commands. Slash command completion is only available at the beginning of a message, so a user cannot reference a skill naturally inside an already-written prompt.

For example, this does not offer skill completion:

Please review this endpoint using $farbay-java-develop

Proposal

Add inline skill references using $skill-name:

  • Typing $ at a token boundary opens completion for the skills currently loaded in the session.
  • Tab accepts a skill reference without submitting the message.
  • On submit, the selected reference is expanded to the native skill content before the model turn.
  • $ references work anywhere in the user message.
  • Existing /skill:name behavior remains unchanged.
  • Existing @path/to/file completion and file-reference behavior remains unchanged.

Example:

Please review this endpoint using $farbay-java-develop, focusing on authentication.

Implementation constraints

  • Use Pi as the source of truth for loaded skills, resource loading, trust, and reload lifecycle.
  • Do not duplicate the skill loader in OpenPI.
  • Keep the raw user-visible message distinct from the expanded model-visible prompt where the existing lifecycle supports that distinction.
  • Define behavior for unknown skills, escaped dollar signs, multiple references, and references adjacent to punctuation.

Acceptance criteria

  • Inline $ completion lists only currently loaded skills.
  • Selecting a skill does not submit the message.
  • A submitted inline reference actually loads the corresponding SKILL.md content.
  • Existing slash skill commands and @ file completion do not regress.
  • Tests cover completion, expansion, unknown references, and mixed inline text.

Activity

  1. added
    enhancement
    on Aug 29, 2026
  2. bkyssn commented on Aug 29, 2026

    @bkyssn
    Contributor

    I'd like to work on this issue.

  3. bkyssn commented on Aug 30, 2026

    @bkyssn
    Contributor

    Problem Statement

    Pi exposes Skills loaded in the current Session through /skill:name commands, but slash-command completion only works at the beginning of a message. A user who is already writing a prompt cannot naturally reference a loaded Skill in the middle of that prompt.

    Users need an inline Skill Reference that provides completion in the TUI and makes the selected Skill content model-visible when the message is submitted. This must preserve Pi as the source of truth for loaded Skills and must not change the existing /skill:name or @path/to/file behavior.

    Solution

    Support $skill-name as an Inline Skill Reference.

    At a valid token boundary, typing $ in the TUI shows only the Skills currently loaded in the Session. Accepting a completion inserts the reference without submitting the message.

    When any input channel submits a message containing known Inline Skill References, OpenPI keeps the raw user-visible message unchanged. It resolves the references against the Skills supplied by Pi for that model turn, loads each distinct referenced Skill once, and adds the native Skill content as a hidden model-visible message.

    Pi remains responsible for Skill discovery, trust, collisions, resource loading, and reload. OpenPI does not scan for Skills or maintain a second Skill registry.

    User Stories

    1. As an interactive Pi user, I want to type $ while writing a message, so that I can reference a Skill without moving to the beginning of the message.
    2. As an interactive Pi user, I want Inline Skill completion to list only Skills loaded in the current Session, so that every suggestion is valid for my current runtime.
    3. As an interactive Pi user, I want Skill candidates to include their descriptions, so that I can select the correct Skill.
    4. As an interactive Pi user, I want to accept an Inline Skill Reference with Tab, so that I can continue editing the same message.
    5. As an interactive Pi user, I want accepting a Skill completion to avoid submitting the message, so that completion does not interrupt composition.
    6. As an interactive Pi user, I want $skill-name to work at the start of a message, so that a slash command is not required.
    7. As an interactive Pi user, I want $skill-name to work after spaces or tabs inside a message, so that I can use it in natural prose.
    8. As an interactive Pi user, I want punctuation such as commas, periods, and closing parentheses to terminate a reference, so that references read naturally in sentences.
    9. As an interactive Pi user, I want text such as abc$skill-name to remain ordinary text, so that a dollar sign inside another token does not trigger a Skill.
    10. As an interactive Pi user, I want \$skill-name to remain literal text, so that I can explicitly prevent expansion.
    11. As a Pi user, I want an unknown $skill-name to remain unchanged, so that a typo or ordinary dollar-prefixed token does not silently load unrelated content.
    12. As a Pi user, I want a known Inline Skill Reference to load the corresponding SKILL.md content, so that the model follows the selected Skill instructions.
    13. As a Pi user, I want my raw $skill-name message to remain user-visible, so that the Session accurately shows what I wrote.
    14. As a Pi user, I want Skill content to be model-visible without being rendered as a second visible user message, so that runtime context does not clutter the conversation UI.
    15. As a Pi user, I want repeated references to the same Skill to load that Skill only once, so that the model context does not contain duplicate instructions.
    16. As a Pi user, I want different Skills to load in first-reference order, so that the model-visible context has deterministic ordering.
    17. As a Pi user, I want Inline Skill expansion to work for TUI, RPC, print mode, and other normal Session input paths, so that prompt meaning does not depend on the transport.
    18. As a Pi user, I want only the TUI to provide the completion menu, so that non-interactive transports do not gain an artificial UI protocol.
    19. As a Pi user, I want /skill:name to keep its native behavior, so that existing workflows continue to work.
    20. As a Pi user, I want @path/to/file completion and file-reference behavior to remain unchanged, so that Inline Skill completion does not interfere with file references.
    21. As a Pi user, I want reload to change Inline Skill candidates without stale cached state, so that completion always follows the current Session.
    22. As a project maintainer, I want Pi to remain the only Skill registry, so that OpenPI does not duplicate discovery, trust, collision, or reload logic.
    23. As a project maintainer, I want the feature to use Pi extension seams, so that it composes with Pi instead of introducing another lifecycle.
    24. As a project maintainer, I want failed Skill content loading to be visible as an extension error, so that the runtime does not silently claim that a Skill was supplied to the model.

    Implementation Decisions

    • Wrap Pi's existing autocomplete provider through the public autocomplete extension seam. The wrapper handles Inline Skill References and delegates all unrelated completion, including slash commands and file references, to the current provider.
    • Obtain completion candidates dynamically from Pi's command projection. Include only commands whose source is skill, and derive the Inline Skill name from the native Skill command name. Do not cache candidates.
    • $ starts an Inline Skill Reference only at the start of input or after horizontal whitespace. A Skill name must exactly match a currently loaded Skill. Normal punctuation can follow the name and is not part of the reference.
    • Completion inserts the literal $skill-name. It does not submit the editor and does not replace the reference with Skill content.
    • Perform expansion at the shared pre-model Session seam so that all normal input channels use the same rule. TUI autocomplete remains TUI-only.
    • Preserve the raw user-visible message. Add referenced Skill content as one hidden model-visible custom message for the model turn.
    • Resolve submitted references only against the Skills supplied by Pi for that model turn. This is the authoritative expansion set and prevents arbitrary file access through $ text.
    • Read content only from the file path provided by the matched loaded Skill. Remove Skill frontmatter and use the native Skill content envelope, including the Skill location and reference base directory.
    • This content projection is not a second Skill loader. Pi continues to own discovery, trust, source precedence, collision handling, diagnostics, and reload.
    • Load each distinct referenced Skill once. Preserve the order in which distinct Skills first appear in the raw message.
    • Leave unknown references unchanged and do not add model-visible Skill content for them.
    • Leave escaped references unchanged, including the escape character, and do not expand them.
    • Do not add Markdown parsing for code spans or fenced code blocks. Escaping is the explicit opt-out mechanism.
    • Surface Skill read failures through Pi's extension error reporting. Do not silently substitute missing content or report a failed Skill as loaded.
    • Add no configuration, setup option, persistent cache, model-facing tool, parallel registry, or new editor state.

    Testing Decisions

    • Test observable behavior at the highest existing seams: Pi's autocomplete-provider boundary for completion, the TUI Editor boundary for Tab acceptance, and the shared pre-model Session boundary for expansion.
    • Add an autocomplete test that proves only currently loaded Skill commands become $ candidates and that candidate descriptions are preserved.
    • Add a TUI Editor integration test that proves Tab inserts the selected $skill-name, updates the editor, and does not call submit.
    • Add delegation regression tests proving slash completion and @path/to/file completion still use the existing provider.
    • Add expansion tests using temporary Skill fixtures. Prove that the raw user message is unchanged and the hidden model-visible message contains the frontmatter-stripped Skill body.
    • Add lexical behavior tests for start-of-input references, whitespace boundaries, adjacent punctuation, embedded dollar signs, escaped references, and unknown references.
    • Add multiple-reference tests proving that distinct Skills follow first-reference order and repeated references are included only once.
    • Add a dynamic-source test proving that changing Pi's loaded Skill command projection changes candidates without recreating an OpenPI cache.
    • Test expansion once at the shared Session seam rather than duplicating the same behavior test for every transport. The shared seam is the contract that gives TUI, RPC, print mode, and other normal inputs the same expansion behavior.
    • Keep completion tests, model-visible context tests, and user-visible raw-message tests separate because they validate different projections.
    • Use existing OpenPI patterns for autocomplete delegation, hidden before_agent_start messages, and UI input acceptance where applicable.
    • After focused tests pass, run the repository's complete check and test commands from the current main branch.

    Out of Scope

    • Replacing or modifying Pi's Skill loader.
    • Scanning Skill directories from OpenPI.
    • Maintaining a second Skill registry or cache.
    • Changing Pi's native /skill:name behavior.
    • Changing interactive @path/to/file completion or making inline file references load file contents.
    • Adding Inline Skill completion protocols to RPC, print mode, or other non-TUI transports.
    • Adding fuzzy matching or automatic correction for unknown Skill names.
    • Parsing Markdown code spans or fenced code blocks to infer whether a reference should expand.
    • Adding configuration, setup commands, feature flags, or model-facing tools.
    • Modifying Pi to add a public Skill expansion API as part of this issue.

    Further Notes

    • The implementation must begin from the current main branch rather than the older investigation checkout.
    • Manual validation must follow the repository's runtime provenance procedure: prove the checkout revision and prove that pi list reports exactly one OpenPI source pointing at that checkout before interpreting TUI behavior.
    • Manual validation should cover Inline Skill completion and Tab acceptance, model-visible Skill content, preserved raw user text, repeated and unknown references, escaped references, punctuation, native slash Skill commands, and file completion.
    • Pi currently exposes loaded Skill metadata to extensions but does not expose a public native Skill-expansion function. This spec deliberately uses Pi's authoritative loaded Skill metadata and file path, then performs only the minimal content projection required for an explicit user reference.
  4. tt-a1i commented on Sep 7, 2026

    @tt-a1i
    Collaborator

    依据已接受的 Decision 0002 和已合并 #322,OpenPI 保留 Pi 原生 /skill:name 调用与生命周期,不再新增 $skill 行内语法、补全或独立正文恢复层。以 not planned 关闭旧提案,而非声称该行内功能已经实现。方向由维护者主动调整,保留并感谢原贡献者按旧要求完成的工作。

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

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions