@user-mrz/dsh-system-prompt-studio 0.0.0-stage → 0.1.7
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 +138 -0
- package/LICENSE +21 -0
- package/README.md +372 -2
- package/cordis.patch.yml +65 -0
- package/icon.svg +16 -0
- package/lib/client.js +1086 -0
- package/lib/index.js +1265 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +61 -6
- package/scripts/verify-entry.mjs +39 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this plugin are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project adheres to
|
|
5
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
Because this plugin binds to internal DSH contracts that carry no stability promise, a version bump
|
|
8
|
+
here is a statement about **those contracts**, not only about features: a minor bump means the
|
|
9
|
+
integration still targets the same DSH shapes, a major bump means it may not.
|
|
10
|
+
|
|
11
|
+
## [Unreleased]
|
|
12
|
+
|
|
13
|
+
Nothing yet.
|
|
14
|
+
|
|
15
|
+
## [0.1.7] — 2026-11-10
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **The plugin prevented DSH from starting.** Renaming the package to a scoped name left the client
|
|
20
|
+
bundle registering itself under the old short id. `client-modules` keys its factory table by
|
|
21
|
+
`registration.id`, while the host dispatches the same bundle by package name, so the two ids made it
|
|
22
|
+
register twice and the renderer threw `duplicate factory registration for "dsh-system-prompt-studio"`.
|
|
23
|
+
DSH showed "无法使用" and refused to boot. The id is now the package name.
|
|
24
|
+
|
|
25
|
+
This is the third distinct way the rename broke something, and each one only surfaced at real startup:
|
|
26
|
+
the profile `bundles` entry, the `cordis.patch.yml` `name`, and now the client id. A CI step now
|
|
27
|
+
asserts that the manifest name, the patch `name`, and the client `id` are the same string, so the
|
|
28
|
+
next rename fails in CI instead of on someone's machine.
|
|
29
|
+
|
|
30
|
+
## [0.1.6] — 2026-11-10
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- The new "published tarball is installable" CI step failed on both Node versions with nothing but
|
|
35
|
+
`exit code 254`. Cause: it packed into `/tmp/pack`, which does not exist, and redirected
|
|
36
|
+
`npm pack`'s output to `/dev/null`, so the real error was discarded. A check written to prevent
|
|
37
|
+
silent failures failed silently on its first run. It now uses `mktemp -d` and lets `npm pack` print.
|
|
38
|
+
|
|
39
|
+
## [0.1.5] — 2026-11-10
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- The package is now published to npm as `@user-mrz/dsh-system-prompt-studio`. The unscoped name
|
|
44
|
+
`dsh-system-prompt-studio` was already taken on npm, so the scoped name keeps the same identity under
|
|
45
|
+
a namespace the author controls.
|
|
46
|
+
- `cordis.patch.yml` keeps `id: dsh-system-prompt-studio` but its `name` is now the scoped package. The
|
|
47
|
+
loader imports the row by `name`, so those two must agree; `id` is the anchor existing users override
|
|
48
|
+
by, so renaming it would silently drop their patch entries.
|
|
49
|
+
- `description` in `package.json` is now English, since that is what npm renders in search results.
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- **The published tarball could not be installed.** `files` omitted `scripts/`, so `prepare` — which
|
|
54
|
+
runs `scripts/verify-entry.mjs` — failed with `MODULE_NOT_FOUND` on every install. The repository
|
|
55
|
+
always had that directory, which is exactly why no test here could see it; only the packed tarball
|
|
56
|
+
exposes the gap. `scripts` is now included, and CI unpacks the real tarball and runs `prepare` inside
|
|
57
|
+
it, so this class of mistake cannot ship again.
|
|
58
|
+
|
|
59
|
+
## [0.1.4] — 2026-11-10
|
|
60
|
+
|
|
61
|
+
### Fixed
|
|
62
|
+
|
|
63
|
+
- The "section list is out of date" warning was decided by comparing millisecond timestamps. A save and
|
|
64
|
+
an assembly can land in the same millisecond — in the test suite they almost always do — and then
|
|
65
|
+
`updatedAt > assembly.at` is false, so a genuinely stale list was reported as current and the panel
|
|
66
|
+
stayed silent. Staleness is now decided by a monotonic write sequence instead. The sequence resumes
|
|
67
|
+
from the highest value in the state file on startup, so a restart cannot make a new write look older
|
|
68
|
+
than a stored one.
|
|
69
|
+
|
|
70
|
+
### Added
|
|
71
|
+
|
|
72
|
+
- CI workflow (`.github/workflows/check.yml`) on Node 20 and 22: syntax, both structural test suites,
|
|
73
|
+
the install-time `prepare` script, manifest sanity (`dsh.bundle.patch` exists, every `exports` subpath
|
|
74
|
+
resolves), version/CHANGELOG consistency, and a guard against committed personal data.
|
|
75
|
+
- `sectionsSeq` on the status payload, for the staleness comparison.
|
|
76
|
+
|
|
77
|
+
## [0.1.3] — 2026-11-10
|
|
78
|
+
|
|
79
|
+
### Fixed
|
|
80
|
+
|
|
81
|
+
- The section list no longer looks broken when it is merely out of date. Assembly runs on a model
|
|
82
|
+
request, not on save, so the list was always one request behind; the panel now shows the assembly's
|
|
83
|
+
clock time and says explicitly when that assembly predates the current override.
|
|
84
|
+
- **Replace everything** mode now labels its section list. The harness replaces the whole section
|
|
85
|
+
array *after* the `system-prompt/assemble` waterfall, so every observer necessarily sees the
|
|
86
|
+
pre-replacement list. The panel explains this instead of leaving the user to conclude the override
|
|
87
|
+
did nothing.
|
|
88
|
+
|
|
89
|
+
### Added
|
|
90
|
+
|
|
91
|
+
- `sectionsAt`, `sectionsStale` and `sectionsComplete` on the status payload.
|
|
92
|
+
|
|
93
|
+
## [0.1.2] — 2026-11-09
|
|
94
|
+
|
|
95
|
+
### Added
|
|
96
|
+
|
|
97
|
+
- An entry point in `conversation.hero.options`, so a brand-new conversation can be given a system
|
|
98
|
+
prompt before its first message. The blank conversation renders with `hideChrome`, which means
|
|
99
|
+
`conversation.session.header.actions` never mounts there and the panel was previously unreachable
|
|
100
|
+
until a message had been sent.
|
|
101
|
+
- `showOnNewConversation` config key (default `true`) to turn that second entry point off.
|
|
102
|
+
|
|
103
|
+
### Fixed
|
|
104
|
+
|
|
105
|
+
- `scopeGlobalHint` claimed the global default applied to *new* conversations. It applies to every
|
|
106
|
+
top-level conversation without an override of its own, including ones that already existed.
|
|
107
|
+
|
|
108
|
+
## [0.1.1] — 2026-11-09
|
|
109
|
+
|
|
110
|
+
### Fixed
|
|
111
|
+
|
|
112
|
+
- Forked conversations inherit the nearest upstream override along `parentSession`, with a *Pin*
|
|
113
|
+
action to freeze the inherited result locally. Previously a fork silently reverted to the default
|
|
114
|
+
prompt, which was the failure mode hardest to notice.
|
|
115
|
+
- Unsaved edits are guarded: `Esc`, backdrop clicks and the close button all ask before discarding,
|
|
116
|
+
and `beforeunload` fires only when the panel is actually dirty.
|
|
117
|
+
- The module export surface no longer exposes write paths (`install`, `handlePost`, …) to any
|
|
118
|
+
same-process importer; test hooks are gated behind `NODE_ENV=test`.
|
|
119
|
+
|
|
120
|
+
## [0.1.0] — 2026-11-09
|
|
121
|
+
|
|
122
|
+
### Added
|
|
123
|
+
|
|
124
|
+
- Initial release: per-conversation system prompt overrides in three modes (append, shadow-replace a
|
|
125
|
+
named section, replace everything), persisted to `$DSH_HOME/dsh-system-prompt-studio/state.json`.
|
|
126
|
+
- Global default scope for top-level conversations.
|
|
127
|
+
- Read-only assembly observer listing the real section names, order and size.
|
|
128
|
+
- Loopback-only HTTP route for the panel; forged `Host` headers are refused.
|
|
129
|
+
|
|
130
|
+
[Unreleased]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.1.7...HEAD
|
|
131
|
+
[0.1.7]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.1.6...v0.1.7
|
|
132
|
+
[0.1.6]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.1.5...v0.1.6
|
|
133
|
+
[0.1.5]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.1.4...v0.1.5
|
|
134
|
+
[0.1.4]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.1.3...v0.1.4
|
|
135
|
+
[0.1.3]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.1.2...v0.1.3
|
|
136
|
+
[0.1.2]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.1.1...v0.1.2
|
|
137
|
+
[0.1.1]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.1.0...v0.1.1
|
|
138
|
+
[0.1.0]: https://github.com/user-Mrz/dsh-system-prompt-studio/releases/tag/v0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 user-Mrz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,373 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-system-prompt-studio
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
|
|
5
|
+
A **[DeepSeek Harness](https://github.com/deepseek-ai)** plugin that lets you inspect and override the
|
|
6
|
+
**system prompt** a conversation actually sends to the model — per conversation, at runtime, without
|
|
7
|
+
restarting.
|
|
8
|
+
|
|
9
|
+
DSH itself only exposes deployment-wide persona prefix/suffix in configuration files: change one and you
|
|
10
|
+
need a restart, and it affects every session. This plugin moves the same capability to runtime, per
|
|
11
|
+
session, effective immediately.
|
|
12
|
+
|
|
13
|
+
> 中文说明见文末 · [跳转到中文](#中文说明)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## What it does
|
|
18
|
+
|
|
19
|
+
- **See the real thing.** The panel shows the system prompt your conversation *actually sent* on its
|
|
20
|
+
last request, plus the section list that was assembled for it (name / order / character count).
|
|
21
|
+
- **Override it three ways.**
|
|
22
|
+
|
|
23
|
+
| Mode | Effect |
|
|
24
|
+
|---|---|
|
|
25
|
+
| **Append** (default) | Keeps every first-party section, adds yours at the end. Safest. |
|
|
26
|
+
| **Replace a section** | Shadows one named first-party section, e.g. `deployment:persona-suffix`. |
|
|
27
|
+
| **Replace everything** | Your text becomes the entire system prompt. Highest risk — see below. |
|
|
28
|
+
|
|
29
|
+
- **Applies on the next model request.** No restart, no reload.
|
|
30
|
+
- **Persists per session**, and a **global default** applies to new conversations automatically.
|
|
31
|
+
- **Inherits across forks.** A forked conversation picks up its parent's rules along the `parentSession`
|
|
32
|
+
chain, with a **Pin** action to freeze the inherited result locally.
|
|
33
|
+
- **Guards unsaved edits.** Esc, backdrop click and the close button all ask before discarding.
|
|
34
|
+
- **Zero runtime dependencies.** Only Node built-ins; it does not import any `@deepseek-ai/*` package.
|
|
35
|
+
|
|
36
|
+
### ⚠️ Before you use "Replace everything"
|
|
37
|
+
|
|
38
|
+
That mode removes **all** first-party guidance — tool instructions, structured-output rules, plan-mode
|
|
39
|
+
policy. Tool-calling quality can drop noticeably. Runtime context (working directory, sandbox policy,
|
|
40
|
+
approval policy) is still sent as a user-side snapshot and is **not** replaced by your text.
|
|
41
|
+
|
|
42
|
+
Also: assembly allows only one active `complete` section. If another plugin registers one in the same
|
|
43
|
+
session, assembly fails with `multiple complete prompt sections`. Switch back to Append or Replace to
|
|
44
|
+
recover.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Requirements
|
|
49
|
+
|
|
50
|
+
- DSH `>=0.2.2-0 <0.3.0-0` (Web and Desktop share the same client artifact)
|
|
51
|
+
- Node.js ≥ 22.19.0
|
|
52
|
+
|
|
53
|
+
## Install
|
|
54
|
+
|
|
55
|
+
From npm (recommended — this is the version that gets version numbers, tags and a published tarball):
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
dsh plugin --profile <profile> add @user-mrz/dsh-system-prompt-studio
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
From GitHub, which tracks the default branch and therefore needs a ref if you want a fixed version:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
dsh plugin --profile <profile> add github:user-Mrz/dsh-system-prompt-studio#v0.1.4
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Replace `<profile>` with your profile name — for the Web build that is usually `web`.
|
|
68
|
+
|
|
69
|
+
**Pin a version for reproducibility.** Without one you get whatever is newest, so a later release
|
|
70
|
+
changes what you install next time:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
dsh plugin --profile <profile> add @user-mrz/dsh-system-prompt-studio@0.1.4
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
<details>
|
|
77
|
+
<summary>Local directory install (for development)</summary>
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
dsh plugin --profile <profile> add file:/absolute/path/to/dsh-system-prompt-studio
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
</details>
|
|
84
|
+
|
|
85
|
+
### If pnpm blocks the build script
|
|
86
|
+
|
|
87
|
+
pnpm refuses to run build scripts from Git dependencies by default. This plugin's `prepare` script only
|
|
88
|
+
**verifies** that the entry files exist — it compiles nothing and writes nothing — so being blocked does
|
|
89
|
+
not break the install. If pnpm stops anyway, it writes a pending entry into your profile's
|
|
90
|
+
`pnpm-workspace.yaml`:
|
|
91
|
+
|
|
92
|
+
```yaml
|
|
93
|
+
allowBuilds:
|
|
94
|
+
dsh-system-prompt-studio: set this to true or false # ← change this line to: true
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Set it to `true` and re-run the same `add` command.
|
|
98
|
+
|
|
99
|
+
> ⚠️ That grants this package's code permission to run **outside the DSH agent sandbox** at install time.
|
|
100
|
+
> Here, [`scripts/verify-entry.mjs`](scripts/verify-entry.mjs) only reads files — no network, no writes —
|
|
101
|
+
> but grant it only to source you trust.
|
|
102
|
+
|
|
103
|
+
### After installing
|
|
104
|
+
|
|
105
|
+
The Host half activates immediately. **The client half is new JavaScript, so refresh the page once** to
|
|
106
|
+
make the title-bar button appear.
|
|
107
|
+
|
|
108
|
+
Verify the Host half is live:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
curl "http://127.0.0.1:3080/api/system-prompt-studio?session=<sessionId>"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
A `{"ok":true,...,"capability":{...}}` response means it's working.
|
|
115
|
+
|
|
116
|
+
### Uninstall
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
dsh plugin --profile <profile> remove @user-mrz/dsh-system-prompt-studio
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Your saved overrides are **not** deleted.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Usage
|
|
127
|
+
|
|
128
|
+
1. A **System prompt** button appears in the title bar of any conversation (with a dot when this
|
|
129
|
+
conversation already has its own override). On a **brand-new conversation** the title bar is
|
|
130
|
+
hidden by the harness, so the button lives in the welcome area instead, labeled
|
|
131
|
+
**Set system prompt**.
|
|
132
|
+
2. Pick a scope: **this conversation** or **global default**. The global default applies to top-level
|
|
133
|
+
conversations only — not to subagents.
|
|
134
|
+
3. Choose a mode, write your text, save. It takes effect on your next message.
|
|
135
|
+
4. Expand the two read-only blocks at the bottom to check reality:
|
|
136
|
+
- *System prompt of the latest request* — what was actually sent;
|
|
137
|
+
- *Sections assembled for this conversation* — real section names, order and size.
|
|
138
|
+
|
|
139
|
+
### Can I set the prompt of a conversation that hasn't started yet?
|
|
140
|
+
|
|
141
|
+
Yes, and it applies from the **first** message, not the second. The harness creates the agent the
|
|
142
|
+
moment the conversation exists — before you type anything — so the override is already registered by
|
|
143
|
+
the time your first prompt is assembled. Open the welcome-area button and save.
|
|
144
|
+
|
|
145
|
+
Two ways to cover a new conversation:
|
|
146
|
+
|
|
147
|
+
| Want | Do this |
|
|
148
|
+
| --- | --- |
|
|
149
|
+
| Just this one new conversation | Open its welcome-area button → **this conversation** → save |
|
|
150
|
+
| Every top-level conversation that has no override of its own | Open the button in any conversation → **global default** → save |
|
|
151
|
+
|
|
152
|
+
The global default is **not** limited to conversations created after you save it: it is re-evaluated
|
|
153
|
+
for every live conversation on each save, so existing top-level conversations without an override of
|
|
154
|
+
their own pick it up immediately too. A conversation that has its own override keeps it — the global
|
|
155
|
+
default only fills in where nothing more specific exists.
|
|
156
|
+
|
|
157
|
+
### Choosing a section to replace
|
|
158
|
+
|
|
159
|
+
"Replace a section" works by registering a section with the **same name** in the conversation's scope,
|
|
160
|
+
which shadows the first-party one. There is no separate API for it — that *is* the mechanism.
|
|
161
|
+
|
|
162
|
+
The panel's section list comes from the live assembly, so the names are real. Pick from the dropdown
|
|
163
|
+
rather than typing from memory: several names are easy to guess wrong.
|
|
164
|
+
|
|
165
|
+
### The section list is a snapshot, not a live view
|
|
166
|
+
|
|
167
|
+
Assembly happens when a model request runs; saving does not trigger one. So the section list is always
|
|
168
|
+
**one request behind** your last save. The panel shows the time of the assembly it came from, and says so
|
|
169
|
+
explicitly when that assembly predates your save — send one message and reopen to see the new result.
|
|
170
|
+
|
|
171
|
+
In **Replace everything** mode the list is always the *pre-replacement* set. That is not a bug: the
|
|
172
|
+
harness applies a `complete` section by replacing the whole section array *after* the assembly hook has
|
|
173
|
+
already run, so any observer — including this one — necessarily sees the full list first. The panel labels
|
|
174
|
+
this case instead of leaving you to wonder why every section is still listed.
|
|
175
|
+
|
|
176
|
+
> An assembled section carries only `name` / `text` / `interpolate` — **not** its sort order. The plugin
|
|
177
|
+
> reconstructs order from known constants plus position in the assembly array
|
|
178
|
+
> ([`deriveOrders`](lib/index.js)). Unknown names land near where they actually belong; a name that
|
|
179
|
+
> does not exist falls back to the append order and is inserted as a new section.
|
|
180
|
+
|
|
181
|
+
### Forked conversations
|
|
182
|
+
|
|
183
|
+
A fork gets a **new session id**. So that carefully tuned rules don't silently vanish, the child walks
|
|
184
|
+
the `parentSession` chain to the nearest ancestor that has its own rules:
|
|
185
|
+
|
|
186
|
+
- the panel shows *Inherited from: …* with a **Pin here** button;
|
|
187
|
+
- **Pin** writes the inherited result into the conversation's own entry — later upstream changes no
|
|
188
|
+
longer affect it;
|
|
189
|
+
- edit the child yourself and inheritance stops immediately (own rules win);
|
|
190
|
+
- at most `maxInheritDepth` levels up (default 3); `inheritOnFork: false` disables it entirely.
|
|
191
|
+
|
|
192
|
+
### Unsaved edits
|
|
193
|
+
|
|
194
|
+
When there are unsaved changes, Esc / backdrop click / ✕ all ask *Discard unsaved changes?* first. Inside
|
|
195
|
+
that confirmation, Esc means **keep editing** — mashing Esc never destroys your text. Closing the tab or
|
|
196
|
+
reloading triggers the browser's own leave confirmation. Editing and reverting is not considered dirty.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Configuration
|
|
201
|
+
|
|
202
|
+
Edit the row in `cordis.patch.yml` or override it in your profile patch. The most useful keys:
|
|
203
|
+
|
|
204
|
+
| Key | Default | Meaning |
|
|
205
|
+
|---|---|---|
|
|
206
|
+
| `enabled` | `true` | Master switch; when off, no section is registered and the API reports why |
|
|
207
|
+
| `defaultMode` | `append` | Mode used by the global default |
|
|
208
|
+
| `allowComplete` | `true` | Set `false` to disable "replace everything" entirely |
|
|
209
|
+
| `appendOrder` | `10500` | Sort order of the appended section, clamped to `[10201, 20000]` |
|
|
210
|
+
| `maxChars` | `200000` | Max body length; oversize is **rejected**, never truncated |
|
|
211
|
+
| `globalDefaultScope` | `roots` | Whether the global default also applies to subagents (`all` to include) |
|
|
212
|
+
| `inheritOnFork` | `true` | Whether forked conversations inherit upstream rules |
|
|
213
|
+
| `maxInheritDepth` | `3` | How many levels to walk up (1–8); `0` behaves like off |
|
|
214
|
+
| `observeAssemblies` | `true` | Read-only assembly observer; required for the section list |
|
|
215
|
+
| `visible` | `true` | Whether the panel button is shown (client-side) |
|
|
216
|
+
| `showOnNewConversation` | `true` | Whether the welcome area of a brand-new conversation also gets a button (client-side) |
|
|
217
|
+
| `hostURL` | `''` | Fallback host URL for desktop shells; empty = auto |
|
|
218
|
+
|
|
219
|
+
Every key is documented in [`cordis.patch.yml`](cordis.patch.yml).
|
|
220
|
+
|
|
221
|
+
## Where data lives
|
|
222
|
+
|
|
223
|
+
`$DSH_HOME/dsh-system-prompt-studio/state.json` — versioned JSON:
|
|
224
|
+
|
|
225
|
+
```jsonc
|
|
226
|
+
{
|
|
227
|
+
"version": 1,
|
|
228
|
+
"global": { "enabled": false, "mode": "append", "text": "", "target": "", "updatedAt": 0 },
|
|
229
|
+
"sessions": { "<sessionId>": { "enabled": true, "mode": "append", "text": "…", "target": "", "updatedAt": 0 } }
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
- Writes go through a temp file plus atomic `rename`, serialized on one queue.
|
|
234
|
+
- If a write fails, the panel says so explicitly (*in memory only, lost on restart*) rather than
|
|
235
|
+
pretending the save worked.
|
|
236
|
+
- A corrupt file is **never overwritten**: it is backed up to `state.json.corrupt-<timestamp>` first, the
|
|
237
|
+
plugin starts empty, and the reason is reported in the API's `health` field.
|
|
238
|
+
|
|
239
|
+
## HTTP API
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
GET /api/system-prompt-studio?session=<sessionId>
|
|
243
|
+
POST /api/system-prompt-studio
|
|
244
|
+
{ "action": "set", "scope": "session"|"global", "sessionId"?: "…", "patch": { "enabled": true, "mode": "append"|"replace"|"complete", "text": "…", "target": "…" } }
|
|
245
|
+
{ "action": "clear", "scope": "session"|"global", "sessionId"?: "…" }
|
|
246
|
+
{ "action": "pin", "scope": "session", "sessionId": "…" }
|
|
247
|
+
{ "action": "resetAll", "confirm": true }
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
- Loopback-only: both the socket and the `Host` header must be loopback; cross-site origins get 403.
|
|
251
|
+
- POST bodies over `maxChars * 4` bytes are rejected with 413 (never truncated).
|
|
252
|
+
- Stable error codes: `TEXT_TOO_LONG`, `EMPTY_TEXT`, `TARGET_REQUIRED`, `COMPLETE_BLOCKED`,
|
|
253
|
+
`UNKNOWN_ACTION`, `MISSING_SESSION`, `NOTHING_TO_PIN`, `PIN_SESSION_ONLY`, `CONFIRM_REQUIRED`,
|
|
254
|
+
`INVALID_JSON`, `BODY_TOO_LARGE`, `method-not-allowed`, `forbidden: loopback-only`.
|
|
255
|
+
|
|
256
|
+
## Known limitations
|
|
257
|
+
|
|
258
|
+
1. **Overrides are keyed by session id, but forks inherit.** A forked conversation picks up the nearest
|
|
259
|
+
ancestor's rules (disable with `inheritOnFork`). Subagents do not take the global default and do not
|
|
260
|
+
participate in the chain. Resuming a session under the same id re-applies its rules.
|
|
261
|
+
2. **Cold sessions** (no live agent) can be saved for, but take effect once resumed. Inheritance
|
|
262
|
+
specifically requires a live agent, because the parent chain is read from the session header — a cold
|
|
263
|
+
session has none until it is running again.
|
|
264
|
+
3. **`{{…}}` is not interpolated.** Bodies are registered with `interpolate: false`, so braces stay
|
|
265
|
+
literal. This is deliberate: otherwise any `{{x}}` in your text would fail assembly with
|
|
266
|
+
*unknown prompt variable*.
|
|
267
|
+
4. **Cache prefix invalidation.** Changing the system prompt invalidates that conversation's provider
|
|
268
|
+
cache from the first changed token, so the next request pays for the new prefix. That is how the
|
|
269
|
+
mechanism works, not plugin behaviour.
|
|
270
|
+
5. **"Replace everything" is exclusive.** Assembly permits a single active `complete` section.
|
|
271
|
+
6. **Section attribution is approximate.** The list is attributed via the assembly context's scope (the
|
|
272
|
+
agent); if that is unavailable it falls back to the most recent assembly. Overrides themselves are
|
|
273
|
+
unaffected.
|
|
274
|
+
|
|
275
|
+
## Development
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
npm run check # syntax check + both test suites
|
|
279
|
+
node test/host-check.mjs # fake ctx: routes, section install, validation, loopback fence, cleanup, order derivation
|
|
280
|
+
node test/client-check.mjs # fake loader/React: slot registration, style injection and teardown
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
The Host half depends only on Node built-ins and resolves every service through `ctx.get(name)`, so the
|
|
284
|
+
plugin still loads and honestly reports capability bits when a service is missing.
|
|
285
|
+
|
|
286
|
+
[`scripts/verify-entry.mjs`](scripts/verify-entry.mjs) runs as `prepare` and only checks that entry files
|
|
287
|
+
exist — no compilation, since `lib/` is committed plain JavaScript.
|
|
288
|
+
|
|
289
|
+
## Privacy
|
|
290
|
+
|
|
291
|
+
No credentials, API keys, conversation content or personal paths are in this repository. At runtime the
|
|
292
|
+
plugin writes only under your own `$DSH_HOME/dsh-system-prompt-studio/`. Nothing is sent anywhere.
|
|
293
|
+
|
|
294
|
+
## License
|
|
295
|
+
|
|
296
|
+
[MIT](LICENSE)
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## 中文说明
|
|
301
|
+
|
|
302
|
+
按**对话**查看并覆盖模型实际收到的**系统提示词**,而不只是用户提示词。
|
|
303
|
+
|
|
304
|
+
DSH 本身只提供配置文件级的人设前后缀:改一次要重启,且对所有会话生效。这个插件把同一件事做成
|
|
305
|
+
运行时的、按会话的、即时生效的。
|
|
306
|
+
|
|
307
|
+
**三种模式**
|
|
308
|
+
|
|
309
|
+
| 模式 | 作用 |
|
|
310
|
+
|---|---|
|
|
311
|
+
| 追加(默认) | 保留第一方全部提示词,在末尾追加你的段落 —— 最安全 |
|
|
312
|
+
| 替换指定段 | 用同名段影子覆盖某一第一方段落,例如 `deployment:persona-suffix` |
|
|
313
|
+
| 完全替换 | 你的文本成为整段系统提示词 —— 风险最高 |
|
|
314
|
+
|
|
315
|
+
**⚠️ 关于「完全替换」**:它会移除第一方的全部指引(工具使用说明、结构化输出规则、计划模式策略),
|
|
316
|
+
工具调用质量可能明显下降。运行时上下文(工作目录 / 沙箱 / 审批策略)仍会作为用户侧快照发送,
|
|
317
|
+
不会被你的文本替换。另外装配只允许一个生效的 `complete` 段,若同会话内有别的插件也注册了一个,
|
|
318
|
+
装配会报 `multiple complete prompt sections` —— 改回「追加」或「替换」即可恢复。
|
|
319
|
+
|
|
320
|
+
**安装**
|
|
321
|
+
|
|
322
|
+
从 npm(推荐,有版本号可锁):
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
dsh plugin --profile <profile> add @user-mrz/dsh-system-prompt-studio
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
或从 GitHub(跟随默认分支,建议锁 tag):
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
dsh plugin --profile <profile> add github:user-Mrz/dsh-system-prompt-studio#v0.1.4
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
锁定版本,保证装到的是一份确定的代码:
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
dsh plugin --profile <profile> add @user-mrz/dsh-system-prompt-studio@0.1.4
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
`prepare` 脚本只校验入口文件存在,不做编译。若被 pnpm 拦下,把 `pnpm-workspace.yaml` 里
|
|
341
|
+
`allowBuilds` 下该包的待决占位改成 `true`,再重跑同一条命令 —— 这一步允许该包在 **DSH 沙箱之外**
|
|
342
|
+
执行安装期脚本,请只对你信任的源码授权。
|
|
343
|
+
|
|
344
|
+
**安装后**:Host 半即时生效;客户端是新的 JS,需要刷新一次页面才会出现标题栏按钮。
|
|
345
|
+
|
|
346
|
+
**使用**:打开对话 → 标题栏「系统提示词」按钮 → 选作用域、模式、写正文 → 保存,下一次发消息生效。
|
|
347
|
+
**新开的空对话**标题栏是隐藏的,入口改在欢迎区(文字为「设置系统提示词」)—— 会话一创建 agent
|
|
348
|
+
就已经在了,所以这里保存的覆盖**从第一句话**就生效,不是等到第二句。
|
|
349
|
+
面板底部两个只读区块分别显示「最近一次请求真正发出的系统提示词」与「本次装配到的段清单」。
|
|
350
|
+
|
|
351
|
+
**段清单是快照,不是实时视图**:装配只在模型请求时发生,保存不会触发它,所以清单总是比你刚才的
|
|
352
|
+
保存**晚一个请求**。面板会标出这份清单来自哪一次装配(时分秒),并在它早于你的保存时明确提示
|
|
353
|
+
「这是保存前的清单」——发一条消息再打开就能看到新结果。
|
|
354
|
+
|
|
355
|
+
**「完全替换」模式下清单永远是替换前的全量**。这不是 bug:DSH 在装配钩子**之后**才把 sections
|
|
356
|
+
整体换成 `[completeSection]`,所以任何观察者(包括本插件)必然先看到全量。面板会把这种情况标出来,
|
|
357
|
+
而不是让你对着几十个段怀疑替换没生效。
|
|
358
|
+
|
|
359
|
+
**新对话怎么生效**:「本对话」只作用于这一个新对话;「全局默认」作用于**所有没有自身覆盖的顶层
|
|
360
|
+
对话**——包括保存时就已经存在的那些,它是「兜底」而不是「只对新对话」。
|
|
361
|
+
|
|
362
|
+
**fork 继承**:fork 出的对话是新 session id,会沿 `parentSession` 链继承最近的祖先规则;面板显示
|
|
363
|
+
「继承自 …」并提供「在此固定」把继承结果固化成本地规则。子对话自己一改就停止继承。默认上溯 3 层,
|
|
364
|
+
可用 `inheritOnFork: false` 关闭。
|
|
365
|
+
|
|
366
|
+
**未保存保护**:有改动时 `Esc`、点遮罩、点 ✕ 都会先问「放弃未保存的修改?」;确认层里 `Esc` 等于
|
|
367
|
+
继续编辑。关标签页/刷新会触发浏览器离开确认。改了又改回去不算脏。
|
|
368
|
+
|
|
369
|
+
**数据位置**:`$DSH_HOME/dsh-system-prompt-studio/state.json`,原子写入;写失败会明说「只在内存」,
|
|
370
|
+
文件损坏会先备份成 `.corrupt-<时间戳>` 再空态起步。
|
|
371
|
+
|
|
372
|
+
**已知限制**:冷会话(没有活 agent)可以保存,但要等它恢复后才生效,且继承需要活会话才能读到父链;
|
|
373
|
+
`{{…}}` 不插值(刻意为之);系统提示词一变,该对话的缓存前缀从首个变化的 token 起失效。
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# dsh-system-prompt-studio bundle patch.
|
|
2
|
+
#
|
|
3
|
+
# 一个 HOST 平面的行。它必须落在 host 平面而不是某个 agent preset 里:既要
|
|
4
|
+
# 对每个会话按 agent 作用域注册提示词段,又要只注册一条回环 HTTP 路由给 Web
|
|
5
|
+
# 面板读取状态,这两件事都跨会话。
|
|
6
|
+
#
|
|
7
|
+
# 注意:patch 对同一行是「整体替换 config」而不是合并,所以这个文件是这份配置
|
|
8
|
+
# 的唯一权威;改默认值请改这里(用户的 patch 层会覆盖本行,升级时保留)。
|
|
9
|
+
#
|
|
10
|
+
# 逐键说明:
|
|
11
|
+
# enabled 总开关。false 时不注册任何提示词段,接口返回
|
|
12
|
+
# capability.enabled=false 并说明原因。
|
|
13
|
+
# apiPath 精确匹配的 HTTP 路由路径,必须以 /api/ 开头;不合法时
|
|
14
|
+
# 回退默认值并在日志里 warn。
|
|
15
|
+
# stateFile 覆盖状态落盘位置。空 = $DSH_HOME/dsh-system-prompt-studio/state.json
|
|
16
|
+
# defaultMode 没有任何覆盖时「全局默认」使用的模式:
|
|
17
|
+
# append | replace | complete
|
|
18
|
+
# allowComplete false 时完全替换模式一律拒绝(接口返回 COMPLETE_BLOCKED),
|
|
19
|
+
# 用来避免误把第一方提示词整段换掉。
|
|
20
|
+
# appendOrder 追加段的排序值(默认 10500,在第一方
|
|
21
|
+
# deployment:persona-suffix=10200 之后)。夹到 [10201, 20000]。
|
|
22
|
+
# defaultTargetName 替换模式的默认目标段名。真正的可选段名以面板里
|
|
23
|
+
# 「本会话装配到的段」实测清单为准。
|
|
24
|
+
# maxChars 单份覆盖正文的字符上限;超限直接拒绝而不是截断。
|
|
25
|
+
# observeAssemblies 是否注册只读的 system-prompt/assemble 观察(用来列出真实
|
|
26
|
+
# 段名与顺序)。false 时段清单返回 null,其余功能照常。
|
|
27
|
+
# maxObservedScopes 观察缓存的作用域上限(FIFO 淘汰),防止长期运行堆积。
|
|
28
|
+
# globalDefaultScope 「全局默认」套用到哪些会话:roots(默认,只套用到顶层会话,
|
|
29
|
+
# 不碰子代理)| all(含子代理)。
|
|
30
|
+
# inheritOnFork fork 继承:子会话没有自身覆盖时,沿 parentSession 链向上找。
|
|
31
|
+
# true(默认)| false(各会话独立,退回旧行为)。
|
|
32
|
+
# maxInheritDepth 继承最多上溯几层(1–8,默认 3)。0 等同于关闭继承。
|
|
33
|
+
# visible 面板入口按钮是否显示(client 半读取)。
|
|
34
|
+
# showLabel 入口按钮是否在图标旁显示文字(client 半读取,默认只显示图标)。
|
|
35
|
+
# showOnNewConversation 新空会话的欢迎区是否也放一个入口(client 半读取,默认 true)。
|
|
36
|
+
# 空会话是 hero 态,标题栏整行隐藏,只有这个槽里有入口;
|
|
37
|
+
# 关掉它等于「新对话只能靠全局默认」,不能单独给某个新对话设覆盖。
|
|
38
|
+
# hostURL 桌面壳跨源访问 host 时的回退地址;留空 = 自动(文档相对
|
|
39
|
+
# 地址 → 页面 origin → http://127.0.0.1:3080)。
|
|
40
|
+
|
|
41
|
+
- insert:
|
|
42
|
+
# `id` 是本行的稳定标识,保持短名不变——它是用户 patch 层覆盖的锚点,
|
|
43
|
+
# 改名会让已有用户的 `- id: dsh-system-prompt-studio` 覆盖失效。
|
|
44
|
+
# `name` 是 loader 真正 import 的模块名,必须和 package.json 的 name 一致,
|
|
45
|
+
# 发布到 npm 后就是 scoped 名。
|
|
46
|
+
- id: dsh-system-prompt-studio
|
|
47
|
+
name: '@user-mrz/dsh-system-prompt-studio'
|
|
48
|
+
config:
|
|
49
|
+
enabled: true
|
|
50
|
+
apiPath: /api/system-prompt-studio
|
|
51
|
+
stateFile: ''
|
|
52
|
+
defaultMode: append
|
|
53
|
+
allowComplete: true
|
|
54
|
+
appendOrder: 10500
|
|
55
|
+
defaultTargetName: 'deployment:persona-suffix'
|
|
56
|
+
maxChars: 200000
|
|
57
|
+
observeAssemblies: true
|
|
58
|
+
maxObservedScopes: 64
|
|
59
|
+
globalDefaultScope: roots
|
|
60
|
+
inheritOnFork: true
|
|
61
|
+
maxInheritDepth: 3
|
|
62
|
+
visible: true
|
|
63
|
+
showLabel: false
|
|
64
|
+
showOnNewConversation: true
|
|
65
|
+
hostURL: ''
|
package/icon.svg
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="System prompt studio">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="sps-bubble" x1="0" y1="0" x2="1" y2="1">
|
|
4
|
+
<stop offset="0" stop-color="#4f7cff"/>
|
|
5
|
+
<stop offset="1" stop-color="#2ec5a8"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<rect x="4" y="10" width="56" height="38" rx="9" fill="url(#sps-bubble)"/>
|
|
9
|
+
<path d="M18 48h12l-8 10z" fill="#2ec5a8"/>
|
|
10
|
+
<g fill="#ffffff" fill-opacity="0.94">
|
|
11
|
+
<circle cx="17" cy="26" r="3.4"/>
|
|
12
|
+
<rect x="24" y="23.4" width="26" height="5.2" rx="2.6"/>
|
|
13
|
+
<circle cx="17" cy="37" r="3.4"/>
|
|
14
|
+
<rect x="24" y="34.4" width="16" height="5.2" rx="2.6"/>
|
|
15
|
+
</g>
|
|
16
|
+
</svg>
|