Adds @magpie-community/middleware-output-strategy 0.2.0. It is middleware only. It appends composable output-style instructions before the model call, and has a small selection page. - Codex `instructions` stay byte-identical. The styles go into a `developer` input item at input[0]. - An existing marker means the body was already applied, and it passes unchanged, so the prompt cache holds across turns. - It writes nothing to disk and has no hooks or telemetry. - PROVENANCE credits OmniRoute v3.8.52. Run at 9b47678ba (mote, Bun 1.4.2, HOME=$(mktemp -d)): - package bun test: 49 pass, 0 fail; - repo bun test: 6555 pass, 0 fail; - scripts/check.mjs output-strategy: ok; - magpie's moejs engine at origin/main 8e350155b: the Claude Code system field is identical over four turns, and the Codex input prefix is stable; - 12 guards broken by hand, each one red. - PR CI (test, on-npm): green. Not tried: real accounts, Codex over websocket, Windows, Linux.
75 lines
3.6 KiB
JSON
75 lines
3.6 KiB
JSON
[
|
|
{
|
|
"name": "all styles off leaves the request unchanged",
|
|
"request": {
|
|
"model": "m",
|
|
"messages": [{ "role": "user", "content": "hello" }]
|
|
}
|
|
},
|
|
{
|
|
"name": "an existing marker is left unchanged",
|
|
"options": { "styles": { "ponytail": true } },
|
|
"request": {
|
|
"model": "m",
|
|
"messages": [{ "role": "system", "content": "[Output Strategy]\nexisting" }]
|
|
}
|
|
},
|
|
{
|
|
"name": "Anthropic keeps existing blocks and appends exactly one static block",
|
|
"options": { "styles": { "terse-cjk": true } },
|
|
"request": {
|
|
"model": "m",
|
|
"system": [{ "type": "text", "text": "Original rules", "cache_control": { "type": "ephemeral" } }],
|
|
"messages": [{ "role": "user", "content": "Delete the obsolete file" }]
|
|
},
|
|
"expect_request": {
|
|
"model": "m",
|
|
"system": [
|
|
{ "type": "text", "text": "Original rules", "cache_control": { "type": "ephemeral" } },
|
|
{ "type": "text", "text": "[Output Strategy]\n以文言简体回答,惜字如金,去赘语虚词。代码、路径、命令、错误、URL、标识符照原样保留,不得改写。\n\nCode blocks, file paths, commands, errors, URLs: keep exact. Security warnings, irreversible action confirmations, multi-step ordered sequences: write normal. Resume terse style after. Active every response until user asks for normal mode." }
|
|
],
|
|
"messages": [{ "role": "user", "content": "Delete the obsolete file" }]
|
|
}
|
|
},
|
|
{
|
|
"name": "Responses preserves instructions and inserts a developer input",
|
|
"ctx": { "protocol": "responses" },
|
|
"options": { "styles": { "terse-cjk": true } },
|
|
"request": {
|
|
"model": "gpt-5",
|
|
"instructions": "You are Codex. Preserve these base instructions.",
|
|
"input": [{ "role": "user", "content": [{ "type": "input_text", "text": "Fix it" }] }]
|
|
},
|
|
"expect_request": {
|
|
"model": "gpt-5",
|
|
"instructions": "You are Codex. Preserve these base instructions.",
|
|
"input": [
|
|
{ "role": "developer", "content": [{ "type": "input_text", "text": "[Output Strategy]\n以文言简体回答,惜字如金,去赘语虚词。代码、路径、命令、错误、URL、标识符照原样保留,不得改写。\n\nCode blocks, file paths, commands, errors, URLs: keep exact. Security warnings, irreversible action confirmations, multi-step ordered sequences: write normal. Resume terse style after. Active every response until user asks for normal mode." }] },
|
|
{ "role": "user", "content": [{ "type": "input_text", "text": "Fix it" }] }
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"name": "historical media does not suppress a selected style",
|
|
"options": { "styles": { "terse-cjk": true } },
|
|
"request": {
|
|
"model": "m",
|
|
"messages": [{ "role": "user", "content": [{ "type": "image", "source": { "data": "AA==" } }] }]
|
|
},
|
|
"expect_request": {
|
|
"model": "m",
|
|
"system": "[Output Strategy]\n以文言简体回答,惜字如金,去赘语虚词。代码、路径、命令、错误、URL、标识符照原样保留,不得改写。\n\nCode blocks, file paths, commands, errors, URLs: keep exact. Security warnings, irreversible action confirmations, multi-step ordered sequences: write normal. Resume terse style after. Active every response until user asks for normal mode.",
|
|
"messages": [{ "role": "user", "content": [{ "type": "image", "source": { "data": "AA==" } }] }]
|
|
}
|
|
},
|
|
{
|
|
"name": "an unsupported Gemini body passes through",
|
|
"ctx": { "protocol": "gemini" },
|
|
"options": { "styles": { "ponytail": true } },
|
|
"request": {
|
|
"model": "m",
|
|
"contents": [{ "role": "user", "parts": [{ "text": "hello" }] }]
|
|
}
|
|
}
|
|
]
|