output-strategy 0.2.2: panel attribution, conversation guidance and save-state fix (#831)
output-strategy 0.2.2. The panel says the plugin is unofficial and maintained by manjughosa (README, page, registry summary). The page tells the user that saving does not rewrite an existing conversation. Unsaved changes are now counted against the saved styles, so ticking a style and unticking it again leaves the panel clean. The README says the `[Output Strategy]` marker is honoured only in system/developer instructions.
The package.json author stays "manjughosa (https://github.com/manjughosa)", as main has it. From the previous reviewed head 8cb337ef to 6110057c, that line is the only change.
What was run at 6110057c, merged with origin/main 5fb28a1f: `bun test packages/output-strategy` (59 pass) and `bun scripts/check.mjs` (ok), on WSL Ubuntu 24.04 and on Windows 11, each with a fresh HOME (and USERPROFILE on Windows). Broken by hand: putting back `dirty = true` on every change turns three page save-flow tests red (56 pass, 3 fail).
Co-authored-by: manjughosa <manjughosa@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
# 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**.
|
||||
An (unofficial) output-style plugin for magpie, developed and maintained by manjughosa.
|
||||
|
||||
Seven composable output styles with a selection panel; **every style is off by default**.
|
||||
|
||||
本插件由 manjughosa 独立开发并维护,非官方出品。七种输出样式可以自由组合,全部默认关闭。
|
||||
|
||||
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/`.
|
||||
|
||||
@@ -38,7 +42,7 @@ No options, an empty options object, or all styles off leaves a request unchange
|
||||
|
||||
- **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.
|
||||
- **An existing `[Output Strategy]` marker in system/developer instructions:** the body is already considered injected and is left unchanged; old blocks are never stripped or replaced. Quoting the marker in user or assistant messages does not trigger this skip. If an agent replays that marker in system/developer instructions, 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.
|
||||
|
||||
@@ -55,4 +59,4 @@ node scripts/gen-page-catalog.mjs
|
||||
|
||||
## 中文摘要
|
||||
|
||||
7 种输出样式可以自由组合,全部默认关闭。启用后在请求发送前注入固定规则;Responses 不修改 Codex 的 `instructions`,而是另加 developer 输入项。已有 `[Output Strategy]` 标记的请求原样通过。为避免提示缓存失效,已移除 autoClarity 和媒体历史绕过;不再提供统计 hook,不保存请求或响应正文,也不写插件安装目录。页面跟随 Magpie 的语言设置。
|
||||
7 种输出样式可以自由组合,全部默认关闭。启用后在请求发送前注入固定规则;Responses 不修改 Codex 的 `instructions`,而是另加 developer 输入项。系统/开发者指令中已有 `[Output Strategy]` 标记的请求原样通过;用户或助手消息中引用标记不会触发跳过。切换或关闭样式不会改写已有会话历史,要完整应用新配置请新建会话。为避免提示缓存失效,已移除 autoClarity 和媒体历史绕过;不再提供统计 hook,不保存请求或响应正文,也不写插件安装目录。页面跟随 Magpie 的语言设置。
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/middleware-output-strategy",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"description": "Composable output-style instructions injected before the model call, with a small selection panel",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -95,8 +95,11 @@
|
||||
input.checked = checked[style.id] === true
|
||||
input.setAttribute("data-style-id", style.id)
|
||||
input.addEventListener("change", function () {
|
||||
dirty = true
|
||||
setMessage("Unsaved changes.")
|
||||
var savedStyles = options.styles && typeof options.styles === "object" ? options.styles : {}
|
||||
dirty = catalog.some(function (style) {
|
||||
return inputs[style.id].checked !== (savedStyles[style.id] === true)
|
||||
})
|
||||
setMessage(dirty ? "Unsaved changes." : "No unsaved changes.")
|
||||
updateSelection()
|
||||
updateControls()
|
||||
})
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
var ZH = {
|
||||
"Output Strategy": "输出策略",
|
||||
"Inject selected writing rules into model requests. Combine freely; all off by default.": "把选中的写作规则注入模型请求。可自由组合,全部默认关闭。",
|
||||
"An (unofficial) output-style plugin for magpie, developed and maintained by manjughosa.": "本插件由 manjughosa 独立开发并维护,非官方出品。",
|
||||
"Saving does not rewrite conversation history. Existing conversations may retain previously injected rules; start a new conversation to fully switch or turn off styles.": "保存不会改写会话历史。已有会话可能保留先前注入的规则;要完整切换或关闭样式,请新建会话。",
|
||||
"selected": "已选择",
|
||||
"Style combinations": "样式组合",
|
||||
"Reading catalog…": "正在读取目录…",
|
||||
@@ -15,6 +17,7 @@
|
||||
"Reading settings…": "正在读取设置…",
|
||||
"Pick styles and save.": "选择样式后保存。",
|
||||
"Unsaved changes.": "有未保存的更改。",
|
||||
"No unsaved changes.": "没有未保存的更改。",
|
||||
"Saved.": "已保存。",
|
||||
"Could not save. Nothing was written; try again.": "保存失败。更改尚未写入,请重试。",
|
||||
"Could not read settings; reopen the page.": "设置读取失败,请重新打开页面。",
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<div class="intro-copy">
|
||||
<h1>Output Strategy</h1>
|
||||
<p class="lede">Inject selected writing rules into model requests. Combine freely; all off by default.</p>
|
||||
<p class="attribution">An (unofficial) output-style plugin for magpie, developed and maintained by manjughosa.</p>
|
||||
</div>
|
||||
<p class="selection-count" aria-live="polite">
|
||||
<strong id="selectedCount">0 / 7</strong>
|
||||
@@ -25,6 +26,8 @@
|
||||
<p id="catalogState">Reading catalog…</p>
|
||||
</div>
|
||||
|
||||
<p class="form-message" id="conversationNote">Saving does not rewrite conversation history. Existing conversations may retain previously injected rules; start a new conversation to fully switch or turn off styles.</p>
|
||||
|
||||
<form id="stylesForm">
|
||||
<fieldset id="stylesFieldset" disabled>
|
||||
<legend class="sr-only">Choose output styles to inject</legend>
|
||||
|
||||
@@ -66,6 +66,14 @@ h1 {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.attribution {
|
||||
margin: 10px 0 0;
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#conversationNote { margin-bottom: 14px; }
|
||||
|
||||
.selection-count {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -103,7 +103,7 @@ async function boot({ catalog = sampleCatalog, current, lang = "en", failGet = f
|
||||
|
||||
describe("generated page catalog", () => {
|
||||
test("is current and exposes only style metadata", () => {
|
||||
const source = readFileSync(new URL("../page/catalog.js", import.meta.url), "utf8")
|
||||
const source = readFileSync(new URL("../page/catalog.js", import.meta.url), "utf8").replace(/\r\n/g, "\n")
|
||||
expect(source).toBe(renderPageCatalog())
|
||||
const sandbox = {}
|
||||
vm.createContext(sandbox)
|
||||
@@ -141,6 +141,52 @@ describe("page save flow", () => {
|
||||
expect(document.nodes.saveButton.disabled).toBe(true)
|
||||
})
|
||||
|
||||
test("clears dirty state when a disabled style is restored", async () => {
|
||||
const { document, writes } = await boot({ current: { styles: {} } })
|
||||
const inputs = descendants(document.nodes.stylesList).filter(node => node.tagName === "INPUT")
|
||||
inputs[0].checked = true
|
||||
inputs[0].dispatch("change")
|
||||
expect(document.nodes.saveButton.disabled).toBe(false)
|
||||
inputs[0].checked = false
|
||||
inputs[0].dispatch("change")
|
||||
expect(document.nodes.saveButton.disabled).toBe(true)
|
||||
expect(document.nodes.formMessage.textContent).toBe("No unsaved changes.")
|
||||
expect(writes).toHaveLength(0)
|
||||
})
|
||||
|
||||
test("clears dirty state when an enabled style is restored", async () => {
|
||||
const { document, writes } = await boot({ current: { styles: { "terse-prose": true } }, lang: "zh-CN" })
|
||||
const inputs = descendants(document.nodes.stylesList).filter(node => node.tagName === "INPUT")
|
||||
inputs[0].checked = false
|
||||
inputs[0].dispatch("change")
|
||||
expect(document.nodes.saveButton.disabled).toBe(false)
|
||||
inputs[0].checked = true
|
||||
inputs[0].dispatch("change")
|
||||
expect(document.nodes.saveButton.disabled).toBe(true)
|
||||
expect(document.nodes.formMessage.textContent).toBe("没有未保存的更改。")
|
||||
expect(writes).toHaveLength(0)
|
||||
})
|
||||
|
||||
test("stays dirty until every changed style is restored", async () => {
|
||||
const { document, setLang } = await boot({ current: { styles: {} } })
|
||||
let inputs = descendants(document.nodes.stylesList).filter(node => node.tagName === "INPUT")
|
||||
inputs[0].checked = true
|
||||
inputs[0].dispatch("change")
|
||||
inputs[1].checked = true
|
||||
inputs[1].dispatch("change")
|
||||
inputs[0].checked = false
|
||||
inputs[0].dispatch("change")
|
||||
expect(document.nodes.saveButton.disabled).toBe(false)
|
||||
expect(document.nodes.formMessage.textContent).toBe("Unsaved changes.")
|
||||
setLang("zh-CN")
|
||||
inputs = descendants(document.nodes.stylesList).filter(node => node.tagName === "INPUT")
|
||||
expect(inputs[1].checked).toBe(true)
|
||||
inputs[1].checked = false
|
||||
inputs[1].dispatch("change")
|
||||
expect(document.nodes.saveButton.disabled).toBe(true)
|
||||
expect(document.nodes.formMessage.textContent).toBe("没有未保存的更改。")
|
||||
})
|
||||
|
||||
test("renders without catalog and fails closed for editing", async () => {
|
||||
const { document, writes } = await boot({ catalog: null, current: { styles: {} }, failGet: true })
|
||||
expect(document.nodes.catalogState.textContent).toBe("Catalog not loaded")
|
||||
@@ -194,12 +240,12 @@ describe("host language", () => {
|
||||
})
|
||||
|
||||
test("closes each responsive media block and increments the shipping version", () => {
|
||||
const css = readFileSync(new URL("../page/style.css", import.meta.url), "utf8")
|
||||
const css = readFileSync(new URL("../page/style.css", import.meta.url), "utf8").replace(/\r\n/g, "\n")
|
||||
const opens = (css.match(/{/g) || []).length
|
||||
const closes = (css.match(/}/g) || []).length
|
||||
expect(closes).toBe(opens)
|
||||
expect(css).toContain("padding-top: 28px;\n }\n}\n\n@media (max-width: 460px)")
|
||||
expect(JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version).toBe("0.2.1")
|
||||
expect(JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version).toBe("0.2.2")
|
||||
})
|
||||
|
||||
test("falls back safely when host theme is missing", () => {
|
||||
@@ -209,6 +255,19 @@ describe("host language", () => {
|
||||
expect(sandbox.document.documentElement.lang).toBe("en")
|
||||
})
|
||||
|
||||
test("shows author attribution and conversation guidance in both languages", () => {
|
||||
const html = readFileSync(new URL("../page/index.html", import.meta.url), "utf8")
|
||||
const author = "An (unofficial) output-style plugin for magpie, developed and maintained by manjughosa."
|
||||
const note = "Saving does not rewrite conversation history. Existing conversations may retain previously injected rules; start a new conversation to fully switch or turn off styles."
|
||||
expect(html).toContain(author)
|
||||
expect(html).toContain(note)
|
||||
const sandbox = { document: { documentElement: {}, body: null }, magpie: { theme: { lang: "zh-CN" } } }
|
||||
vm.createContext(sandbox)
|
||||
vm.runInContext(i18nSource, sandbox)
|
||||
expect(sandbox.OutputStrategyI18n.t(author)).toBe("本插件由 manjughosa 独立开发并维护,非官方出品。")
|
||||
expect(sandbox.OutputStrategyI18n.t(note)).toBe("保存不会改写会话历史。已有会话可能保留先前注入的规则;要完整切换或关闭样式,请新建会话。")
|
||||
})
|
||||
|
||||
test("ships English HTML and no private stats or local language switch", () => {
|
||||
const html = readFileSync(new URL("../page/index.html", import.meta.url), "utf8")
|
||||
expect(html).toContain('<html lang="en">')
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@
|
||||
{ "package": "@magpie-community/middleware-system-prompt", "name": "System Prompt", "kind": "middleware", "community": true,
|
||||
"summary": { "en": "Add your own system prompt to every request, or only some agents' or models', in each API's own place.", "zh": "给每个请求(或指定 agent、模型)加上自己的系统提示词,放在各 API 自己的位置。" } },
|
||||
{ "package": "@magpie-community/middleware-output-strategy", "name": "Output Strategy", "kind": "middleware", "community": true,
|
||||
"summary": { "en": "Seven composable output styles, all off by default, with a selection panel and prompt-cache-stable injection that preserves Codex instructions. by manjughosa", "zh": "七种可组合的输出样式,全部默认关闭;带选择面板,注入不破坏提示缓存,也不改写 Codex instructions。由 manjughosa 维护。" } },
|
||||
"summary": { "en": "Seven composable output styles, all off by default, with a selection panel and prompt-cache-stable injection that preserves Codex instructions. Unofficial; by manjughosa.", "zh": "七种可组合的输出样式,全部默认关闭;带选择面板,注入不破坏提示缓存,也不改写 Codex instructions。由 manjughosa 独立开发并维护,非官方出品。" } },
|
||||
{ "package": "@magpie-community/middleware-word-guard", "name": "Word Guard", "kind": "middleware", "community": true,
|
||||
"summary": { "en": "New API's sensitive-word filter: turn away or mask words and patterns in what you send, and in replies.", "zh": "New API 的敏感词过滤:拒绝或替换你发出的内容和回复里的词与正则。" } },
|
||||
{ "package": "@magpie-community/middleware-think-tags", "name": "Think Tags", "kind": "middleware", "community": true,
|
||||
|
||||
Reference in New Issue
Block a user