dsh-output-styles 0.4.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.es.md +9 -5
- package/README.hi.md +9 -5
- package/README.md +10 -5
- package/README.pt.md +9 -5
- package/README.zh.md +9 -5
- package/cordis.patch.yml +5 -0
- package/docs/COEXISTENCE.md +62 -0
- package/docs/renderer-protocol.md +10 -0
- package/docs/renderer-protocol.zh.md +8 -0
- package/lib/index.js +186 -38
- package/lib/types/coexist.d.ts +49 -0
- package/lib/types/coexist.d.ts.map +1 -0
- package/lib/types/config.d.ts +9 -0
- package/lib/types/config.d.ts.map +1 -1
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/runtime.d.ts +47 -1
- package/lib/types/runtime.d.ts.map +1 -1
- package/package.json +11 -1
- package/src/coexist.ts +68 -0
- package/src/config.ts +11 -0
- package/src/index.ts +2 -0
- package/src/runtime.ts +198 -43
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,36 @@ All notable changes to this project are documented in this file. The format
|
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the
|
|
5
5
|
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.6.0] - 2026-08-26
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- 与核心 outputStyles 共存/降级策略:探测 + 免重复注入 + 可运行检测。
|
|
12
|
+
|
|
13
|
+
## [0.5.0] - 2026-08-23
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **`/export --save <path>`**: the export command now writes the rendered
|
|
18
|
+
document to a workspace path, gated by the user-approval service and the fs
|
|
19
|
+
service. `/export [md|markdown|html] [--renderer=<id>] [--save <path>]` — the
|
|
20
|
+
no-argument behavior is unchanged (the document is returned as output text);
|
|
21
|
+
`--save` writes only after `ctx.get('approval')` grants `allowed-once`
|
|
22
|
+
(fail-closed when the service is absent, rejects, cancels, or throws), uses
|
|
23
|
+
`ctx.get('fs')` for the actual write (fail-loud with a structured error when
|
|
24
|
+
absent), and passes the document through `sanitizeText` before writing.
|
|
25
|
+
`md` is accepted as a Markdown alias. `@deepseek-ai/dsh-fs` and
|
|
26
|
+
`@deepseek-ai/dsh-user-approval` are declared as optional peer dependencies.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- **Standards alignment**: `package.json` declares `packageManager` (`pnpm@11.7.0`,
|
|
31
|
+
matching CI and the lockfile), and the `cordis.patch.yml` reference comment
|
|
32
|
+
now lists the two renderer-protocol config keys (`rules`, `enableExport`)
|
|
33
|
+
added in 0.4.0. No runtime behavior changes.
|
|
34
|
+
- Five READMEs: `/export --save` reference, the `fs:write` workshop permission,
|
|
35
|
+
and the test count refreshed to 127.
|
|
36
|
+
|
|
7
37
|
## [0.4.3] - 2026-08-22
|
|
8
38
|
|
|
9
39
|
### Changed
|
package/README.es.md
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
- **Paridad Claude Code** — `keep-coding-instructions`, `force-for-plugin` (alias `force`), compatibilidad JSON `outputStyles`, directorios `stylesDir` por capas, recarga en caliente y fallback del proyecto sobre la costura de settings de DSH.
|
|
41
41
|
- **Registro de renderers (`output.render.*`)** — `ctx.outputRenderers` permite a cualquier plugin registrar un presenter puro, aplicado a través de la cascada `output.render/before`; renderers integrados `concise` y `step-by-step`.
|
|
42
42
|
- **Reglas por sesión/por herramienta** — `rules: [{ match: { tool: 'bash' }, style: 'concise' }]` nombran el renderer para solicitudes coincidentes; editables mediante la sección de settings `output-style-rules`.
|
|
43
|
-
- **`/export`** — renderiza la sesión actual a Markdown o HTML saneado a través de la tubería de render;
|
|
43
|
+
- **`/export`** — renderiza la sesión actual a Markdown o HTML saneado a través de la tubería de render; `--save <path>` escribe el documento saneado en esa ruta de workspace tras la aprobación del usuario. Cada render conserva el texto original junto al renderizado.
|
|
44
44
|
|
|
45
45
|
## Quick start
|
|
46
46
|
|
|
@@ -111,14 +111,15 @@ Todos los parámetros son campos Schemastery `Config` (modificables desde cordis
|
|
|
111
111
|
| `includeBuiltins` | `true` | Incluir los `styles/` del paquete como capa de menor prioridad |
|
|
112
112
|
| `watchStyles` | `true` | Recargar la librería cuando un archivo de estilo cambia en disco |
|
|
113
113
|
| `rules` | `[]` | Reglas de render por sesión/herramienta: `[{ match: { tool?, contentType?, session? }, style, priority? }]` |
|
|
114
|
-
| `enableExport` | `true` | Registrar el comando `/export` (exportación de sesión Markdown/HTML, consciente del renderer) |
|
|
114
|
+
| `enableExport` | `true` | Registrar el comando `/export` (exportación de sesión Markdown/HTML, consciente del renderer; `--save` escribe con aprobación) |
|
|
115
|
+
| `respectCoreOutputStyles` | `true` | Al detectar un servicio core `outputStyles`, omitir la inyección de prompt de este plugin (mantener hot-switch / rules / export) |
|
|
115
116
|
|
|
116
117
|
## Tools & surfaces
|
|
117
118
|
|
|
118
119
|
| Surface | Kind | Notes |
|
|
119
120
|
|---|---|---|
|
|
120
121
|
| `/style` | command | Lista estilos, cambia o restaura el valor por defecto del proyecto |
|
|
121
|
-
| `/export` | command | Renderiza la sesión actual a Markdown o HTML saneado |
|
|
122
|
+
| `/export` | command | Renderiza la sesión actual a Markdown o HTML saneado; `--save` escribe con aprobación |
|
|
122
123
|
| `output_style` | storage domain | Elección de estilo por sesión, indexada por sessionId |
|
|
123
124
|
| `systemPrompt.section()` | contribution | Inyecta el cuerpo del estilo actual en cada ensamblado |
|
|
124
125
|
| `output.render.*` | renderer registry | `ctx.outputRenderers` + la cascada `output.render/before` |
|
|
@@ -135,8 +136,10 @@ Todos los parámetros son campos Schemastery `Config` (modificables desde cordis
|
|
|
135
136
|
| `/style off` | Restaura el valor por defecto del proyecto (default de settings, luego `defaultStyle`) |
|
|
136
137
|
| `/style nope` | `error: unknown output style "nope" (available: …)` |
|
|
137
138
|
| `/export` | Renderiza la sesión actual a Markdown a través de la pipeline de render |
|
|
139
|
+
| `/export md` | Renderiza a Markdown (`md` es la forma abreviada de `markdown`) |
|
|
138
140
|
| `/export html` | Renderiza a HTML saneado |
|
|
139
141
|
| `/export --renderer=concise` | Renderiza forzando un renderer (reglas omitidas) |
|
|
142
|
+
| `/export md --save report.md` | Renderiza y luego escribe el documento saneado en `report.md` tras la aprobación |
|
|
140
143
|
|
|
141
144
|
## Style library
|
|
142
145
|
|
|
@@ -182,7 +185,7 @@ Filtrado contra el ecosistema DSH antes del desarrollo (instantánea 2026-08): n
|
|
|
182
185
|
|
|
183
186
|
## Permissions & data
|
|
184
187
|
|
|
185
|
-
- **Permissions**: el manifiesto de workshop declara `fs:read`, `fs:watch`, `storage:read`, `storage:write` y `settings:read`.
|
|
188
|
+
- **Permissions**: el manifiesto de workshop declara `fs:read`, `fs:write`, `fs:watch`, `storage:read`, `storage:write` y `settings:read`.
|
|
186
189
|
- **Data**: la elección de estilo vive en el dominio de almacenamiento `output_style` (indexada por sessionId); no se persiste otro estado, sin solicitudes de red.
|
|
187
190
|
- **Session log**: el nombre del estilo viene de `command/run`, el texto exacto inyectado de `request/header`; el marcador de procedencia `{ kind: 'plugin', plugin: 'dsh-output-styles' }` viaja en el registro del dominio.
|
|
188
191
|
|
|
@@ -191,6 +194,7 @@ Filtrado contra el ecosistema DSH antes del desarrollo (instantánea 2026-08): n
|
|
|
191
194
|
- **Solo servicios públicos.** Contribuye `systemPrompt`, comandos, almacenamiento y settings; sin cambios en engine / agent-loop / apiproxy / UI oficial.
|
|
192
195
|
- **Visible para el modelo ⟺ registrado.** Todo lo que el modelo ve es reconstruible desde el registro de sesión — sin un nuevo tipo de evento de sesión, sin cambios en el agent-loop.
|
|
193
196
|
- **Original siempre conservado.** Cada render (y `/export`) conserva el texto original junto al renderizado; para la exportación HTML se usa HTML saneado.
|
|
197
|
+
- **Escrituras en disco controladas.** `/export --save` escribe solo después de que el servicio de aprobación lo conceda, y el contenido escrito pasa primero por la función pura `sanitizeText`; sin un servicio de aprobación o fs no escribe nada (fail-closed).
|
|
194
198
|
|
|
195
199
|
## Known limitations
|
|
196
200
|
|
|
@@ -203,7 +207,7 @@ Filtrado contra el ecosistema DSH antes del desarrollo (instantánea 2026-08): n
|
|
|
203
207
|
```sh
|
|
204
208
|
pnpm install
|
|
205
209
|
pnpm run typecheck # ambos proyectos tsc
|
|
206
|
-
pnpm test # vitest —
|
|
210
|
+
pnpm test # vitest — 127 tests
|
|
207
211
|
pnpm run verify # typecheck + tests + self-contained (la puerta de prepublishOnly)
|
|
208
212
|
pnpm run build # artefactos lib/ (bundles host + client)
|
|
209
213
|
pnpm pack # tarball para dsh plugin add
|
package/README.hi.md
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
- **Claude Code समानता** — `keep-coding-instructions`, `force-for-plugin` (उपनाम `force`), `outputStyles` JSON संगतता, स्तरित `stylesDir` निर्देशिकाएँ, हॉट रीलोड और DSH settings सीम पर परियोजना-डिफ़ॉल्ट फ़ॉलबैक।
|
|
41
41
|
- **रेंडरर रजिस्ट्री (`output.render.*`)** — `ctx.outputRenderers` किसी भी प्लगइन को एक शुद्ध presenter पंजीकृत करने देता है, जो `output.render/before` वॉटरफ़ॉल से लागू होता है; अंतर्निहित रेंडरर `concise` और `step-by-step`।
|
|
42
42
|
- **प्रति-सत्र/प्रति-टूल नियम** — `rules: [{ match: { tool: 'bash' }, style: 'concise' }]` मिलान वाले अनुरोधों के लिए रेंडरर नामित करते हैं; `output-style-rules` settings अनुभाग से संपादन-योग्य।
|
|
43
|
-
- **`/export`** — रेंडर पाइपलाइन से वर्तमान सत्र को Markdown या सैनिटाइज़्ड HTML में प्रस्तुत करता है; हर रेंडर मूल पाठ को रेंडर किए गए के साथ रखता है।
|
|
43
|
+
- **`/export`** — रेंडर पाइपलाइन से वर्तमान सत्र को Markdown या सैनिटाइज़्ड HTML में प्रस्तुत करता है; `--save <path>` उपयोगकर्ता की स्वीकृति के बाद सैनिटाइज़्ड दस्तावेज़ को उस workspace पथ पर लिखता है। हर रेंडर मूल पाठ को रेंडर किए गए के साथ रखता है।
|
|
44
44
|
|
|
45
45
|
## Quick start
|
|
46
46
|
|
|
@@ -111,14 +111,15 @@ flowchart LR
|
|
|
111
111
|
| `includeBuiltins` | `true` | पैकेज के अंतर्निहित `styles/` को निम्नतम-प्राथमिकता परत के रूप में शामिल करें |
|
|
112
112
|
| `watchStyles` | `true` | डिस्क पर शैली फ़ाइल बदलने पर पुस्तकालय फिर से लोड करें |
|
|
113
113
|
| `rules` | `[]` | प्रति-सत्र/प्रति-टूल रेंडर नियम: `[{ match: { tool?, contentType?, session? }, style, priority? }]` |
|
|
114
|
-
| `enableExport` | `true` | `/export` कमांड पंजीकृत करें (Markdown/HTML सत्र निर्यात,
|
|
114
|
+
| `enableExport` | `true` | `/export` कमांड पंजीकृत करें (Markdown/HTML सत्र निर्यात, रेंडरर-जागरूक; `--save` स्वीकृति से लिखता है) |
|
|
115
|
+
| `respectCoreOutputStyles` | `true` | कोर `outputStyles` सेवा का पता चलने पर इस प्लगइन का prompt इंजेक्शन छोड़ें (hot-switch / rules / export बनाए रखें) |
|
|
115
116
|
|
|
116
117
|
## Tools & surfaces
|
|
117
118
|
|
|
118
119
|
| Surface | Kind | Notes |
|
|
119
120
|
|---|---|---|
|
|
120
121
|
| `/style` | command | शैलियाँ सूचीबद्ध करें, बदलें या परियोजना डिफ़ॉल्ट बहाल करें |
|
|
121
|
-
| `/export` | command | वर्तमान सत्र को Markdown या सैनिटाइज़्ड HTML में प्रस्तुत
|
|
122
|
+
| `/export` | command | वर्तमान सत्र को Markdown या सैनिटाइज़्ड HTML में प्रस्तुत करें; `--save` स्वीकृति से लिखता है |
|
|
122
123
|
| `output_style` | storage domain | sessionId से अनुक्रमित सत्र-स्कोप्ड शैली चयन |
|
|
123
124
|
| `systemPrompt.section()` | contribution | हर संयोजन पर वर्तमान शैली का मुख्य भाग इंजेक्ट करता है |
|
|
124
125
|
| `output.render.*` | renderer registry | `ctx.outputRenderers` + `output.render/before` वॉटरफ़ॉल |
|
|
@@ -135,8 +136,10 @@ flowchart LR
|
|
|
135
136
|
| `/style off` | परियोजना डिफ़ॉल्ट बहाल करें (settings डिफ़ॉल्ट, फिर `defaultStyle`) |
|
|
136
137
|
| `/style nope` | `error: unknown output style "nope" (available: …)` |
|
|
137
138
|
| `/export` | रेंडर पाइपलाइन से वर्तमान सत्र को Markdown में प्रस्तुत करें |
|
|
139
|
+
| `/export md` | Markdown में प्रस्तुत करें (`md`, `markdown` का संक्षिप्त रूप है) |
|
|
138
140
|
| `/export html` | सैनिटाइज़्ड HTML में प्रस्तुत करें |
|
|
139
141
|
| `/export --renderer=concise` | एक रेंडरर बाध्य करके प्रस्तुत करें (नियम छोड़े गए) |
|
|
142
|
+
| `/export md --save report.md` | प्रस्तुत करें, फिर स्वीकृति के बाद सैनिटाइज़्ड दस्तावेज़ को `report.md` में लिखें |
|
|
140
143
|
|
|
141
144
|
## Style library
|
|
142
145
|
|
|
@@ -182,7 +185,7 @@ flowchart LR
|
|
|
182
185
|
|
|
183
186
|
## Permissions & data
|
|
184
187
|
|
|
185
|
-
- **Permissions**: workshop मैनिफ़ेस्ट `fs:read`, `fs:watch`, `storage:read`, `storage:write` और `settings:read` घोषित करता है।
|
|
188
|
+
- **Permissions**: workshop मैनिफ़ेस्ट `fs:read`, `fs:write`, `fs:watch`, `storage:read`, `storage:write` और `settings:read` घोषित करता है।
|
|
186
189
|
- **Data**: शैली चयन `output_style` स्टोरेज डोमेन में रहता है (sessionId से अनुक्रमित); कोई अन्य स्थिति स्थायी नहीं, कोई नेटवर्क अनुरोध नहीं।
|
|
187
190
|
- **Session log**: शैली नाम `command/run` से आता है, सटीक इंजेक्ट किया गया पाठ `request/header` से; स्रोत मार्कर `{ kind: 'plugin', plugin: 'dsh-output-styles' }` डोमेन रिकॉर्ड में चलता है।
|
|
188
191
|
|
|
@@ -191,6 +194,7 @@ flowchart LR
|
|
|
191
194
|
- **केवल सार्वजनिक सेवाएँ।** `systemPrompt`, कमांड, स्टोरेज और settings योगदान करता है; engine / agent-loop / apiproxy / आधिकारिक UI में कोई बदलाव नहीं।
|
|
192
195
|
- **मॉडल-दृश्य ⟺ लॉग किया गया।** मॉडल जो देखता है वह सब सत्र लॉग से पुनर्निर्माण-योग्य है — कोई नया सत्र घटना प्रकार नहीं, कोई agent-loop बदलाव नहीं।
|
|
193
196
|
- **मूल हमेशा रखा गया।** हर रेंडर (और `/export`) मूल पाठ को रेंडर किए गए के साथ रखता है; HTML निर्यात के लिए सैनिटाइज़्ड HTML उपयोग होता है।
|
|
197
|
+
- **डिस्क लेखन गेटेड।** `/export --save` केवल स्वीकृति सेवा की अनुमति के बाद लिखता है, और लिखा गया कंटेंट पहले `sanitizeText` शुद्ध फ़ंक्शन से गुज़रता है; स्वीकृति या fs सेवा के बिना कुछ भी नहीं लिखा जाता (fail-closed)।
|
|
194
198
|
|
|
195
199
|
## Known limitations
|
|
196
200
|
|
|
@@ -203,7 +207,7 @@ flowchart LR
|
|
|
203
207
|
```sh
|
|
204
208
|
pnpm install
|
|
205
209
|
pnpm run typecheck # दोनों tsc परियोजनाएँ
|
|
206
|
-
pnpm test # vitest —
|
|
210
|
+
pnpm test # vitest — 127 tests
|
|
207
211
|
pnpm run verify # typecheck + tests + self-contained (prepublishOnly द्वार)
|
|
208
212
|
pnpm run build # lib/ कलाकृतियाँ (host + client बंडल)
|
|
209
213
|
pnpm pack # dsh plugin add के लिए tarball
|
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
- **Claude Code parity** — `keep-coding-instructions`, `force-for-plugin` (`force` alias), `outputStyles` JSON compatibility, layered `stylesDir` directories, hot reload, and project-default fallback over the DSH settings seam.
|
|
42
42
|
- **Renderer registry (`output.render.*`)** — `ctx.outputRenderers` lets any plugin register a pure presenter, applied through the `output.render/before` waterfall; built-in renderers `concise` and `step-by-step`.
|
|
43
43
|
- **Per-session/per-tool rules** — `rules: [{ match: { tool: 'bash' }, style: 'concise' }]` name the renderer for matching requests; editable through the `output-style-rules` settings section.
|
|
44
|
-
- **`/export`** — render the current session to Markdown or sanitized HTML through the render pipeline;
|
|
44
|
+
- **`/export`** — render the current session to Markdown or sanitized HTML through the render pipeline; `--save <path>` writes the sanitized document to that workspace path after user approval. Every render keeps the original text beside the rendered one.
|
|
45
45
|
|
|
46
46
|
## Quick start
|
|
47
47
|
|
|
@@ -112,14 +112,15 @@ All tunables are Schemastery `Config` fields (changeable from cordis.yml). Inval
|
|
|
112
112
|
| `includeBuiltins` | `true` | Include the package's bundled `styles/` as the lowest-priority layer |
|
|
113
113
|
| `watchStyles` | `true` | Reload the library when a style file changes on disk |
|
|
114
114
|
| `rules` | `[]` | Per-session/per-tool render rules: `[{ match: { tool?, contentType?, session? }, style, priority? }]` |
|
|
115
|
-
| `enableExport` | `true` | Register the `/export` command (Markdown/HTML session export, renderer-aware) |
|
|
115
|
+
| `enableExport` | `true` | Register the `/export` command (Markdown/HTML session export, renderer-aware; `--save` writes with approval) |
|
|
116
|
+
| `respectCoreOutputStyles` | `true` | When a core `outputStyles` service is detected, skip this plugin's prompt injection (keep hot-switch / rules / export) |
|
|
116
117
|
|
|
117
118
|
## Tools & surfaces
|
|
118
119
|
|
|
119
120
|
| Surface | Kind | Notes |
|
|
120
121
|
|---|---|---|
|
|
121
122
|
| `/style` | command | List styles, switch, or restore the project default |
|
|
122
|
-
| `/export` | command | Render the current session to Markdown or sanitized HTML |
|
|
123
|
+
| `/export` | command | Render the current session to Markdown or sanitized HTML; `--save` writes with approval |
|
|
123
124
|
| `output_style` | storage domain | Session-scoped style choice, keyed by sessionId |
|
|
124
125
|
| `systemPrompt.section()` | contribution | Injects the current style body at every assembly |
|
|
125
126
|
| `output.render.*` | renderer registry | `ctx.outputRenderers` + the `output.render/before` waterfall |
|
|
@@ -136,8 +137,10 @@ All tunables are Schemastery `Config` fields (changeable from cordis.yml). Inval
|
|
|
136
137
|
| `/style off` | Restore the project default (settings default, then `defaultStyle`) |
|
|
137
138
|
| `/style nope` | `error: unknown output style "nope" (available: …)` |
|
|
138
139
|
| `/export` | Render the current session to Markdown through the renderer pipeline |
|
|
140
|
+
| `/export md` | Render to Markdown (`md` is the shorthand for `markdown`) |
|
|
139
141
|
| `/export html` | Render to sanitized HTML |
|
|
140
142
|
| `/export --renderer=concise` | Render with one renderer forced (rules bypassed) |
|
|
143
|
+
| `/export md --save report.md` | Render, then write the sanitized document to `report.md` after approval |
|
|
141
144
|
|
|
142
145
|
## Style library
|
|
143
146
|
|
|
@@ -183,7 +186,7 @@ Screened against the DSH ecosystem before development (2026-08 snapshot): no `st
|
|
|
183
186
|
|
|
184
187
|
## Permissions & data
|
|
185
188
|
|
|
186
|
-
- **Permissions**: declares `fs:read`, `fs:watch`, `storage:read`, `storage:write`, and `settings:read` in its workshop manifest.
|
|
189
|
+
- **Permissions**: declares `fs:read`, `fs:write`, `fs:watch`, `storage:read`, `storage:write`, and `settings:read` in its workshop manifest.
|
|
187
190
|
- **Data**: the style choice lives in the `output_style` storage domain (keyed by sessionId); no other state is persisted, no network requests.
|
|
188
191
|
- **Session log**: the style name comes from `command/run`, the exact injected text from `request/header`; the provenance marker `{ kind: 'plugin', plugin: 'dsh-output-styles' }` rides in the domain record.
|
|
189
192
|
|
|
@@ -192,9 +195,11 @@ Screened against the DSH ecosystem before development (2026-08 snapshot): no `st
|
|
|
192
195
|
- **Public services only.** Contributes `systemPrompt`, commands, storage, and settings; no engine / agent-loop / apiproxy / official-UI changes.
|
|
193
196
|
- **Model-visible ⟺ logged.** Everything the model sees is reconstructable from the session log — no new session event type, no agent-loop changes.
|
|
194
197
|
- **Original always kept.** Every render (and `/export`) keeps the original text beside the rendered one; sanitized HTML is used for HTML export.
|
|
198
|
+
- **Disk writes gated.** `/export --save` writes only after the approval service grants it, and the written content passes through the `sanitizeText` pure function first; without an approval or fs service it writes nothing (fail-closed).
|
|
195
199
|
|
|
196
200
|
## Known limitations
|
|
197
201
|
|
|
202
|
+
- **Core coexistence.** If a first-party `outputStyles` capability lands, this plugin detects its `outputStyles` service and degrades to the incremental surface (hot-switch, rules, `/export`) while leaving prompt injection to the core — see [`docs/COEXISTENCE.md`](docs/COEXISTENCE.md) and the exported `detectCoreOutputStyles` / `coexistenceReport` functions.
|
|
198
203
|
- **Main conversation only.** Styles apply to the main conversation; subagent sessions keep their own prompts (matching Claude Code).
|
|
199
204
|
- **Truncation.** Style bodies longer than `maxStyleChars` are truncated with a marker.
|
|
200
205
|
- **Skipped style files.** A bad style file is skipped with a warning and never breaks the profile.
|
|
@@ -204,7 +209,7 @@ Screened against the DSH ecosystem before development (2026-08 snapshot): no `st
|
|
|
204
209
|
```sh
|
|
205
210
|
pnpm install
|
|
206
211
|
pnpm run typecheck # both tsc projects
|
|
207
|
-
pnpm test # vitest —
|
|
212
|
+
pnpm test # vitest — 127 tests
|
|
208
213
|
pnpm run verify # typecheck + tests + self-contained (the prepublishOnly gate)
|
|
209
214
|
pnpm run build # lib/ artifacts (host + client bundles)
|
|
210
215
|
pnpm pack # tarball for dsh plugin add
|
package/README.pt.md
CHANGED
|
@@ -40,7 +40,7 @@ O `dsh-output-styles` é o equivalente do `outputStyles` do Claude Code para o D
|
|
|
40
40
|
- **Paridade Claude Code** — `keep-coding-instructions`, `force-for-plugin` (alias `force`), compatibilidade JSON `outputStyles`, diretórios `stylesDir` em camadas, recarga a quente e fallback do projeto sobre a costura de settings do DSH.
|
|
41
41
|
- **Registro de renderers (`output.render.*`)** — `ctx.outputRenderers` permite a qualquer plugin registrar um presenter puro, aplicado pela cascata `output.render/before`; renderers integrados `concise` e `step-by-step`.
|
|
42
42
|
- **Regras por sessão/por ferramenta** — `rules: [{ match: { tool: 'bash' }, style: 'concise' }]` nomeiam o renderer para solicitações coincidentes; editáveis pela seção de settings `output-style-rules`.
|
|
43
|
-
- **`/export`** — renderiza a sessão atual para Markdown ou HTML saneado pela pipeline de render;
|
|
43
|
+
- **`/export`** — renderiza a sessão atual para Markdown ou HTML saneado pela pipeline de render; `--save <path>` escreve o documento saneado nessa rota de workspace após aprovação do usuário. Cada render mantém o texto original ao lado do renderizado.
|
|
44
44
|
|
|
45
45
|
## Quick start
|
|
46
46
|
|
|
@@ -111,14 +111,15 @@ Todos os parâmetros são campos Schemastery `Config` (alteráveis pelo cordis.y
|
|
|
111
111
|
| `includeBuiltins` | `true` | Incluir os `styles/` do pacote como camada de menor prioridade |
|
|
112
112
|
| `watchStyles` | `true` | Recarregar a biblioteca quando um arquivo de estilo muda em disco |
|
|
113
113
|
| `rules` | `[]` | Regras de render por sessão/ferramenta: `[{ match: { tool?, contentType?, session? }, style, priority? }]` |
|
|
114
|
-
| `enableExport` | `true` | Registrar o comando `/export` (exportação de sessão Markdown/HTML, ciente do renderer) |
|
|
114
|
+
| `enableExport` | `true` | Registrar o comando `/export` (exportação de sessão Markdown/HTML, ciente do renderer; `--save` escreve com aprovação) |
|
|
115
|
+
| `respectCoreOutputStyles` | `true` | Ao detectar um serviço core `outputStyles`, omitir a injeção de prompt deste plugin (manter hot-switch / rules / export) |
|
|
115
116
|
|
|
116
117
|
## Tools & surfaces
|
|
117
118
|
|
|
118
119
|
| Surface | Kind | Notes |
|
|
119
120
|
|---|---|---|
|
|
120
121
|
| `/style` | command | Lista estilos, alterna ou restaura o padrão do projeto |
|
|
121
|
-
| `/export` | command | Renderiza a sessão atual para Markdown ou HTML saneado |
|
|
122
|
+
| `/export` | command | Renderiza a sessão atual para Markdown ou HTML saneado; `--save` escreve com aprovação |
|
|
122
123
|
| `output_style` | storage domain | Escolha de estilo por sessão, indexada por sessionId |
|
|
123
124
|
| `systemPrompt.section()` | contribution | Injeta o corpo do estilo atual a cada montagem |
|
|
124
125
|
| `output.render.*` | renderer registry | `ctx.outputRenderers` + a cascata `output.render/before` |
|
|
@@ -135,8 +136,10 @@ Todos os parâmetros são campos Schemastery `Config` (alteráveis pelo cordis.y
|
|
|
135
136
|
| `/style off` | Restaura o padrão do projeto (default de settings, depois `defaultStyle`) |
|
|
136
137
|
| `/style nope` | `error: unknown output style "nope" (available: …)` |
|
|
137
138
|
| `/export` | Renderiza a sessão atual para Markdown pela pipeline de render |
|
|
139
|
+
| `/export md` | Renderiza para Markdown (`md` é a forma abreviada de `markdown`) |
|
|
138
140
|
| `/export html` | Renderiza para HTML saneado |
|
|
139
141
|
| `/export --renderer=concise` | Renderiza forçando um renderer (regras ignoradas) |
|
|
142
|
+
| `/export md --save report.md` | Renderiza e então escreve o documento saneado em `report.md` após aprovação |
|
|
140
143
|
|
|
141
144
|
## Style library
|
|
142
145
|
|
|
@@ -182,7 +185,7 @@ Filtrado contra o ecossistema DSH antes do desenvolvimento (instantânea 2026-08
|
|
|
182
185
|
|
|
183
186
|
## Permissions & data
|
|
184
187
|
|
|
185
|
-
- **Permissions**: o manifesto de workshop declara `fs:read`, `fs:watch`, `storage:read`, `storage:write` e `settings:read`.
|
|
188
|
+
- **Permissions**: o manifesto de workshop declara `fs:read`, `fs:write`, `fs:watch`, `storage:read`, `storage:write` e `settings:read`.
|
|
186
189
|
- **Data**: a escolha de estilo vive no domínio de armazenamento `output_style` (indexada por sessionId); nenhum outro estado é persistido, sem solicitações de rede.
|
|
187
190
|
- **Session log**: o nome do estilo vem de `command/run`, o texto exato injetado de `request/header`; o marcador de procedência `{ kind: 'plugin', plugin: 'dsh-output-styles' }` viaja no registro do domínio.
|
|
188
191
|
|
|
@@ -191,6 +194,7 @@ Filtrado contra o ecossistema DSH antes do desenvolvimento (instantânea 2026-08
|
|
|
191
194
|
- **Somente serviços públicos.** Contribui `systemPrompt`, comandos, armazenamento e settings; sem alterações em engine / agent-loop / apiproxy / UI oficial.
|
|
192
195
|
- **Visível para o modelo ⟺ registrado.** Tudo o que o modelo vê é reconstruível a partir do log de sessão — sem novo tipo de evento de sessão, sem alterações no agent-loop.
|
|
193
196
|
- **Original sempre conservado.** Cada render (e `/export`) mantém o texto original ao lado do renderizado; a exportação HTML usa HTML saneado.
|
|
197
|
+
- **Escritas em disco controladas.** `/export --save` escreve somente após o serviço de aprovação conceder, e o conteúdo escrito passa primeiro pela função pura `sanitizeText`; sem um serviço de aprovação ou fs, nada é escrito (fail-closed).
|
|
194
198
|
|
|
195
199
|
## Known limitations
|
|
196
200
|
|
|
@@ -203,7 +207,7 @@ Filtrado contra o ecossistema DSH antes do desenvolvimento (instantânea 2026-08
|
|
|
203
207
|
```sh
|
|
204
208
|
pnpm install
|
|
205
209
|
pnpm run typecheck # ambos os projetos tsc
|
|
206
|
-
pnpm test # vitest —
|
|
210
|
+
pnpm test # vitest — 127 tests
|
|
207
211
|
pnpm run verify # typecheck + tests + self-contained (a porta de prepublishOnly)
|
|
208
212
|
pnpm run build # artefatos lib/ (bundles host + client)
|
|
209
213
|
pnpm pack # tarball para dsh plugin add
|
package/README.zh.md
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
- **Claude Code 对齐** —— `keep-coding-instructions`、`force-for-plugin`(别名 `force`)、`outputStyles` JSON 兼容、分层 `stylesDir` 目录、热重载,以及通过 DSH settings 接缝的项目默认回退。
|
|
41
41
|
- **渲染器注册表(`output.render.*`)** —— `ctx.outputRenderers` 允许任意插件注册纯 presenter,经 `output.render/before` waterfall 应用;内置渲染器 `concise` 与 `step-by-step`。
|
|
42
42
|
- **按会话/按工具规则** —— `rules: [{ match: { tool: 'bash' }, style: 'concise' }]` 为匹配请求指定渲染器;可通过 `output-style-rules` 设置区编辑。
|
|
43
|
-
- **`/export`** —— 经渲染管线把当前会话导出为 Markdown 或净化 HTML
|
|
43
|
+
- **`/export`** —— 经渲染管线把当前会话导出为 Markdown 或净化 HTML;`--save <path>` 经用户审批后把净化文档写入该工作区路径。每次渲染都保留原文与渲染结果并列。
|
|
44
44
|
|
|
45
45
|
## Quick start
|
|
46
46
|
|
|
@@ -111,14 +111,15 @@ flowchart LR
|
|
|
111
111
|
| `includeBuiltins` | `true` | 将包内置 `styles/` 作为最低优先级层 |
|
|
112
112
|
| `watchStyles` | `true` | 风格文件在磁盘上变化时重载库 |
|
|
113
113
|
| `rules` | `[]` | 按会话/按工具渲染规则:`[{ match: { tool?, contentType?, session? }, style, priority? }]` |
|
|
114
|
-
| `enableExport` | `true` | 注册 `/export` 命令(Markdown/HTML
|
|
114
|
+
| `enableExport` | `true` | 注册 `/export` 命令(Markdown/HTML 会话导出,感知渲染器;`--save` 经审批写入) |
|
|
115
|
+
| `respectCoreOutputStyles` | `true` | 检测到核心 `outputStyles` 服务时跳过本插件的提示词注入(保留热切换 / rules / export) |
|
|
115
116
|
|
|
116
117
|
## Tools & surfaces
|
|
117
118
|
|
|
118
119
|
| Surface | Kind | Notes |
|
|
119
120
|
|---|---|---|
|
|
120
121
|
| `/style` | command | 列出风格、切换或恢复项目默认 |
|
|
121
|
-
| `/export` | command | 把当前会话渲染为 Markdown 或净化 HTML |
|
|
122
|
+
| `/export` | command | 把当前会话渲染为 Markdown 或净化 HTML;`--save` 经审批写入 |
|
|
122
123
|
| `output_style` | storage domain | 按 sessionId 隔离的会话级风格选择 |
|
|
123
124
|
| `systemPrompt.section()` | contribution | 在每次组装时注入当前风格正文 |
|
|
124
125
|
| `output.render.*` | renderer registry | `ctx.outputRenderers` + `output.render/before` waterfall |
|
|
@@ -135,8 +136,10 @@ flowchart LR
|
|
|
135
136
|
| `/style off` | 恢复项目默认(settings 默认,其次 `defaultStyle`) |
|
|
136
137
|
| `/style nope` | `error: unknown output style "nope" (available: …)` |
|
|
137
138
|
| `/export` | 经渲染管线把当前会话渲染为 Markdown |
|
|
139
|
+
| `/export md` | 渲染为 Markdown(`md` 是 `markdown` 的简写) |
|
|
138
140
|
| `/export html` | 渲染为净化 HTML |
|
|
139
141
|
| `/export --renderer=concise` | 强制指定一个渲染器渲染(跳过规则) |
|
|
142
|
+
| `/export md --save report.md` | 渲染后经审批把净化文档写入 `report.md` |
|
|
140
143
|
|
|
141
144
|
## Style library
|
|
142
145
|
|
|
@@ -182,7 +185,7 @@ flowchart LR
|
|
|
182
185
|
|
|
183
186
|
## Permissions & data
|
|
184
187
|
|
|
185
|
-
- **Permissions**:workshop 清单声明 `fs:read`、`fs:watch`、`storage:read`、`storage:write` 与 `settings:read`。
|
|
188
|
+
- **Permissions**:workshop 清单声明 `fs:read`、`fs:write`、`fs:watch`、`storage:read`、`storage:write` 与 `settings:read`。
|
|
186
189
|
- **Data**:风格选择存于 `output_style` 存储域(按 sessionId 隔离);不持久化其他状态,无网络请求。
|
|
187
190
|
- **Session log**:风格名来自 `command/run`,精确注入文本来自 `request/header`;来源标记 `{ kind: 'plugin', plugin: 'dsh-output-styles' }` 随域记录携带。
|
|
188
191
|
|
|
@@ -191,6 +194,7 @@ flowchart LR
|
|
|
191
194
|
- **仅公开服务。** 贡献 `systemPrompt`、命令、存储与 settings;不改 engine / agent-loop / apiproxy / 官方 UI。
|
|
192
195
|
- **模型可见 ⟺ 已记录。** 模型所见的一切都能从会话日志重建 —— 无新增会话事件类型、无 agent-loop 改动。
|
|
193
196
|
- **始终保留原文。** 每次渲染(含 `/export`)都保留原文与渲染结果并列;HTML 导出使用净化 HTML。
|
|
197
|
+
- **写盘有门禁。** `/export --save` 仅在审批服务放行后写入,且写入内容先经 `sanitizeText` 纯函数净化;缺少审批或 fs 服务时一律不写入(fail-closed)。
|
|
194
198
|
|
|
195
199
|
## Known limitations
|
|
196
200
|
|
|
@@ -203,7 +207,7 @@ flowchart LR
|
|
|
203
207
|
```sh
|
|
204
208
|
pnpm install
|
|
205
209
|
pnpm run typecheck # 两个 tsc 项目
|
|
206
|
-
pnpm test # vitest ——
|
|
210
|
+
pnpm test # vitest —— 127 个测试
|
|
207
211
|
pnpm run verify # typecheck + tests + self-contained(prepublishOnly 门禁)
|
|
208
212
|
pnpm run build # lib/ 产物(host + client 包)
|
|
209
213
|
pnpm pack # 供 dsh plugin add 的 tarball
|
package/cordis.patch.yml
CHANGED
|
@@ -31,6 +31,11 @@
|
|
|
31
31
|
# truncationMarker: "\n\n[style truncated]"
|
|
32
32
|
# includeBuiltins: true
|
|
33
33
|
# watchStyles: true
|
|
34
|
+
# rules: [] # per-session/per-tool render rules
|
|
35
|
+
# # [{ match: { tool?, contentType?, session? }, style, priority? }]
|
|
36
|
+
# enableExport: true # register the /export command
|
|
37
|
+
# # (md|html; --save <path> writes the
|
|
38
|
+
# # sanitized document after approval)
|
|
34
39
|
|
|
35
40
|
# Optional invariant companion (envelope-level checks). Only for profiles
|
|
36
41
|
# that DISABLE the main row above: the main plugin already registers
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Coexistence with a core `outputStyles` capability
|
|
2
|
+
|
|
3
|
+
`dsh-output-styles` is the standalone Claude Code `outputStyles`-equivalent. If
|
|
4
|
+
DeepSeek Harness ships a first-party `outputStyles` feature, the two would
|
|
5
|
+
otherwise both inject an output-style directive into the system prompt. This
|
|
6
|
+
plugin ships a coexistence policy that detects the core capability and degrades
|
|
7
|
+
to the incremental surface it uniquely adds.
|
|
8
|
+
|
|
9
|
+
## Detection
|
|
10
|
+
|
|
11
|
+
The core capability is detected through its reserved service seam, not by name
|
|
12
|
+
guessing. A core implementation publishes the `outputStyles` service; the plugin
|
|
13
|
+
probes it at mount:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { detectCoreOutputStyles } from 'dsh-output-styles'
|
|
17
|
+
|
|
18
|
+
// ctx is the plugin-scoped Cordis context.
|
|
19
|
+
const coreActive = detectCoreOutputStyles(ctx)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- **Core absent** → `standalone` mode: the plugin injects the style section
|
|
23
|
+
(`systemPrompt.section('output-style:selection')` plus the
|
|
24
|
+
`system-prompt/assemble` waterfall for `keep-coding-instructions: false`).
|
|
25
|
+
- **Core present** → `degraded` mode: prompt injection is left to the core, and
|
|
26
|
+
the plugin keeps only hot-switch (`/style`), rules, and `/export`.
|
|
27
|
+
|
|
28
|
+
## Runnable verification
|
|
29
|
+
|
|
30
|
+
`coexistenceReport` is the runnable check for one composition:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { coexistenceReport } from 'dsh-output-styles'
|
|
34
|
+
|
|
35
|
+
const report = coexistenceReport(ctx)
|
|
36
|
+
// report = { coreActive, mode: 'standalone' | 'degraded',
|
|
37
|
+
// promptInjection: 'enabled' | 'disabled', retained, disabled }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
It is also covered by the test suite (`tests/coexist.spec.ts`), which mounts the
|
|
41
|
+
plugin with a fake `outputStyles` service and asserts the injected section is
|
|
42
|
+
absent while `/style` and the renderer registry stay active.
|
|
43
|
+
|
|
44
|
+
## Forcing injection
|
|
45
|
+
|
|
46
|
+
A deployment that wants this plugin to keep injecting regardless of the core can
|
|
47
|
+
set `respectCoreOutputStyles: false` in `cordis.yml`. The default is `true`
|
|
48
|
+
(honor the core and avoid duplicate injection).
|
|
49
|
+
|
|
50
|
+
## Degraded surface
|
|
51
|
+
|
|
52
|
+
In `degraded` mode the plugin still contributes:
|
|
53
|
+
|
|
54
|
+
- **Hot-switch** — `/style` listing/selection, per-session persistence over the
|
|
55
|
+
`output_style` domain, and the `style` session projection.
|
|
56
|
+
- **Rules** — the `output.render.*` renderer registry, the
|
|
57
|
+
`output.render/before` waterfall, and per-session/per-tool rules.
|
|
58
|
+
- **Export** — `/export` (Markdown / sanitized HTML) through the renderer
|
|
59
|
+
pipeline, with approval-gated `--save`.
|
|
60
|
+
|
|
61
|
+
Only the two prompt-injection registrations (the prompt section and the
|
|
62
|
+
`system-prompt/assemble` waterfall) are skipped.
|
|
@@ -132,3 +132,13 @@ export function apply(ctx: Context): void {
|
|
|
132
132
|
const result = await ctx.outputRenderers.renderText(rawText, { tool: 'sql', contentType: 'text' })
|
|
133
133
|
// { original, rendered, rendererId, changed } — log both halves wherever you surface it.
|
|
134
134
|
```
|
|
135
|
+
|
|
136
|
+
## Export to disk
|
|
137
|
+
|
|
138
|
+
`/export` returns the rendered document as command output text. `/export
|
|
139
|
+
[md|markdown|html] [--renderer=<id>] --save <path>` additionally writes the
|
|
140
|
+
document to a workspace path: the document passes through the `sanitizeText`
|
|
141
|
+
pure function first, then the write is gated by the approval service
|
|
142
|
+
(`ctx.get('approval')`, fail-closed when absent) and performed by the fs
|
|
143
|
+
service (`ctx.get('fs')`, fail-loud when absent). The render pipeline itself is
|
|
144
|
+
unchanged — the same presenters and rule table apply before either output.
|
|
@@ -123,3 +123,11 @@ export function apply(ctx: Context): void {
|
|
|
123
123
|
const result = await ctx.outputRenderers.renderText(rawText, { tool: 'sql', contentType: 'text' })
|
|
124
124
|
// { original, rendered, rendererId, changed } —— 在任何展示它的地方把两半都记下来。
|
|
125
125
|
```
|
|
126
|
+
|
|
127
|
+
## 导出到磁盘
|
|
128
|
+
|
|
129
|
+
`/export` 把渲染后的文档作为命令输出文本返回。`/export [md|markdown|html]
|
|
130
|
+
[--renderer=<id>] --save <path>` 另外把文档写入工作区路径:文档先经 `sanitizeText`
|
|
131
|
+
纯函数净化,随后写入由审批服务(`ctx.get('approval')`,缺失则 fail-closed)把关、由
|
|
132
|
+
fs 服务(`ctx.get('fs')`,缺失则大声失败)执行。渲染流水线本身不变——两种输出之前都应用
|
|
133
|
+
同样的 presenter 与规则表。
|