qwen-code/docs/users
易良 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
..
configuration feat(core): add NotebookEdit tool for Jupyter notebooks 2026-05-21 00:06:15 +08:00
extension chore(deps): upgrade ink 6.2.3 → 7.0.2 + bump Node engine to 22 (#3860) 2026-05-11 17:29:50 +08:00
features feat(skills): support priority field in SKILL.md for sorting skill display order (#4155) 2026-05-21 14:49:22 +08:00
ide-integration update documentation 2025-12-19 18:16:59 +08:00
reference feat(cli): readline Ctrl+P/N for history and selection navigation (#4082) 2026-05-16 23:07:25 +08:00
support docs: update authentication methods to reflect OAuth discontinuation (#3325) 2026-04-17 15:34:18 +08:00
_meta.ts feat(cli,sdk): qwen serve daemon (Stage 1) (#3889) 2026-05-13 14:47:47 +08:00
common-workflow.md docs: updated all links, click and open in vscode, new showcase video in overview 2025-12-17 11:10:31 +08:00
integration-github-action.md docs: updated all links, click and open in vscode, new showcase video in overview 2025-12-17 11:10:31 +08:00
integration-jetbrains.md docs(integration): use CDN URLs for images and fix formatting 2026-03-16 14:12:48 +08:00
integration-vscode.md fix: docs 2026-01-14 10:30:03 +08:00
integration-zed.md docs(integration): use CDN URLs for images and fix formatting 2026-03-16 14:12:48 +08:00
overview.md feat(installer): add standalone archive installation (#3776) 2026-05-11 13:25:48 +08:00
quickstart.md chore(deps): upgrade ink 6.2.3 → 7.0.2 + bump Node engine to 22 (#3860) 2026-05-11 17:29:50 +08:00
qwen-serve.md feat(serve): MCP guardrail push events + hysteresis (#4175 Wave 3 PR 14b) (#4271) 2026-05-19 01:06:20 +08:00