Skip to content

feat(rules): write qwencode output-style rules to .qwen/output-styles - #3993

Merged
dyoshikawa merged 6 commits into
mainfrom
resolve-issue-2668-qwen-output-styles
Nov 26, 2026
Merged

dyoshikawa merged 6 commits into
mainfrom
resolve-issue-2668-qwen-output-styles

Conversation

@dyoshikawa

@dyoshikawa dyoshikawa commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds the last open item of #2668: Qwen Code custom output style files. A non-root rule with qwencode.channel: output-style is now written to .qwen/output-styles/<rule file name>.md (project) / ~/.qwen/output-styles/<rule file name>.md (global) instead of .qwen/rules/. rulesync import --targets qwencode reads those files back as output-style rules. Together with the qwencode.general.outputStyle permissions override (#3384), a repo can now ship a style and select it through rulesync.

Upstream contract (checked against primary sources): docs/users/features/output-styles.md and the loader packages/core/src/core/output-style-files.ts. A style is a Markdown body with optional name / description / keep-coding-instructions frontmatter. Only the direct *.md children of the directory are read. Qwen Code skips a file with an empty body, a name that is default (case-insensitive) or longer than 64 characters, or a size over 25,000 bytes.

Changes

  • src/features/rules/rulesync-rule.ts: new qwencode frontmatter section with channel: "output-style", name (trimmed, 1-64 chars) and keep-coding-instructions (boolean).
  • src/features/rules/qwencode-rule.ts: the output-style write path (buildOutputStyle), import through fromFile/toRulesyncRule, forDeletion, getExtraFixedFiles (import-only *.md glob) and getRuleOptionWarnings. These reuse the shared helpers in output-style-paths.ts, which Qoder and Factory Droid already use.
  • src/constants/qwencode-paths.ts: directory, reserved name and size/name limits.
  • src/features/rules/output-style-paths.ts: qwencode added to the warning helper's target union.
  • Tests: qwencode-rule.test.ts covers both scopes, bare and full frontmatter, keep-coding-instructions: false, a root rule ignoring the channel, nested / reserved / empty / oversized / long-name refusals, import round trip and warnings. rules-processor.test.ts covers import enumeration (only direct .md children, never deletion) and generation into .qwen/output-styles instead of .qwen/rules at both scopes. e2e-rules.spec.ts adds a generate + import round trip.
  • Docs: rules frontmatter example and the Qwen Code rules note in docs/reference/file-formats.md. The permissions note no longer says that rulesync does not write the style files. Also updated the rulesync-feature-research qwencode reference and regenerated the docs content.

Design decisions

  • Same shape as Qoder / Factory Droid: the output-style channel lives on rules, root rules ignore it, and a rule nested under .rulesync/rules/ is refused. The output file is named after the rule file, and qwencode.name sets only the frontmatter name.
  • Import only, no deletion or gitignore entry: the directory also holds styles written by hand, including personal ones under ~/.qwen/output-styles/. rulesync cannot tell those from its own files, so --delete leaves the directory alone. Qoder and Factory Droid already work this way. The triage plan mentioned "orphan deletion limited to output-style files rulesync owns". Rulesync has no ownership tracking for this, so I followed the existing precedent instead.
  • default is refused at generate time, not in the schema. The check covers both qwencode.name and the file stem, because a file named default.md with no name is reserved too. This matches Factory Droid's reserved-name check. The triage plan proposed a schema-level rejection, which would have missed the stem case.
  • Generate fails on styles Qwen Code would skip without telling anyone. That covers a name (qwencode.name, or else the file stem) that is default, longer than 64 characters or contains control characters, an empty body, and a file over 25,000 bytes. The checks mirror the upstream loader and avoid an output file that silently does nothing.
  • Import skips the same styles with a warning instead of failing. .qwen/output-styles/ holds hand-written files, and before this change one bad style failed the whole rulesync import --targets qwencode. A new ToolRule#getImportSkipReason() hook (default undefined) is checked for importOnly extra files in the rules processor. QwencodeRule uses it so that import, then generate, round-trips.
  • keep-coding-instructions is written only when set. Upstream inherits a value from a built-in style of the same name when the key is absent, so rulesync never adds a default. Setting it without the channel prints a warning, the same way a stray qwencode.name does.
  • Selecting the style stays with the existing qwencode.general.outputStyle permissions override. This PR does not wire the two together automatically.

Skipped items (declined, with reasons)

Every other item on this issue was already resolved by earlier PRs (#3275, #3306, #3325, #3370, #3384, #3467, #3677, #3809 and the tools.lspEnabled commit).

Closes #2668

🤖 Generated with Claude Code

https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4

dyoshikawa and others added 3 commits November 26, 2026 17:01
A non-root rule with qwencode.channel: output-style is written as a Qwen
Code custom output style (.qwen/output-styles/<name>.md, project and
global) with name / description / keep-coding-instructions frontmatter,
and imported back from that directory. Styles Qwen Code would skip
(reserved "default" name, empty body, over 25 kB, nested source rule)
are refused at generate time.

Closes #2668

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
A hand-written style in .qwen/output-styles/ with a name over 64
characters, a reserved name, an empty body or a size over 25 kB used to
fail the whole import. It is now skipped with a warning through a new
ToolRule#getImportSkipReason hook. Generate also checks the 64-character
limit and control characters on the effective style name (file stem
fallback), using the shared constants.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…en-output-styles

# Conflicts:
#	src/generated/docs-content.ts
@github-actions

Copy link
Copy Markdown
Contributor

@dyoshikawa The CI checks on this pull request are currently failing.

Please review the failing checks and push a fix. If you need help, leave a comment and a maintainer will follow up.

dyoshikawa and others added 3 commits November 26, 2026 18:23
…en-output-styles

# Conflicts:
#	src/generated/docs-content.ts
…tripping

Replace the single-pass `<!-- ... -->` regex removal (CodeQL
js/incomplete-multi-character-sanitization) with an indexOf scan that
checks the text between comments in place. Behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…en-output-styles

# Conflicts:
#	src/generated/docs-content.ts
@dyoshikawa
dyoshikawa merged commit 5f0a641 into main Nov 26, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-2668-qwen-output-styles branch November 26, 2026 09:44
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.

Follow up Qwen Code upstream updates: .qwen/review-rules.md checks surface, fork profiles, server-level mcp.allowed/excluded

2 participants