Skip to content
Merged
Show file tree
Hide file tree
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 Sep 2, 2026
321aaae
Merge branch 'main' into feat/output-style-files
qqqys Sep 2, 2026
e21bb03
Merge branch 'main' into feat/output-style-files
qqqys Sep 2, 2026
eaf9e88
Merge branch 'main' into feat/output-style-files
yiliang114 Sep 3, 2026
599441c
fix(output-style): stop a style file reading anything but itself
qqqys Sep 3, 2026
cd8d043
fix(output-style): key the headless Learning rule on the built-in, no…
qqqys Sep 3, 2026
994a828
fix(output-style): stop a dismissed picker re-opening behind the user
qqqys Sep 3, 2026
2e3b878
fix(opentui): give the output-style picker the same catalog as ink
qqqys Sep 3, 2026
3b3ec63
Merge remote-tracking branch 'upstream/main' into codex/pr-10761-r4-fix
qqqys Sep 3, 2026
49b081b
fix(output-style): make picker loading non-interactive
qqqys Sep 3, 2026
4259337
Merge remote-tracking branch 'upstream/main' into codex/pr-10761-r4-fix
qqqys Sep 3, 2026
fd2ade4
Merge branch 'main' into feat/output-style-files
wenshao Sep 4, 2026
2823052
fix(opentui): keep the output-style picker steady while it is open
qqqys Sep 4, 2026
898d923
fix(output-style): read a style file the way a prompt should be read
qqqys Sep 4, 2026
fc41b13
fix(output-style): keep a resolved style inside the session it belong…
qqqys Sep 4, 2026
71c7196
fix(output-style): say what the setting takes, and where a choice lands
qqqys Sep 4, 2026
bb936ad
fix(cli): explain inactive project output styles
qqqys Sep 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .qwen/e2e-tests/output-style-files.md
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.
Comment thread
qqqys marked this conversation as resolved.
Resolved

## 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.
59 changes: 59 additions & 0 deletions docs/design/2026-09-02-output-style-files.md
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.
Comment thread
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.
Loading
Loading