MCPcopy Create free account
hub / github.com/ConardLi/easy-agent / tryExpandSkillCommand

Method tryExpandSkillCommand

src/core/queryEngine.ts:377–420  ·  view source on GitHub ↗

* Expand `/skill-name [args]` into the two-message pattern source uses: * - `markerContent` — short XML block consumed by the UI to render a * styled "❯ /skill-name args" command bubble in the transcript. * - `bodyText` — the substituted SKILL.md body that becomes the actual *

(
    input: string,
  )

Source from the content-addressed store, hash-verified

375 // The auto-trigger (background-agent reply) path has no
376 // user-typed prompt for the UI to stamp via beginUserTurn(), so open
377 // the turn here. Normal turns already had beginUserTurn() called by the
378 // UI before the prompt was persisted.
379 if (!trimmed) {
380 this.beginUserTurn();
381 }
382
383 if (trimmed.startsWith("/")) {
384 // Built-in `prompt` command (`/init`). Resolved FIRST so a
385 // reserved prompt command always means itself and can never be shadowed
386 // by a user command or skill file. Expands into a prompt and runs a
387 // normal model turn (the model analyses the repo and writes AGENT.md),
388 // using the same visible-marker + hidden-body pattern as skills.
389 const promptExpansion = tryExpandBuiltinPromptCommand(trimmed);
390 if (promptExpansion) {
391 const markerMessage: MessageParam = markMessageSource(
392 { role: "user", content: promptExpansion.markerContent },
393 "command",
394 );
395 this.messages = [...this.messages, markerMessage];
396 yield { type: "messages_updated", messages: [...this.messages] };
397 return yield* this.submitInternal(promptExpansion.bodyText);
398 }
399
400 // User-defined slash command (`/review [args]`). Resolved
401 // BEFORE skills so an explicit user command takes precedence, but we
402 // skip reserved built-in names so `/help`, `/output-style`, etc. can
403 // never be shadowed by a same-named file on disk. Expands into the
404 // same two-message pattern as skills (visible marker + hidden body).
405 const userExpansion = this.tryExpandUserCommand(trimmed);
406 if (userExpansion) {
407 if (userExpansion.model) {
408 this.turnModelOverride = userExpansion.model;
409 }
410 const markerMessage: MessageParam = markMessageSource(
411 { role: "user", content: userExpansion.markerContent },
412 "command",
413 );
414 this.messages = [...this.messages, markerMessage];
415 yield { type: "messages_updated", messages: [...this.messages] };
416 return yield* this.submitInternal(userExpansion.bodyText);
417 }
418
419 // User-invoked skill: `/skill-name [args]`. Resolve the skill against
420 // the registry; if it matches, expand into a two-message pattern
421 // (visible metadata bubble + hidden model-only body) and submit
422 // normally. Falls through to handleCommand() for /help, /mcp,
423 // /clear, etc. when no skill matches.

Callers 1

submitMessageMethod · 0.95

Calls 2

addSessionAllowRulesMethod · 0.95
findSkillFunction · 0.90

Tested by

no test coverage detected