Files
plugins/packages/output-strategy/README.md
T
Mañjūṣaka 006e96ef03 output-strategy 0.2.1: finish #814's review follow-ups (#815)
Follow-up to #814 (081c67ac). The core request injection is unchanged.

- Page: static text goes back to English when magpie.theme.lang changes
  from zh to en. Unsaved style picks survive a language change, and the
  title follows the language. zh / zh-CN / zh-Hans use the Simplified
  strings. zh-TW and other languages fall back to English on purpose,
  with <html lang> kept as zh-TW. With no host theme, the page loads in
  English without throwing.
- apply.js: an empty system message gets the style block with no
  leading blank lines. The unused media detector and addedBytes are
  removed.
- style.css: obsolete stats/lang/workspace rules are removed, and the
  720px media block is closed again (52 { / 52 }).
- Tests: lowercase "delete" in the cross-turn cache case;
  empty/null/object system; zh -> en restore; unsaved picks kept;
  zh-TW; a missing theme; style.css brace balance and the version.
- PROVENANCE names ANTISLOP_BOUNDARIES (OmniRoute v3.8.52), checked
  byte for byte against the tag. The page/stats.js ignore is gone.
- Version 0.2.1. dist had only 0.2.0, and npm has no version yet.

Run at 2f971ab9 (mote, Bun 1.4.2, fresh HOME):
- package bun test: 55 pass, 0 fail;
- repo bun test: 6561 pass, 20 skip, 0 fail;
- scripts/check.mjs output-strategy: ok;
- CI run 42320776930 at this head, attempt 1: test and on-npm green;
- page render, main vs head, in Chromium and WebKit at 400/700/1000px:
  identical.
Broken by hand, each turning exactly one test red: the dropped }, the
version at 0.2.0, an unguarded theme.lang, the old conditional
applyTheme, a case-sensitive delete skip, the old appendInstruction,
one-way translate, unkept checkbox state, the old zh* normalize, and
addedBytes put back.
Not tried: a live theme switch in the real magpie window, and real
Claude Code/Codex sessions.
2026-11-07 09:10:31 +08:00

59 lines
3.5 KiB
Markdown

# output-strategy
Composable output-style instructions injected before a model call. Seven styles are available in a small selection panel; **every style is off by default**.
The style texts and the original request-injection design are adapted from OmniRoute's Output Styles, caveman, ponytail, i-have-adhd and 9router. Exact sources, revisions, licenses and adaptations are recorded in `PROVENANCE.json`; upstream license files are in `LICENSES/`.
## Styles
- **Terse prose** — remove filler, ceremony and hedging without losing technical content.
- **Less code** — YAGNI and the smallest working change.
- **Ponytail** — lazy senior-developer discipline: reuse, root causes and a complete minimal diff.
- **I have ADHD** — action first, numbered steps and one concrete next action.
- **Terse CJK** — ultra-terse Classical Chinese, with technical identifiers kept verbatim. Unlike OmniRoute's zh-only automatic use, this is an explicit style available for any locale.
- **Antislop UI** — purpose-tested visuals rather than template decoration and dead controls.
- **Antislop copy** — honest, specific copy with accessibility and complete UI states.
Select any combination in the **Output Strategy** panel and save. Styles are combined in catalog order and duplicate boundaries are included only once.
## Options
```json
{
"styles": {
"terse-prose": false,
"less-code": false,
"ponytail": true,
"i-have-adhd": false,
"terse-cjk": false,
"antislop-ui": false,
"antislop-copy": false
}
}
```
No options, an empty options object, or all styles off leaves a request unchanged.
## Request behavior
- **Anthropic and Chat Completions:** append one static style block to the existing system prompt, or create the protocol-appropriate system field when none exists.
- **Responses:** leave `instructions` completely untouched, including Codex's identity and base instructions. Add the style block as a separate `developer` input item.
- **An existing `[Output Strategy]` marker:** the body is already considered injected and is left unchanged; old blocks are never stripped or replaced. If an agent replays that marker in its history, the saved style remains part of that conversation; turning a style off does not rewrite history. Start a new conversation to begin without the old style block.
- **Cache stability:** a selected style injects consistently across turns. The former `autoClarity` and media-history bypasses are removed because they made the cached system prefix appear and disappear.
- **Unknown or unsupported shapes:** pass through unchanged. Middleware errors fail open.
This package has no Bun gateway hook, telemetry, prompt logging, or writes to the plugin installation folder. The panel reads and writes only `magpie.options` and follows `magpie.theme.lang`.
## Verification
```sh
bun test
node scripts/gen-page-catalog.mjs
```
`page/catalog.js` is generated from `catalog.js`. From the community repository, `output-strategy.test.mjs` runs the same `cases.json` through `../../scripts/middleware.mjs`.
## 中文摘要
7 种输出样式可以自由组合,全部默认关闭。启用后在请求发送前注入固定规则;Responses 不修改 Codex 的 `instructions`,而是另加 developer 输入项。已有 `[Output Strategy]` 标记的请求原样通过。为避免提示缓存失效,已移除 autoClarity 和媒体历史绕过;不再提供统计 hook,不保存请求或响应正文,也不写插件安装目录。页面跟随 Magpie 的语言设置。