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.
31 lines
1007 B
JavaScript
31 lines
1007 B
JavaScript
import { writeFileSync } from "node:fs"
|
|
import { fileURLToPath } from "node:url"
|
|
import { resolve } from "node:path"
|
|
import { STYLES } from "../catalog.js"
|
|
|
|
const output = fileURLToPath(new URL("../page/catalog.js", import.meta.url))
|
|
|
|
export function renderPageCatalog() {
|
|
if (!Array.isArray(STYLES) || STYLES.length !== 7) {
|
|
throw new Error("catalog.js must export exactly seven STYLES")
|
|
}
|
|
const ids = new Set()
|
|
const styles = STYLES.map(style => {
|
|
if (!style || typeof style.id !== "string" || !style.id || ids.has(style.id)) {
|
|
throw new Error("Each page style must have a unique id")
|
|
}
|
|
ids.add(style.id)
|
|
return {
|
|
id: style.id,
|
|
label: style.label,
|
|
description: style.description,
|
|
}
|
|
})
|
|
return `globalThis.OUTPUT_STRATEGY_CATALOG = ${JSON.stringify(styles, null, 2)}\n`
|
|
}
|
|
|
|
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
writeFileSync(output, renderPageCatalog(), "utf8")
|
|
console.log(`wrote ${output}`)
|
|
}
|