qwen-code/docs/users/features
易良 d2ece83726
feat(skills): support priority field in SKILL.md for sorting skill display order (#4155)
* feat(skills): support priority field in SKILL.md for sorting skill display order

Closes #4136

* fix(skills): make /skills respect priority and treat unset as 0

- /skills was re-sorting alphabetically after listSkills(), masking the
  new priority order. Drop the redundant sort and reuse the manager's
  output directly.
- Treat missing priority as 0 instead of -Infinity so an explicit
  negative priority (e.g. -1) sorts below unset skills, which matches
  user intent.

* fix(skills): harden priority parsing and ordering

* fix(skills): warn when extension supplies invalid priority

Extension-provided skills bypass parseSkillContent / validateConfig, so a
non-number `priority` was silently normalized to 0 in the sort with zero
diagnostic. Match the SKILL.md author signal: warn at load time so the
extension author can see and fix the typo.

Addresses PR #4155 review (the extension-bypass-validation point).

* test(skills): direct unit tests for parsePriorityField and normalizeSkillPriority

Both helpers are exported but previously had no direct tests — coverage
came only via parseSkillContent and listSkills. Adds inputs the
integration paths can't surface cleanly: -0 / NaN / Infinity, numeric
strings, objects, arrays, and the boolean coercion regression that
motivated the strict typecheck.

Also adds a NOTE on parsePriorityField warning future contributors that
SKILL.md frontmatter parsing lives in two places (parseSkillContent here
and SkillManager.parseSkillContent), so any new field must be wired into
both — the same regression that previously hit whenToUse,
disable-model-invocation, paths, and priority. Full dedup of the two
parseSkillContent bodies is left as a follow-up refactor.

Addresses the remaining two [Suggestion] items from PR #4155 review.

* fix(skills): scope priority to /skills listing only

Earlier in this PR, `skill.priority` was mapped into `SlashCommand.completionPriority`
on both bundled and non-bundled skill loaders, so a high-priority skill
also bubbled up in the slash-completion menu and the `/help` custom-commands
tab. That was broader than intended — the design goal is for `priority:`
to control the `/skills` listing only, with everything else (typing `/`,
mid-input completion, `/help`) staying purely alphabetical so a skill
can't reorder built-in commands.

Changes:
- BundledSkillLoader / SkillCommandLoader: drop the
  `completionPriority: skill.priority` mapping. Skill commands now have
  no `completionPriority`, falling back to alphabetical+recency in the
  shared completion comparator.
- Help.tsx: revert the per-group sort to `localeCompare` and remove the
  `compareCommandsForHelp` helper. `/help` is again purely alphabetical
  within each group.
- Tests:
  - Both loader tests assert `completionPriority` is `undefined` when
    a skill has a `priority` set, locking the non-leakage in.
  - Help.test.tsx's "orders by completionPriority" case is replaced
    with "orders alphabetically regardless of completionPriority", so a
    future change that re-introduces the leak fails the test.
- Extension-skill validation also normalizes `skill.priority` to 0 (in
  addition to the existing sort-time normalization) so downstream
  consumers see a clean value matching the emitted warning.

Validation:
- 177/177 unit tests pass across the 5 affected test files
- core typecheck clean
- bundled CLI built (`npm run bundle`) and exercised via tmux E2E:
  E1 /skills sorted by priority, E2 / completion menu unaffected,
  E3 mid-input alphabetical, E4 invalid priority warns + skill loads,
  E5 order stable across restart — all 5 pass.

* fix(skills): tag priority warning with calling module's namespace

`parsePriorityField` previously hardcoded `debugLogger.warn` from
skill-load, so a warning emitted from `SkillManager.parseSkillContent`
(project / user / bundled skills) was tagged `[SKILL_LOAD]` instead of
`[SKILL_MANAGER]`. Annoying for log filtering and slightly misleading
about which parse path actually surfaced the bad priority.

Added an optional `warn` callback parameter; the existing extension
call site keeps the default skill-load logger, while skill-manager
passes its own. Behavior is otherwise unchanged.

* docs(skills): correct priority scope description

Earlier doc said priority sorts "in /skills, slash-command completion,
and the /help custom commands view." After the scope-narrowing in
96722aa67, priority only affects /skills. Updating the doc to match
the actual behavior so readers don't expect cross-surface ordering.

* fix(skills): keep listSkills() alphabetical, sort priority at /skills display

`listSkills()` previously returned priority-desc order for every consumer,
including `SkillTool.refreshSkills()` which builds the model-facing
`<available_skills>` description. That contradicted the stated design goal
(`priority:` controls the `/skills` listing only) and the user docs, which
say everything outside `/skills` stays alphabetical.

- skill-manager.ts: `listSkills()` now sorts name-asc only, giving all
  programmatic consumers (SkillTool, contextCommand, loaders) a stable
  alphabetical order unaffected by `priority:`.
- skillsCommand.ts: apply the priority-desc, name-asc sort at the display
  layer using the shared `normalizeSkillPriority`.
- skills/index.ts: export `normalizeSkillPriority` for the CLI display sort.
- Tests: core tests now lock in that `listSkills()` stays alphabetical
  regardless of priority; new skillsCommand.test.ts covers the display sort.

* fix: correct copyright year 2025 -> 2026 in new file [skip ci]
2026-05-21 14:49:22 +08:00
..
channels feat(channels): add dispatch modes and prompt lifecycle hooks 2026-03-28 06:19:02 +00:00
_meta.ts feat(cli,core): add Auto approval mode with LLM classifier (#4151) 2026-05-20 10:30:05 +08:00
approval-mode.md feat(core): add NotebookEdit tool for Jupyter notebooks 2026-05-21 00:06:15 +08:00
arena.md feat(arena): add comparison summary for agent results (#3394) 2026-04-22 05:31:19 +08:00
auto-mode.md feat(cli,core): add Auto approval mode with LLM classifier (#4151) 2026-05-20 10:30:05 +08:00
checkpointing.md feat: restructure docs 2025-12-04 18:26:05 +08:00
code-review.md feat(cli): route foreground subagents through pill+dialog while running (#3768) 2026-05-06 14:08:12 +08:00
commands.md feat(cli): add session path status command (#4124) 2026-05-20 16:33:19 +08:00
dual-output.md feat(cli): add dual-output sidecar mode for TUI (#3352) 2026-04-18 02:14:53 +08:00
followup-suggestions.md fix: improve /model --fast description clarity and prevent accidental activation (#3077) 2026-04-10 12:09:46 +08:00
headless.md feat(retry): add persistent retry mode for unattended CI/CD environments (#3080) 2026-04-21 22:08:11 +08:00
hooks.md feat(hooks): add prompt hook type with LLM evaluation support (#3388) 2026-05-15 17:13:05 +08:00
language.md refactor(cli): revert dynamic slash command LLM translation (#4145) 2026-05-15 16:01:16 +08:00
lsp.md fix(lsp): expose status and startup diagnostics (#3649) 2026-05-17 01:42:28 +08:00
markdown-rendering.md feat(cli): expand TUI markdown rendering (#3680) 2026-05-07 16:24:13 +08:00
mcp.md feat(perf): progressive MCP availability — MCP no longer blocks first input (#3994) 2026-05-13 22:17:16 +08:00
memory.md feat(cli): support multi-line status line output (#3311) 2026-04-17 12:44:30 +08:00
sandbox.md feat(cli): support tools.sandboxImage in settings (#3146) 2026-04-13 09:43:34 +08:00
scheduled-tasks.md docs(scheduled-tasks): add documentation for /loop and cron scheduling features 2026-03-29 12:56:28 +08:00
skills.md feat(skills): support priority field in SKILL.md for sorting skill display order (#4155) 2026-05-21 14:49:22 +08:00
status-line.md feat(cli): support refreshInterval in statusLine for periodic refresh (#3383) 2026-04-19 11:12:16 +08:00
structured-output.md docs: user + design docs for --json-schema structured output (#4051) 2026-05-17 23:10:34 +08:00
sub-agents.md feat(core): extend cross-auth fast models to agents (#4153) 2026-05-20 00:25:29 +08:00
tips.md feat: add contextual tips system with post-response context awareness (#2904) 2026-04-13 17:40:27 +08:00
token-caching.md feat: update docs 2025-12-12 19:37:36 +08:00
tool-use-summaries.md feat(cli,core): LLM-generated summary labels for tool-call batches (#3538) 2026-04-27 16:54:10 +08:00