Repository navigation
feat: load custom output styles from ~/.qwen/output-styles and .qwen/output-styles #10761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a8186c4
feat: load custom output styles from ~/.qwen/output-styles and .qwen/…
qqqys 321aaae
Merge branch 'main' into feat/output-style-files
qqqys e21bb03
Merge branch 'main' into feat/output-style-files
qqqys eaf9e88
Merge branch 'main' into feat/output-style-files
yiliang114 599441c
fix(output-style): stop a style file reading anything but itself
qqqys cd8d043
fix(output-style): key the headless Learning rule on the built-in, no…
qqqys 994a828
fix(output-style): stop a dismissed picker re-opening behind the user
qqqys 2e3b878
fix(opentui): give the output-style picker the same catalog as ink
qqqys 3b3ec63
Merge remote-tracking branch 'upstream/main' into codex/pr-10761-r4-fix
qqqys 49b081b
fix(output-style): make picker loading non-interactive
qqqys 4259337
Merge remote-tracking branch 'upstream/main' into codex/pr-10761-r4-fix
qqqys fd2ade4
Merge branch 'main' into feat/output-style-files
wenshao 2823052
fix(opentui): keep the output-style picker steady while it is open
qqqys 898d923
fix(output-style): read a style file the way a prompt should be read
qqqys fc41b13
fix(output-style): keep a resolved style inside the session it belong…
qqqys 71c7196
fix(output-style): say what the setting takes, and where a choice lands
qqqys bb936ad
fix(cli): explain inactive project output styles
qqqys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Custom Output Style Files | ||
|
|
||
| ## Goal | ||
|
|
||
| Confirm that a style file in `~/.qwen/output-styles/` or the project's | ||
| `.qwen/output-styles/` is offered by `/output-style`, applies to the running | ||
| session, survives a restart through `general.outputStyle`, and is refused in | ||
| the cases the design excludes (untrusted workspace, `--safe-mode`). | ||
|
|
||
| ## Baseline | ||
|
|
||
| Run the global `qwen` first: `/output-style` lists only the four built-ins and | ||
| `/output-style reviewer` reports an unknown style. The scenarios below must | ||
| change that. | ||
|
|
||
| ## Fixtures | ||
|
|
||
| ```bash | ||
| mkdir -p ~/.qwen/output-styles .qwen/output-styles | ||
| cat > ~/.qwen/output-styles/reviewer.md <<'EOF' | ||
| --- | ||
| name: Reviewer | ||
| description: Reviews code and reports findings without editing anything | ||
| --- | ||
| You are reviewing, not implementing. List concrete findings ordered by severity and never edit files unless asked. | ||
| EOF | ||
| cat > .qwen/output-styles/haiku.md <<'EOF' | ||
| Answer every question as a haiku. Keep it to three lines. | ||
| EOF | ||
| cat > .qwen/output-styles/broken.md <<'EOF' | ||
| --- | ||
| name: default | ||
| --- | ||
| This file must be skipped. | ||
| EOF | ||
| ``` | ||
|
|
||
| ## Scenarios | ||
|
|
||
| 1. **Picker lists custom styles.** `npm run dev`, then `/output-style`. Expect | ||
| the four built-ins followed by `Reviewer — … (user)` and | ||
| `haiku — Answer every question as a haiku. … (project)`. No `broken` entry. | ||
| 2. **Project style applies now.** Select `haiku`. Expect | ||
| `Output style set to haiku.` and `~/.qwen/settings.json` to contain | ||
| `"outputStyle": "haiku"`. Ask "what does package.json do?" and expect a | ||
| three-line answer. | ||
| 3. **Name argument, case-insensitive.** `/output-style REVIEWER`. Expect | ||
| `Output style set to Reviewer.` | ||
| 4. **New file without restart.** With the session still open, add | ||
| `.qwen/output-styles/terse.md` containing `One sentence only.` then run | ||
| `/output-style` again. Expect `terse` in the list. | ||
| 5. **Unknown name lists custom styles.** `/output-style nope`. Expect the | ||
| error to list `Concise, Proactive, Explanatory, Learning, Reviewer, haiku, | ||
| terse`. | ||
| 6. **Persists across restart.** Exit, start again, ask a question. Expect a | ||
| haiku (or the last selected style) with no `/output-style` call. | ||
| 7. **Safe mode keeps built-ins.** `npm run dev -- --safe-mode`. Expect no | ||
| custom style applied and `/output-style` to refuse. | ||
| 8. **Untrusted workspace.** In a folder not trusted under | ||
| `security.folderTrust`, expect the picker to show `Reviewer` but not | ||
| `haiku`. | ||
|
|
||
| ## Cleanup | ||
|
|
||
| ```bash | ||
| rm -rf .qwen/output-styles ~/.qwen/output-styles/reviewer.md | ||
| ``` | ||
|
|
||
| Restore `general.outputStyle` in `~/.qwen/settings.json` to its prior value. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Custom output style files | ||
|
|
||
| Follow-up to the built-in styles (#9565, #10282), the `general.outputStyle` | ||
| setting and `--output-style` flag (#10283), and the `/output-style` picker | ||
| (#10683). Those slices left `OutputStyleSource` with `user`, `project` and | ||
| `extension` members that nothing populated. This slice populates the first two. | ||
|
|
||
| ## What a style file is | ||
|
|
||
| A Markdown file in `~/.qwen/output-styles/` or `<project>/.qwen/output-styles/`. | ||
| The body is the prompt section; an optional YAML frontmatter carries `name`, | ||
| `description` and `keep-coding-instructions`. Every field has a default (file | ||
| name, first body line, `false`), so a bare Markdown file is a valid style. | ||
| The keys are kebab-case on purpose: they are the keys a style file written for | ||
| other CLI agents already uses, so one file works in both. | ||
|
|
||
| ## Decisions | ||
|
|
||
| - **Only two directories, top level only.** No policy/managed level, no | ||
| additional-directory scan, no recursion. Each of those is a separate | ||
| decision with its own trust story; none is needed to make the feature | ||
| useful. The loader takes a directory and a source label, so more levels | ||
| are one call each if they ever land. | ||
| - **Project files require a trusted workspace.** A checked-in style file is a | ||
| prompt. The CLI passes the project root to the catalog only when | ||
| `isWorkspaceTrusted` says so, and the command does the same through | ||
| `config.isTrustedFolder()`. This is the same line the workspace | ||
| `settings.json` already draws. | ||
| - **`--bare` and `--safe-mode` keep the built-ins.** Both modes already ignore | ||
| the setting and refuse `/output-style`; the catalog is never read there, so a | ||
| broken file cannot affect a diagnostic run. | ||
| - **Precedence project > user > built-in, by case-insensitive name.** Mirrors | ||
| `SkillManager`. A custom file may shadow a built-in name; a user who names a | ||
| file `concise.md` gets their file, which is the least surprising outcome | ||
| and matches how skills behave. | ||
| - **`keep-coding-instructions` defaults to `false` for a file.** The built-ins | ||
| are all coding styles and set it to `true`; a file is assumed to describe | ||
| something else until it says otherwise. The section it drops is exactly the | ||
| software-engineering workflow guidance; safety rules and tool guidance stay. | ||
| - **Re-read on use, no cache, no watcher.** The catalog is read at startup | ||
| (to resolve the setting or flag), when the picker opens, and when a name | ||
| is given to `/output-style`. Two small directory reads are cheap, and it | ||
| means adding a file needs no restart. A hand edit to the _active_ style's | ||
| file still needs a re-select, since the prompt is only rebuilt on apply. | ||
| - **Bad files are skipped, not fatal.** Empty body, reserved or malformed | ||
| name, or a file over 1 MiB is logged to the debug log and the rest load. | ||
| Startup already applies the no-lockout rule to an unknown setting value. | ||
| - **The picker resolves against the list it showed.** The hook keeps the | ||
| catalog it loaded when opening; the selection is resolved against that | ||
| list, not a fresh read, so a file removed between open and select yields a | ||
| clear error rather than a silent no-op. | ||
|
qqqys marked this conversation as resolved.
Resolved
|
||
|
|
||
| ## Out of scope | ||
|
|
||
| - Extension-bundled styles (`source: 'extension'`), including the | ||
| `outputStyles` manifest field the Claude-plugin converter currently | ||
| warns about. Next slice. | ||
| - A settings-file watcher applying a hand-edited `general.outputStyle` | ||
| mid-session. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.