@sagmans/dsh-terse 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sercan Sagman
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 ADDED
@@ -0,0 +1,123 @@
1
+ # dsh-terse
2
+
3
+ Mandatory, always-on terseness for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)
4
+ agents. Compresses everything an agent emits and everything it reads, without replacing the
5
+ deployment's system prompt and without giving up answer quality.
6
+
7
+ There is no mode and no off switch. Mounting the row is the enabling act.
8
+
9
+ ## What it does
10
+
11
+ | Layer | Extension point | Effect |
12
+ |---|---|---|
13
+ | **L1 constitution** | `systemPrompt.section` | A static, cache-stable rule set that makes every reply compressed. |
14
+ | **L2 standing reminder** | `systemPrompt.context` | A durable `<system-reminder>` snapshot that survives compaction, where a system-only rule fades. |
15
+ | **L3 drift nudge** | `tools/post-execute` -> `additionalContexts` | A one-line reminder that rides a tool result and catches a reply that ran long. Capped per turn; cannot loop. |
16
+ | **L4 input shaping** | `tools/post-execute` content | Collapses repeated lines and elides the middle of oversized tool output, with a locator so the original is one call away. |
17
+ | **L5 enforcement** | `system-prompt/assemble` | Asserts the constitution survived assembly; logs a loud warning if it did not. Never rewrites peer contributions. |
18
+ | **L6 coverage** | per-session state | Cadence and reply observations keyed by the session object, so a resumed or forked session starts clean. |
19
+
20
+ ## Why it does not hurt quality
21
+
22
+ Compression is aimed at the **chat mouth**, never at meaning or at durable artifacts:
23
+
24
+ - **Never cut** negations, quantifiers, numbers, units, code, identifiers, paths, commands, or
25
+ exact error strings. These are the token classes whose loss flips semantics.
26
+ - **Never fake terseness.** Invented abbreviations and arrows cost the same tokens and hurt
27
+ clarity; if the terse form is not shorter than plain, plain wins.
28
+ - **Full prose returns** for security warnings, irreversible-action confirmations,
29
+ order-sensitive multi-step sequences, and anywhere compression would create ambiguity.
30
+ - **Code is never judged as drift**, so a long implementation is never punished.
31
+ - **Tool output is only elided reversibly**, never lossy on errors, and the locator lets the
32
+ agent pull the original back.
33
+
34
+ The evidence behind those choices is in [docs/research.md](docs/research.md).
35
+
36
+ ## Install
37
+
38
+ The plugin is one row. Add it to a profile:
39
+
40
+ ```bash
41
+ dsh plugin --profile <name> add @sagmans/dsh-terse
42
+ ```
43
+
44
+ Or insert it directly in the profile's `cordis.patch.yml`:
45
+
46
+ ```yaml
47
+ - insert:
48
+ - id: terse
49
+ name: '@sagmans/dsh-terse'
50
+ ```
51
+
52
+ The shipped row is in [cordis.patch.yml](cordis.patch.yml).
53
+
54
+ ## Configuration
55
+
56
+ Every field is optional; the shipped defaults are the product.
57
+
58
+ | Field | Default | Meaning |
59
+ |---|---|---|
60
+ | `constitution` | shipped text | Replaces the L1 rule set. |
61
+ | `standing` | shipped text | Replaces the L2 reminder; empty suppresses it. |
62
+ | `shaping` | `true` | Whether L4 runs. |
63
+ | `drift` | see below | L3 thresholds. |
64
+ | `shapingConfig` | see below | L4 bounds. |
65
+
66
+ ```ts
67
+ interface DriftConfig {
68
+ maxReplyTokens: number // 220 reply length above which the prose budget is exceeded
69
+ minReplyTokensToJudge: number // 60 floor below which no reply is judged
70
+ maxProseRatio: number // 0.72 prose ratio above which a long reply is padding
71
+ minJudgeableProseRatio: number // 0.4 below this the reply is code, never judged
72
+ idleStepsBeforeNudge: number // 14 steps with no nudge before the anti-drift backstop fires
73
+ maxNudgesPerTurn: number // 2 hard cap on nudges, and so on their extra steps
74
+ }
75
+
76
+ interface ShapingConfig {
77
+ maxResultChars: number // 12000 threshold above which a result may be elided
78
+ headChars: number // 3000 head kept
79
+ tailChars: number // 1500 tail kept, where error trails live
80
+ duplicateRunMin: number // 4 repeated lines before a run collapses
81
+ }
82
+ ```
83
+
84
+ ## Development
85
+
86
+ ```bash
87
+ pnpm install --frozen-lockfile
88
+ pnpm run typecheck
89
+ pnpm test
90
+ pnpm run build
91
+ ```
92
+
93
+ A profile loads `dist/`, not `src/`; run `pnpm run build` before dogfooding a linked profile.
94
+
95
+ ## Try it in the TUI
96
+
97
+ `scripts/dogfood/run-terse-from-worktree.sh` clones the real `~/.dsh` to a scratch
98
+ directory, mounts this checkout on the real `tui` profile inside the clone, and launches
99
+ it. Every composition input is present — your other bundles, the profile patch, settings,
100
+ themes, credentials — while every write goes to the throwaway clone.
101
+
102
+ ```bash
103
+ ./scripts/dogfood/run-terse-from-worktree.sh # clone, build, launch
104
+ ./scripts/dogfood/run-terse-from-worktree.sh --no-launch # set up, print the command
105
+ ./scripts/dogfood/run-terse-from-worktree.sh --status # show what the clone runs
106
+ ./scripts/dogfood/run-terse-from-worktree.sh --with-sessions
107
+ ./scripts/dogfood/run-terse-from-worktree.sh --clean # remove the clone
108
+ ```
109
+
110
+ What to look for on the surface: the status line shows `injected … terse:standing …` when
111
+ the layer is live. Ask a short factual question (expect one line), ask for code inline
112
+ (expect the full implementation, no elision), and ask something safety-critical (expect
113
+ full prose). Those three cases are the contract; if the code case is trimmed, that is a bug.
114
+
115
+ ## Benchmark
116
+
117
+ `benchmark/benchmark.sh` measures this plugin against a control profile that lacks it. See
118
+ [benchmark/README.md](benchmark/README.md); the neutral home is mandatory, because a
119
+ profile whose global instructions already ask for brevity makes the control terse too.
120
+
121
+ ## License
122
+
123
+ MIT.
@@ -0,0 +1,31 @@
1
+ # dsh-terse — mandatory, always-on terseness for every agent in this profile.
2
+ #
3
+ # One row. It contributes prompt sections/context and rides tool results; it
4
+ # registers no tool, provides no service, gates no call, and never touches the
5
+ # deployment's own system prompt. Mounting the row IS the enabling act: there is
6
+ # no mode and no off switch.
7
+ #
8
+ # Field overrides are optional; the shipped defaults are the product.
9
+ - insert:
10
+ - id: terse
11
+ name: '@sagmans/dsh-terse'
12
+ config:
13
+ # L4 input shaping runs by default. Set false to leave tool output
14
+ # untouched while every output-side and prompt-side layer stays on.
15
+ shaping: true
16
+ # Drift thresholds (L3). Tuned so ordinary answers never trigger; the
17
+ # nudge catches collapse over a long turn, not every long sentence.
18
+ drift:
19
+ maxReplyTokens: 220
20
+ minReplyTokensToJudge: 60
21
+ maxProseRatio: 0.72
22
+ minJudgeableProseRatio: 0.4
23
+ idleStepsBeforeNudge: 14
24
+ maxNudgesPerTurn: 2
25
+ # Input-shaping bounds (L4). The threshold sits well above ordinary tool
26
+ # output so the common case is untouched and pays nothing.
27
+ shapingConfig:
28
+ maxResultChars: 12000
29
+ headChars: 3000
30
+ tailChars: 1500
31
+ duplicateRunMin: 4
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Drift detection: deciding when a reply has broken the terse contract.
3
+ *
4
+ * This module is deliberately free of Cordis and of the harness types. The
5
+ * decision core is a pure function of observed text and counters, so it can be
6
+ * tested exhaustively and reasoned about without a running agent — the same
7
+ * separation `dsh-tui`'s todo guard uses, and the reason its behaviour is
8
+ * inspectable at all.
9
+ *
10
+ * Design stance: **precision over recall**. A false nudge costs a real step and
11
+ * can annoy the model into over-correcting (which costs tokens and can hurt
12
+ * quality). We therefore nudge only on strong, cheap signals, cap the rate hard,
13
+ * and never nudge a short reply. The nudge exists to catch collapse over a long
14
+ * turn, not to police every sentence.
15
+ *
16
+ * @module dsh-terse/drift
17
+ */
18
+ /** Default signal weights and caps for drift detection. */
19
+ export interface DriftConfig {
20
+ /** Reply length, in estimated tokens, above which the prose budget is exceeded. */
21
+ readonly maxReplyTokens: number;
22
+ /** Minimum estimated reply tokens before any structural signal may fire. */
23
+ readonly minReplyTokensToJudge: number;
24
+ /** Prose ratio (0..1) above which a long reply is judged to be padding. */
25
+ readonly maxProseRatio: number;
26
+ /**
27
+ * Prose ratio below which a long reply is treated as code, not prose.
28
+ *
29
+ * Code is never the thing terse mode asks to cut, so a long answer that is
30
+ * mostly code is exempt even when it exceeds the token budget. Without this
31
+ * floor a legitimate multi-line implementation would be flagged for drift,
32
+ * which would train the model to shorten exactly the output that must not be
33
+ * shortened.
34
+ */
35
+ readonly minJudgeableProseRatio: number;
36
+ /** Whole steps that may pass without a nudge before an idle reminder is allowed. */
37
+ readonly idleStepsBeforeNudge: number;
38
+ /** Hard ceiling on nudges per turn; also bounds the extra steps they may cost. */
39
+ readonly maxNudgesPerTurn: number;
40
+ }
41
+ /**
42
+ * Deployment defaults.
43
+ *
44
+ * The reply budget is generous on purpose: measured guidance shows terse output
45
+ * still needs room for real explanation and multi-line code, and a budget tight
46
+ * enough to fire on ordinary answers would cost more in corrections than it
47
+ * saves in output. The idle cadence is the backstop for turns that produce no
48
+ * long reply at all but still drift.
49
+ */
50
+ export declare const DRIFT_DEFAULTS: DriftConfig;
51
+ /** A very small, dependency-free token estimate. */
52
+ export interface ReplyShape {
53
+ /** Estimated token count. */
54
+ readonly tokens: number;
55
+ /** Non-whitespace characters. */
56
+ readonly chars: number;
57
+ /** Count of prose characters (outside fenced code and inline code). */
58
+ readonly proseChars: number;
59
+ /** Count of fenced code blocks. */
60
+ readonly fencedBlocks: number;
61
+ }
62
+ /** Whether a reply trips the drift signal, and which one, for logs and tests. */
63
+ export type DriftSignal = 'length' | 'prose' | 'idle' | undefined;
64
+ /**
65
+ * Estimate the shape of one assistant reply.
66
+ *
67
+ * The estimate is intentionally crude: tokenizers differ, a real count would
68
+ * require loading one, and the thresholds are wide enough that a 4-chars-per-
69
+ * token approximation never changes the decision. What matters is separating
70
+ * prose from code, because code is never the thing we ask the model to cut.
71
+ */
72
+ export declare function replyShape(text: string): ReplyShape;
73
+ /**
74
+ * Judge one reply.
75
+ *
76
+ * A reply is too long when it exceeds the token budget AND is mostly prose;
77
+ * both must hold, so a long but necessary code answer is never punished. A reply
78
+ * below the judging floor is never judged, which keeps short clarifying answers
79
+ * exempt.
80
+ *
81
+ * @param text - the assistant reply text.
82
+ * @param config - resolved drift configuration.
83
+ * @returns the signal that fired, or undefined to stay silent.
84
+ */
85
+ export declare function judgeReply(text: string, config: DriftConfig): DriftSignal;
86
+ /** Per-session counters, bounded by the object's own lifetime. */
87
+ export interface DriftCounters {
88
+ /** Model steps observed in the current turn. */
89
+ steps: number;
90
+ /** Nudges already emitted in the current turn. */
91
+ nudges: number;
92
+ /** Whether this step already carried a nudge, so one step never gets two. */
93
+ nudgedThisStep: boolean;
94
+ /** Steps since the last nudge of any kind. */
95
+ stepsSinceNudge: number;
96
+ }
97
+ /** A fresh counter set. */
98
+ export declare function initialCounters(): DriftCounters;
99
+ /**
100
+ * Advance counters for one durable session event.
101
+ *
102
+ * Turn boundaries reset the per-turn budget; step boundaries reset the per-step
103
+ * flag. Counting steps rather than tool calls means one parallel batch is one
104
+ * step, so a batch can never spend the whole nudge budget at once.
105
+ *
106
+ * @param counters - counters to mutate.
107
+ * @param type - durable session event type.
108
+ */
109
+ export declare function advance(counters: DriftCounters, type: string): void;
110
+ /**
111
+ * Decide whether this step should carry a nudge.
112
+ *
113
+ * Both triggers share one budget and one per-step slot, so a length signal and
114
+ * an idle signal can never double up. Idle only fires once a long stretch of
115
+ * steps has passed with no nudge at all, which is the anti-drift backstop for
116
+ * turns whose replies each stayed just under budget.
117
+ *
118
+ * @param counters - current counters; mutated when a nudge is granted.
119
+ * @param reply - the latest assistant reply text, when one was observed.
120
+ * @param config - resolved drift configuration.
121
+ * @returns whether to emit the nudge this step.
122
+ */
123
+ export declare function shouldNudge(counters: DriftCounters, reply: string | undefined, config: DriftConfig): boolean;
124
+ /** Validate and apply defaults; fail loud rather than silently guard nothing. */
125
+ export declare function resolveDriftConfig(config?: Partial<DriftConfig>): DriftConfig;
126
+ //# sourceMappingURL=drift.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drift.d.ts","sourceRoot":"","sources":["../src/drift.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,2DAA2D;AAC3D,MAAM,WAAW,WAAW;IAC1B,mFAAmF;IACnF,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAA;IACtC,2EAA2E;IAC3E,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B;;;;;;;;OAQG;IACH,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAA;IACvC,oFAAoF;IACpF,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;IACrC,kFAAkF;IAClF,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;CAClC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,EAAE,WAO5B,CAAA;AAED,oDAAoD;AACpD,MAAM,WAAW,UAAU;IACzB,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,iCAAiC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,uEAAuE;IACvE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,mCAAmC;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAC9B;AAED,iFAAiF;AACjF,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;AAEjE;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAgBnD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,WAAW,CAUzE;AAED,kEAAkE;AAClE,MAAM,WAAW,aAAa;IAC5B,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAA;IACb,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAA;IACd,6EAA6E;IAC7E,cAAc,EAAE,OAAO,CAAA;IACvB,8CAA8C;IAC9C,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,2BAA2B;AAC3B,wBAAgB,eAAe,IAAI,aAAa,CAE/C;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAanE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAS5G;AAED,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM,GAAG,WAAW,CAkBjF"}
package/dist/drift.js ADDED
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Drift detection: deciding when a reply has broken the terse contract.
3
+ *
4
+ * This module is deliberately free of Cordis and of the harness types. The
5
+ * decision core is a pure function of observed text and counters, so it can be
6
+ * tested exhaustively and reasoned about without a running agent — the same
7
+ * separation `dsh-tui`'s todo guard uses, and the reason its behaviour is
8
+ * inspectable at all.
9
+ *
10
+ * Design stance: **precision over recall**. A false nudge costs a real step and
11
+ * can annoy the model into over-correcting (which costs tokens and can hurt
12
+ * quality). We therefore nudge only on strong, cheap signals, cap the rate hard,
13
+ * and never nudge a short reply. The nudge exists to catch collapse over a long
14
+ * turn, not to police every sentence.
15
+ *
16
+ * @module dsh-terse/drift
17
+ */
18
+ /**
19
+ * Deployment defaults.
20
+ *
21
+ * The reply budget is generous on purpose: measured guidance shows terse output
22
+ * still needs room for real explanation and multi-line code, and a budget tight
23
+ * enough to fire on ordinary answers would cost more in corrections than it
24
+ * saves in output. The idle cadence is the backstop for turns that produce no
25
+ * long reply at all but still drift.
26
+ */
27
+ export const DRIFT_DEFAULTS = {
28
+ maxReplyTokens: 220,
29
+ minReplyTokensToJudge: 60,
30
+ maxProseRatio: 0.72,
31
+ minJudgeableProseRatio: 0.4,
32
+ idleStepsBeforeNudge: 14,
33
+ maxNudgesPerTurn: 2,
34
+ };
35
+ /**
36
+ * Estimate the shape of one assistant reply.
37
+ *
38
+ * The estimate is intentionally crude: tokenizers differ, a real count would
39
+ * require loading one, and the thresholds are wide enough that a 4-chars-per-
40
+ * token approximation never changes the decision. What matters is separating
41
+ * prose from code, because code is never the thing we ask the model to cut.
42
+ */
43
+ export function replyShape(text) {
44
+ const chars = text.replace(/\s/g, '').length;
45
+ // Fenced blocks, then inline spans, are removed before prose is measured:
46
+ // compression must never touch code, so code must never raise the prose ratio.
47
+ const withoutFences = text.replace(/```[\s\S]*?```/g, (block) => {
48
+ return '';
49
+ });
50
+ const inlineStripped = withoutFences.replace(/`[^`\n]*`/g, '');
51
+ const proseChars = inlineStripped.replace(/\s/g, '').length;
52
+ const fencedBlocks = (text.match(/```/g)?.length ?? 0) / 2;
53
+ return {
54
+ tokens: Math.ceil(chars / 4),
55
+ chars,
56
+ proseChars,
57
+ fencedBlocks: Math.floor(fencedBlocks),
58
+ };
59
+ }
60
+ /**
61
+ * Judge one reply.
62
+ *
63
+ * A reply is too long when it exceeds the token budget AND is mostly prose;
64
+ * both must hold, so a long but necessary code answer is never punished. A reply
65
+ * below the judging floor is never judged, which keeps short clarifying answers
66
+ * exempt.
67
+ *
68
+ * @param text - the assistant reply text.
69
+ * @param config - resolved drift configuration.
70
+ * @returns the signal that fired, or undefined to stay silent.
71
+ */
72
+ export function judgeReply(text, config) {
73
+ const shape = replyShape(text);
74
+ if (shape.tokens < config.minReplyTokensToJudge)
75
+ return undefined;
76
+ if (shape.tokens <= config.maxReplyTokens)
77
+ return undefined;
78
+ const proseRatio = shape.chars === 0 ? 0 : shape.proseChars / shape.chars;
79
+ // Mostly-code replies are exempt regardless of length: the budget governs
80
+ // prose, and flagging code would erode the very output quality terse mode
81
+ // promises to preserve.
82
+ if (proseRatio < config.minJudgeableProseRatio)
83
+ return undefined;
84
+ return proseRatio > config.maxProseRatio ? 'prose' : 'length';
85
+ }
86
+ /** A fresh counter set. */
87
+ export function initialCounters() {
88
+ return { steps: 0, nudges: 0, nudgedThisStep: false, stepsSinceNudge: 0 };
89
+ }
90
+ /**
91
+ * Advance counters for one durable session event.
92
+ *
93
+ * Turn boundaries reset the per-turn budget; step boundaries reset the per-step
94
+ * flag. Counting steps rather than tool calls means one parallel batch is one
95
+ * step, so a batch can never spend the whole nudge budget at once.
96
+ *
97
+ * @param counters - counters to mutate.
98
+ * @param type - durable session event type.
99
+ */
100
+ export function advance(counters, type) {
101
+ if (type === 'turn/start') {
102
+ counters.steps = 0;
103
+ counters.nudges = 0;
104
+ counters.nudgedThisStep = false;
105
+ counters.stepsSinceNudge = 0;
106
+ return;
107
+ }
108
+ if (type === 'step/start') {
109
+ counters.steps += 1;
110
+ counters.nudgedThisStep = false;
111
+ counters.stepsSinceNudge += 1;
112
+ }
113
+ }
114
+ /**
115
+ * Decide whether this step should carry a nudge.
116
+ *
117
+ * Both triggers share one budget and one per-step slot, so a length signal and
118
+ * an idle signal can never double up. Idle only fires once a long stretch of
119
+ * steps has passed with no nudge at all, which is the anti-drift backstop for
120
+ * turns whose replies each stayed just under budget.
121
+ *
122
+ * @param counters - current counters; mutated when a nudge is granted.
123
+ * @param reply - the latest assistant reply text, when one was observed.
124
+ * @param config - resolved drift configuration.
125
+ * @returns whether to emit the nudge this step.
126
+ */
127
+ export function shouldNudge(counters, reply, config) {
128
+ if (counters.nudgedThisStep || counters.nudges >= config.maxNudgesPerTurn)
129
+ return false;
130
+ const signal = reply === undefined ? undefined : judgeReply(reply, config);
131
+ const idle = counters.stepsSinceNudge >= config.idleStepsBeforeNudge;
132
+ if (signal === undefined && !idle)
133
+ return false;
134
+ counters.nudges += 1;
135
+ counters.nudgedThisStep = true;
136
+ counters.stepsSinceNudge = 0;
137
+ return true;
138
+ }
139
+ /** Validate and apply defaults; fail loud rather than silently guard nothing. */
140
+ export function resolveDriftConfig(config = {}) {
141
+ return {
142
+ maxReplyTokens: positive('maxReplyTokens', config.maxReplyTokens ?? DRIFT_DEFAULTS.maxReplyTokens),
143
+ minReplyTokensToJudge: positive('minReplyTokensToJudge', config.minReplyTokensToJudge ?? DRIFT_DEFAULTS.minReplyTokensToJudge),
144
+ maxProseRatio: ratio('maxProseRatio', config.maxProseRatio ?? DRIFT_DEFAULTS.maxProseRatio),
145
+ minJudgeableProseRatio: ratio('minJudgeableProseRatio', config.minJudgeableProseRatio ?? DRIFT_DEFAULTS.minJudgeableProseRatio),
146
+ idleStepsBeforeNudge: positive('idleStepsBeforeNudge', config.idleStepsBeforeNudge ?? DRIFT_DEFAULTS.idleStepsBeforeNudge),
147
+ maxNudgesPerTurn: positive('maxNudgesPerTurn', config.maxNudgesPerTurn ?? DRIFT_DEFAULTS.maxNudgesPerTurn),
148
+ };
149
+ }
150
+ function positive(field, value) {
151
+ if (!Number.isFinite(value) || value < 1) {
152
+ throw new Error(`dsh-terse: \`${field}\` must be a number >= 1 (got ${String(value)})`);
153
+ }
154
+ return value;
155
+ }
156
+ function ratio(field, value) {
157
+ if (!Number.isFinite(value) || value <= 0 || value > 1) {
158
+ throw new Error(`dsh-terse: \`${field}\` must be in (0, 1] (got ${String(value)})`);
159
+ }
160
+ return value;
161
+ }
162
+ //# sourceMappingURL=drift.js.map
@@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,CAAC,gBAAgB,IAAI,cAAc,CAAC,gBAAgB,CAAC;KAC3G,CAAA;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,KAAa;IAC5C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,gBAAgB,KAAK,iCAAiC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACzF,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,KAAK,CAAC,KAAa,EAAE,KAAa;IACzC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,gBAAgB,KAAK,6BAA6B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACrF,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * dsh-terse — mandatory, always-on terseness for DeepSeek Harness agents.
3
+ *
4
+ * The plugin compresses everything the agent *emits* and everything it *reads*,
5
+ * without touching the deployment's own system prompt: it contributes sections
6
+ * and context and lets the prompt registry compose, exactly as DeepSeek's own
7
+ * first-party rows do. There is no mode and no off switch; mounting the row is
8
+ * the enabling act.
9
+ *
10
+ * Six layers, each mapped to one harness extension point:
11
+ *
12
+ * - L1 constitution -> `systemPrompt.section` (static, cache-stable)
13
+ * - L2 standing -> `systemPrompt.context` (durable snapshot, survives compaction)
14
+ * - L3 nudge + drift -> `tools/post-execute` `additionalContexts` (rides a result)
15
+ * - L4 input shaping -> `tools/post-execute` content replacement (reversible)
16
+ * - L5 enforcement -> `system-prompt/assemble` (observe + log, never rewrite peers)
17
+ * - L6 coverage -> per-session state keyed by the session object
18
+ *
19
+ * @module dsh-terse
20
+ */
21
+ import type { Context } from '@deepseek-ai/cordis';
22
+ import z from '@deepseek-ai/schemastery';
23
+ import { type DriftConfig } from './drift.ts';
24
+ import { type ShapingConfig } from './shaping.ts';
25
+ /** The plugin row name, used for provenance on every message it injects. */
26
+ export declare const name = "dsh-terse";
27
+ /** The prompt registry is required; otherwise the constitution has nowhere to land. */
28
+ export declare const inject: string[];
29
+ /** Config accepted from the profile patch; every field is a tuning knob. */
30
+ export interface Config {
31
+ /** Static constitution text; overriding it replaces the shipped wording. */
32
+ readonly constitution?: string;
33
+ /** Standing reminder text; empty suppresses L2 entirely. */
34
+ readonly standing?: string;
35
+ /** Whether the L4 input shaper runs. Defaults to true. */
36
+ readonly shaping?: boolean;
37
+ /** Drift-detection thresholds. */
38
+ readonly drift?: Partial<DriftConfig>;
39
+ /** Input-shaping bounds. */
40
+ readonly shapingConfig?: Partial<ShapingConfig>;
41
+ }
42
+ /** Loader-validated config schema; omitted fields fall back to the shipped defaults. */
43
+ export declare const Config: z<Config>;
44
+ /**
45
+ * Install every layer.
46
+ *
47
+ * Registration order does not affect correctness because each layer attaches to
48
+ * a different extension point, but it is kept L1..L6 to match the documentation.
49
+ *
50
+ * @param ctx - the plugin's Cordis context.
51
+ * @param config - optional tuning; the shipped defaults are the product.
52
+ */
53
+ export declare function apply(ctx: Context, config?: Config): void;
54
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AASxC,OAAO,EAKL,KAAK,WAAW,EAEjB,MAAM,YAAY,CAAA;AACnB,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,cAAc,CAAA;AAErB,4EAA4E;AAC5E,eAAO,MAAM,IAAI,cAAc,CAAA;AAE/B,uFAAuF;AACvF,eAAO,MAAM,MAAM,UAAmB,CAAA;AAEtC,4EAA4E;AAC5E,MAAM,WAAW,MAAM;IACrB,4EAA4E;IAC5E,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,kCAAkC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IACrC,4BAA4B;IAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;CAChD;AAED,wFAAwF;AACxF,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAM3B,CAAA;AAmBF;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CA8D7D"}
package/dist/index.js ADDED
@@ -0,0 +1,185 @@
1
+ import { createUserMessage } from '@deepseek-ai/dsh-llm';
2
+ import z from '@deepseek-ai/schemastery';
3
+ import { CONSTITUTION, CONSTITUTION_ORDER, DRIFT_NUDGE, DRIFT_NUDGE_SUMMARY, STANDING_ORDER, STANDING_REMINDER, } from "./instructions.js";
4
+ import { advance, initialCounters, resolveDriftConfig, shouldNudge, } from "./drift.js";
5
+ import { resolveShapingConfig, shapeText, textOf, } from "./shaping.js";
6
+ /** The plugin row name, used for provenance on every message it injects. */
7
+ export const name = 'dsh-terse';
8
+ /** The prompt registry is required; otherwise the constitution has nowhere to land. */
9
+ export const inject = ['systemPrompt'];
10
+ /** Loader-validated config schema; omitted fields fall back to the shipped defaults. */
11
+ export const Config = z.object({
12
+ constitution: z.string(),
13
+ standing: z.string(),
14
+ shaping: z.boolean().default(true),
15
+ drift: z.object({}),
16
+ shapingConfig: z.object({}),
17
+ });
18
+ /**
19
+ * The frame that states the contract's standing, mirroring first-party context.
20
+ *
21
+ * The precedence sentence is load-bearing: it keeps a style rule from being read
22
+ * as an override of real instructions, which is the one way an always-on prompt
23
+ * contribution could do harm.
24
+ */
25
+ const STANDING_INTRO = 'The following output contract is active for every reply in this session. It does not override system, developer, or direct user instructions.';
26
+ /**
27
+ * Install every layer.
28
+ *
29
+ * Registration order does not affect correctness because each layer attaches to
30
+ * a different extension point, but it is kept L1..L6 to match the documentation.
31
+ *
32
+ * @param ctx - the plugin's Cordis context.
33
+ * @param config - optional tuning; the shipped defaults are the product.
34
+ */
35
+ export function apply(ctx, config = {}) {
36
+ const driftConfig = resolveDriftConfig(config.drift ?? {});
37
+ const shapingConfig = resolveShapingConfig(config.shapingConfig ?? {});
38
+ const shaping = config.shaping ?? true;
39
+ const states = new WeakMap();
40
+ const stateFor = (session) => {
41
+ let state = states.get(session);
42
+ if (state === undefined) {
43
+ state = { counters: initialCounters(), lastReply: undefined };
44
+ states.set(session, state);
45
+ }
46
+ return state;
47
+ };
48
+ // L1 — the immutable constitution. Static text keeps the provider prefix
49
+ // reusable, which is what lets an always-on rule set pay for itself.
50
+ ctx.systemPrompt.section({
51
+ name: 'terse:constitution',
52
+ order: CONSTITUTION_ORDER,
53
+ text: () => config.constitution ?? CONSTITUTION,
54
+ });
55
+ // L2 — the durable standing reminder. Delivered through the context channel so
56
+ // it is re-materialized after compaction, where a system-only rule fades.
57
+ const standing = config.standing ?? STANDING_REMINDER;
58
+ if (standing !== '') {
59
+ ctx.systemPrompt.context({
60
+ name: 'terse:standing',
61
+ order: STANDING_ORDER,
62
+ text: () => `${STANDING_INTRO}\n\n${standing}`,
63
+ });
64
+ }
65
+ // L6 — follow durable events for turn/step cadence and the latest committed
66
+ // assistant text. Reading the committed message (not the live stream) means a
67
+ // retry or a cancelled stream cannot double-count, and the judge sees exactly
68
+ // what entered history.
69
+ ctx.on('session/event', (session, event) => {
70
+ const state = stateFor(session);
71
+ advance(state.counters, event.type);
72
+ if (event.type === 'assistant/message') {
73
+ const reply = assistantTextOf(event.data);
74
+ if (reply !== undefined)
75
+ state.lastReply = reply;
76
+ }
77
+ });
78
+ // L5 — observe the final assembly. A style contribution has no business
79
+ // rewriting what peer plugins published, so this layer only asserts the
80
+ // constitution survived assembly and otherwise defers; it exists so a future
81
+ // enforcement rule has one obvious home and so a mis-ordered contribution is
82
+ // visible in logs rather than silent.
83
+ ctx.on('system-prompt/assemble', async (assembly, _context, next) => {
84
+ const resolved = await next();
85
+ const present = resolved.sections.some((section) => section.name === 'terse:constitution');
86
+ if (!present) {
87
+ ctx.logger.warn('dsh-terse: constitution section missing from assembly; terseness rules are not reaching the model');
88
+ }
89
+ return resolved;
90
+ });
91
+ installPostExecute(ctx, stateFor, driftConfig, shaping ? shapingConfig : undefined);
92
+ }
93
+ /**
94
+ * Extract plain text from one `assistant/message` event payload.
95
+ *
96
+ * The payload is event data rather than a typed message, so it is narrowed
97
+ * defensively: an unexpected shape yields undefined and simply leaves the last
98
+ * observed reply in place, which degrades to the idle trigger instead of
99
+ * throwing inside an event observer (where harness failures are contained, but
100
+ * a silent no-op is still better than a log line per message).
101
+ */
102
+ function assistantTextOf(data) {
103
+ if (typeof data !== 'object' || data === null)
104
+ return undefined;
105
+ const message = data.message;
106
+ if (typeof message !== 'object' || message === null)
107
+ return undefined;
108
+ const content = message.content;
109
+ if (!Array.isArray(content))
110
+ return undefined;
111
+ return textOf(content);
112
+ }
113
+ /**
114
+ * Install the post-execute waterfall that both rides nudges and shapes results.
115
+ *
116
+ * One listener serves both layers because both act on the same result and the
117
+ * waterfall must call `next()` exactly once. Keeping them together is what makes
118
+ * "observe before delegate" and "shape after delegate" correct in a single pass.
119
+ *
120
+ * @param ctx - plugin context.
121
+ * @param stateFor - per-session state accessor.
122
+ * @param driftConfig - resolved drift thresholds.
123
+ * @param shapingConfig - resolved shaping bounds, or undefined when shaping is off.
124
+ */
125
+ function installPostExecute(ctx, stateFor, driftConfig, shapingConfig) {
126
+ ctx.on('tools/post-execute', async (exec, result, next) => {
127
+ const session = exec.agent?.session;
128
+ const state = session === undefined ? undefined : stateFor(session);
129
+ // Decide the nudge BEFORE delegating, so a downstream block cannot hide
130
+ // that the step happened; the reminder then rides whatever decision returns.
131
+ // A concluding result ends the turn, so a nudge there would only buy an
132
+ // extra step after the tools have wound down.
133
+ const nudging = state !== undefined && result.concludesTurn !== true && shouldNudge(state.counters, state.lastReply, driftConfig);
134
+ const downstream = await next();
135
+ const shaped = shapingConfig === undefined ? undefined : shapeResult(downstream, result, shapingConfig);
136
+ const accepted = shaped ?? downstream;
137
+ return nudging ? foldNudge(accepted, nudgeMessage()) : accepted;
138
+ });
139
+ }
140
+ /**
141
+ * Replace the accepted content projection with a shaped one, when the result is
142
+ * a text-only success and shaping actually shrinks it.
143
+ *
144
+ * Only an `accept` decision is reshaped: a `block` already replaced the
145
+ * projection with corrective feedback and must keep it. Errors are never shaped
146
+ * even though the candidate content of a failure is often text — the decisive
147
+ * line of a failure is frequently the tail, and the cheap lost saving is not
148
+ * worth a wrong cut.
149
+ *
150
+ * @returns the reshaped decision, or undefined when nothing should change.
151
+ */
152
+ function shapeResult(downstream, result, config) {
153
+ if (downstream.kind !== 'accept')
154
+ return undefined;
155
+ if (result.isError === true)
156
+ return undefined;
157
+ const original = downstream.content ?? result.content;
158
+ const text = textOf(original);
159
+ if (text === undefined)
160
+ return undefined;
161
+ const shaped = shapeText(text, config);
162
+ if (!shaped.changed)
163
+ return undefined;
164
+ // Rebuilt rather than spread because the accept union forbids `content` on the
165
+ // `value` arm; naming the fields keeps this on the content arm by construction.
166
+ const rebuilt = { kind: 'accept', content: [{ type: 'text', text: shaped.text }] };
167
+ const contexts = downstream.additionalContexts;
168
+ return contexts === undefined ? rebuilt : { ...rebuilt, additionalContexts: contexts };
169
+ }
170
+ /** Build the model-facing nudge message, tagged so history attributes it here. */
171
+ function nudgeMessage() {
172
+ return createUserMessage({
173
+ content: [{ type: 'text', text: DRIFT_NUDGE }],
174
+ source: { kind: 'plugin', plugin: name, form: 'notice', summary: DRIFT_NUDGE_SUMMARY },
175
+ });
176
+ }
177
+ /** Prepend this step's nudge while preserving every downstream context's own source. */
178
+ function foldNudge(downstream, nudge) {
179
+ const contexts = [nudge, ...(downstream.additionalContexts ?? [])];
180
+ if (downstream.kind === 'block') {
181
+ return { kind: 'block', feedback: downstream.feedback, additionalContexts: contexts };
182
+ }
183
+ return { ...downstream, additionalContexts: contexts };
184
+ }
185
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAIxD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,WAAW,GAGZ,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,oBAAoB,EACpB,SAAS,EACT,MAAM,GAEP,MAAM,cAAc,CAAA;AAErB,4EAA4E;AAC5E,MAAM,CAAC,MAAM,IAAI,GAAG,WAAW,CAAA;AAE/B,uFAAuF;AACvF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,cAAc,CAAC,CAAA;AAgBtC,wFAAwF;AACxF,MAAM,CAAC,MAAM,MAAM,GAAc,CAAC,CAAC,MAAM,CAAC;IACxC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAClC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IACnB,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;CAC5B,CAAC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AAI,EAAE,WAAW,EAAE,CAAC;QAC9C,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,mBAAmB,EAAE;KACvF,CAAC,CAAA;AACJ,CAAC;AAED,wFAAwF;AACxF,SAAS,SAAS,CAAC,UAA4B,EAAE,KAAkB;IACjE,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,UAAU,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,CAAA;IAClE,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAChC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAA;IACvF,CAAC;IACD,OAAO,EAAE,GAAG,UAAU,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAA;AACxD,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * The terse constitution and its runtime fragments.
3
+ *
4
+ * Every string here is model-facing and costs input tokens on EVERY request, so
5
+ * each rule must buy back more than it costs. Three properties are non-negotiable
6
+ * and are why this file is mostly one composed constant rather than prose spread
7
+ * across modules:
8
+ *
9
+ * - Cache stability: the constitution renders identically every turn, so it
10
+ * stays inside the provider's reusable prefix. Anything variable lives in the
11
+ * runtime reminder or the event-driven nudge instead.
12
+ * - Meaning preservation: the never-cut list protects exactly the token classes
13
+ * whose loss flips semantics (negation, quantity, identifiers, exact errors).
14
+ * - Quality preservation: compression applies to the chat mouth only; durable
15
+ * artifacts and ambiguity-sensitive answers escalate back to full prose. This
16
+ * is what lets aggression rise without a quality cost.
17
+ *
18
+ * @module dsh-terse/instructions
19
+ */
20
+ /**
21
+ * Where the constitution sits in the prompt.
22
+ *
23
+ * External contributions may use any finite order, so we pick a slot inside the
24
+ * first-party guidance band and BEFORE the tool sections (the lowest tool order
25
+ * is TOOL_BASH = 1000). Sitting just ahead of the tool instructions keeps the
26
+ * style rules adjacent to the environment they govern, while leaving the sparse
27
+ * named first-party orders untouched — we never hijack a reserved position.
28
+ */
29
+ export declare const CONSTITUTION_ORDER = 980;
30
+ /**
31
+ * Where the standing reminder sits among dynamic contexts.
32
+ *
33
+ * Contexts are joined in ascending order; the first-party context orders start
34
+ * at SANDBOX_POLICY = 110. A lower number renders the reminder first, so the
35
+ * agent reads the output contract before the safety and approval facts that
36
+ * qualify it.
37
+ */
38
+ export declare const STANDING_ORDER = 10;
39
+ /**
40
+ * The immutable core rules.
41
+ *
42
+ * Ordered by how much each rule protects: substance preservation first, then
43
+ * compression mechanics, then escalation. A rule that is not needed to bind
44
+ * behaviour is not here — brevity in the instruction is itself the first
45
+ * demonstration of the instruction.
46
+ */
47
+ export declare const CONSTITUTION = "Compress prose; substance exact. Drop articles, filler, pleasantries, hedging; fragments OK.\nNo preamble, recap, or closing. One idea per sentence, <=20 words; active voice.\n\nNever cut: not, never, no, only, except; numbers; units; identifiers; paths; commands; flags;\nexact error strings. Losing one changes meaning and costs more than it saves.\n\nNever invent abbreviations or arrows to sound terse; if terse is not shorter than plain, use\nplain. Skip narration, progress notes, restating the request, recaps, emoji, decorative tables;\ncall tools directly, with text before a call only to warn, disambiguate, or answer.\n\nCompress form, never substance. Keep every fact, cause, and step a reader needs to act; cut only\nthe words around them. A short question gets a short answer; do not turn it into an essay, a\nfile, or a project. Shape: [thing] [action] [reason]. Quote the decisive line, not the log.\n\nFull prose ONLY for security warnings, irreversible-action confirmations, order-sensitive\nmulti-step sequences, and real ambiguity - conditions an outside reader could check, not a\nfeeling the topic deserves room. Explaining or being asked for detail is not an exception.\n\nCode keeps normal formatting and full length, in a file or in chat: never shorten an\nimplementation, drop a case, or elide a body. Commits, docs, issue/PR text, and messages to other\nhumans stay normal prose.\n\nConstruct: first rung that holds - need it? already here? stdlib? native? installed dep? one\nline? else the minimum that works. Never cut validation, error handling, security, accessibility,\nor tests that are required; build only what was asked, with no unrequested options, abstractions,\nhelpers, or config.";
48
+ /**
49
+ * The durable standing reminder.
50
+ *
51
+ * Re-materialized on every assembly as a sourced user-role snapshot, so it
52
+ * survives compaction and long-context dilution where a system section alone
53
+ * fades. Kept to one line and changed only on real state change to avoid
54
+ * disturbing the cached prefix.
55
+ */
56
+ export declare const STANDING_REMINDER = "<system-reminder>dsh-terse active: keep replies compressed; code, paths, commands, and exact errors verbatim.</system-reminder>";
57
+ /**
58
+ * The event-driven nudge.
59
+ *
60
+ * Rides a tool result at the user position — the most-attended position near
61
+ * generation time — and stays under the notice summary bound. It states the
62
+ * omission, not a lecture, so it steers without spending a turn.
63
+ */
64
+ export declare const DRIFT_NUDGE = "<system-reminder>dsh-terse: reply ran long. Compress prose; keep code, paths, commands, and exact errors exact.</system-reminder>";
65
+ /**
66
+ * One-line account shown on the collapsed transcript row for a nudge.
67
+ *
68
+ * A `notice` source requires this; it is human-facing, bounded to 120 chars,
69
+ * and never reaches the model, so it may name the guard plainly.
70
+ */
71
+ export declare const DRIFT_NUDGE_SUMMARY = "terse drift \u00B7 reply over budget";
72
+ //# sourceMappingURL=instructions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAA;AAErC;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,KAAK,CAAA;AAEhC;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,8rDAyBL,CAAA;AAEpB;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,oIACqG,CAAA;AAEnI;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,sIAC6G,CAAA;AAErI;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,yCAAoC,CAAA"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * The terse constitution and its runtime fragments.
3
+ *
4
+ * Every string here is model-facing and costs input tokens on EVERY request, so
5
+ * each rule must buy back more than it costs. Three properties are non-negotiable
6
+ * and are why this file is mostly one composed constant rather than prose spread
7
+ * across modules:
8
+ *
9
+ * - Cache stability: the constitution renders identically every turn, so it
10
+ * stays inside the provider's reusable prefix. Anything variable lives in the
11
+ * runtime reminder or the event-driven nudge instead.
12
+ * - Meaning preservation: the never-cut list protects exactly the token classes
13
+ * whose loss flips semantics (negation, quantity, identifiers, exact errors).
14
+ * - Quality preservation: compression applies to the chat mouth only; durable
15
+ * artifacts and ambiguity-sensitive answers escalate back to full prose. This
16
+ * is what lets aggression rise without a quality cost.
17
+ *
18
+ * @module dsh-terse/instructions
19
+ */
20
+ /**
21
+ * Where the constitution sits in the prompt.
22
+ *
23
+ * External contributions may use any finite order, so we pick a slot inside the
24
+ * first-party guidance band and BEFORE the tool sections (the lowest tool order
25
+ * is TOOL_BASH = 1000). Sitting just ahead of the tool instructions keeps the
26
+ * style rules adjacent to the environment they govern, while leaving the sparse
27
+ * named first-party orders untouched — we never hijack a reserved position.
28
+ */
29
+ export const CONSTITUTION_ORDER = 980;
30
+ /**
31
+ * Where the standing reminder sits among dynamic contexts.
32
+ *
33
+ * Contexts are joined in ascending order; the first-party context orders start
34
+ * at SANDBOX_POLICY = 110. A lower number renders the reminder first, so the
35
+ * agent reads the output contract before the safety and approval facts that
36
+ * qualify it.
37
+ */
38
+ export const STANDING_ORDER = 10;
39
+ /**
40
+ * The immutable core rules.
41
+ *
42
+ * Ordered by how much each rule protects: substance preservation first, then
43
+ * compression mechanics, then escalation. A rule that is not needed to bind
44
+ * behaviour is not here — brevity in the instruction is itself the first
45
+ * demonstration of the instruction.
46
+ */
47
+ export const CONSTITUTION = `Compress prose; substance exact. Drop articles, filler, pleasantries, hedging; fragments OK.
48
+ No preamble, recap, or closing. One idea per sentence, <=20 words; active voice.
49
+
50
+ Never cut: not, never, no, only, except; numbers; units; identifiers; paths; commands; flags;
51
+ exact error strings. Losing one changes meaning and costs more than it saves.
52
+
53
+ Never invent abbreviations or arrows to sound terse; if terse is not shorter than plain, use
54
+ plain. Skip narration, progress notes, restating the request, recaps, emoji, decorative tables;
55
+ call tools directly, with text before a call only to warn, disambiguate, or answer.
56
+
57
+ Compress form, never substance. Keep every fact, cause, and step a reader needs to act; cut only
58
+ the words around them. A short question gets a short answer; do not turn it into an essay, a
59
+ file, or a project. Shape: [thing] [action] [reason]. Quote the decisive line, not the log.
60
+
61
+ Full prose ONLY for security warnings, irreversible-action confirmations, order-sensitive
62
+ multi-step sequences, and real ambiguity - conditions an outside reader could check, not a
63
+ feeling the topic deserves room. Explaining or being asked for detail is not an exception.
64
+
65
+ Code keeps normal formatting and full length, in a file or in chat: never shorten an
66
+ implementation, drop a case, or elide a body. Commits, docs, issue/PR text, and messages to other
67
+ humans stay normal prose.
68
+
69
+ Construct: first rung that holds - need it? already here? stdlib? native? installed dep? one
70
+ line? else the minimum that works. Never cut validation, error handling, security, accessibility,
71
+ or tests that are required; build only what was asked, with no unrequested options, abstractions,
72
+ helpers, or config.`;
73
+ /**
74
+ * The durable standing reminder.
75
+ *
76
+ * Re-materialized on every assembly as a sourced user-role snapshot, so it
77
+ * survives compaction and long-context dilution where a system section alone
78
+ * fades. Kept to one line and changed only on real state change to avoid
79
+ * disturbing the cached prefix.
80
+ */
81
+ export const STANDING_REMINDER = `<system-reminder>dsh-terse active: keep replies compressed; code, paths, commands, and exact errors verbatim.</system-reminder>`;
82
+ /**
83
+ * The event-driven nudge.
84
+ *
85
+ * Rides a tool result at the user position — the most-attended position near
86
+ * generation time — and stays under the notice summary bound. It states the
87
+ * omission, not a lecture, so it steers without spending a turn.
88
+ */
89
+ export const DRIFT_NUDGE = `<system-reminder>dsh-terse: reply ran long. Compress prose; keep code, paths, commands, and exact errors exact.</system-reminder>`;
90
+ /**
91
+ * One-line account shown on the collapsed transcript row for a nudge.
92
+ *
93
+ * A `notice` source requires this; it is human-facing, bounded to 120 chars,
94
+ * and never reaches the model, so it may name the guard plainly.
95
+ */
96
+ export const DRIFT_NUDGE_SUMMARY = 'terse drift · reply over budget';
97
+ //# sourceMappingURL=instructions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAA;AAErC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAA;AAEhC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;oBAyBR,CAAA;AAEpB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,iIAAiI,CAAA;AAEnI;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GACtB,mIAAmI,CAAA;AAErI;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,iCAAiC,CAAA"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Input shaping: reducing what the agent READS.
3
+ *
4
+ * Output style is the smaller half of the token bill; in agentic sessions most
5
+ * spend is re-reading logs, diffs, search results, and test output. This module
6
+ * shrinks that stream before it reaches the model.
7
+ *
8
+ * Two rules keep this safe enough to be always-on:
9
+ *
10
+ * - Reversible: an elided result always carries a locator (a spill path or a
11
+ * count) so the agent can pull the original back with an ordinary tool call.
12
+ * Nothing is destroyed, only deferred.
13
+ * - Conservative: only *failure-free, block-shaped* content is elided, and only
14
+ * past a size that makes the locator cheaper than the payload. Error output is
15
+ * never shaped, because the decisive line is often the last one and a wrong
16
+ * cut would cost a whole debugging loop.
17
+ *
18
+ * @module dsh-terse/shaping
19
+ */
20
+ /** Bounds for tool-output shaping. */
21
+ export interface ShapingConfig {
22
+ /** Character count above which a candidate result may be elided. */
23
+ readonly maxResultChars: number;
24
+ /** Characters of head kept so the result stays recognizable. */
25
+ readonly headChars: number;
26
+ /** Characters of tail kept, because error trails and totals live at the end. */
27
+ readonly tailChars: number;
28
+ /** Minimum repeated lines before a run is collapsed. */
29
+ readonly duplicateRunMin: number;
30
+ }
31
+ /**
32
+ * Deployment defaults.
33
+ *
34
+ * The threshold sits well above ordinary tool output so the common case is
35
+ * untouched and pays nothing. Head and tail are generous enough that a shaped
36
+ * result still shows what ran and how it ended.
37
+ */
38
+ export declare const SHAPING_DEFAULTS: ShapingConfig;
39
+ /** The shaped text plus what was removed, for the locator line. */
40
+ export interface ShapedText {
41
+ readonly text: string;
42
+ /** Whether shaping actually changed the text. */
43
+ readonly changed: boolean;
44
+ /** Characters removed from the middle, when a middle was removed. */
45
+ readonly elidedChars: number;
46
+ /** Duplicate lines collapsed into run markers. */
47
+ readonly collapsedLines: number;
48
+ }
49
+ /** Collapse long runs of identical lines into one line plus a count. */
50
+ export declare function collapseDuplicateRuns(text: string, minRun: number): {
51
+ text: string;
52
+ collapsed: number;
53
+ };
54
+ /**
55
+ * Apply the cheap, lossless transform first.
56
+ *
57
+ * Duplicate-run collapse is near-lossless (the omitted lines are identical to a
58
+ * kept one) and needs no locator, so it runs unconditionally and often removes
59
+ * enough that the heavier middle-elision never triggers.
60
+ */
61
+ export declare function collapseRuns(text: string, config: ShapingConfig): ShapedText;
62
+ /**
63
+ * Elide the middle of an oversized block, keeping head and tail with a locator.
64
+ *
65
+ * The middle is chosen over the ends on purpose: a command's identity is at the
66
+ * top and its outcome is at the bottom, while the middle of a long log is where
67
+ * repetition lives. The locator names the omission so the agent can re-run or
68
+ * read the original rather than guess.
69
+ *
70
+ * @param text - the already run-collapsed text.
71
+ * @param config - resolved shaping configuration.
72
+ * @returns the shaped text and accounting.
73
+ */
74
+ export declare function elideMiddle(text: string, config: ShapingConfig): ShapedText;
75
+ /** Extract the plain text of a tool result's content blocks, when it is text-only. */
76
+ export declare function textOf(blocks: readonly unknown[]): string | undefined;
77
+ /**
78
+ * Shape one result's text.
79
+ *
80
+ * Collapse first, then elide only if a middle remains over budget. Returning
81
+ * `changed: false` lets the caller leave the original result object untouched,
82
+ * which keeps an unchanged path allocation-free and byte-identical.
83
+ *
84
+ * @param text - the result text.
85
+ * @param config - resolved shaping configuration.
86
+ * @returns the shaped text and accounting.
87
+ */
88
+ export declare function shapeText(text: string, config: ShapingConfig): ShapedText;
89
+ /** Validate and apply defaults; fail loud rather than silently shape nothing. */
90
+ export declare function resolveShapingConfig(config?: Partial<ShapingConfig>): ShapingConfig;
91
+ //# sourceMappingURL=shaping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shaping.d.ts","sourceRoot":"","sources":["../src/shaping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,gFAAgF;IAChF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;CACjC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAK9B,CAAA;AAED,mEAAmE;AACnE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,qEAAqE;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;CAChC;AAED,wEAAwE;AACxE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAmBvG;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,UAAU,CAQ5E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,UAAU,CAS3E;AAED,sFAAsF;AACtF,wBAAgB,MAAM,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,GAAG,SAAS,CASrE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,UAAU,CASzE;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,MAAM,GAAE,OAAO,CAAC,aAAa,CAAM,GAAG,aAAa,CAWvF"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Input shaping: reducing what the agent READS.
3
+ *
4
+ * Output style is the smaller half of the token bill; in agentic sessions most
5
+ * spend is re-reading logs, diffs, search results, and test output. This module
6
+ * shrinks that stream before it reaches the model.
7
+ *
8
+ * Two rules keep this safe enough to be always-on:
9
+ *
10
+ * - Reversible: an elided result always carries a locator (a spill path or a
11
+ * count) so the agent can pull the original back with an ordinary tool call.
12
+ * Nothing is destroyed, only deferred.
13
+ * - Conservative: only *failure-free, block-shaped* content is elided, and only
14
+ * past a size that makes the locator cheaper than the payload. Error output is
15
+ * never shaped, because the decisive line is often the last one and a wrong
16
+ * cut would cost a whole debugging loop.
17
+ *
18
+ * @module dsh-terse/shaping
19
+ */
20
+ /**
21
+ * Deployment defaults.
22
+ *
23
+ * The threshold sits well above ordinary tool output so the common case is
24
+ * untouched and pays nothing. Head and tail are generous enough that a shaped
25
+ * result still shows what ran and how it ended.
26
+ */
27
+ export const SHAPING_DEFAULTS = {
28
+ maxResultChars: 12_000,
29
+ headChars: 3_000,
30
+ tailChars: 1_500,
31
+ duplicateRunMin: 4,
32
+ };
33
+ /** Collapse long runs of identical lines into one line plus a count. */
34
+ export function collapseDuplicateRuns(text, minRun) {
35
+ const lines = text.split('\n');
36
+ const out = [];
37
+ let collapsed = 0;
38
+ let index = 0;
39
+ while (index < lines.length) {
40
+ const line = lines[index] ?? '';
41
+ let end = index + 1;
42
+ while (end < lines.length && lines[end] === line)
43
+ end += 1;
44
+ const run = end - index;
45
+ if (run >= minRun && line.trim() !== '') {
46
+ out.push(`${line}`, ` ... [${run} identical lines omitted by dsh-terse]`);
47
+ collapsed += run - 1;
48
+ }
49
+ else {
50
+ for (let i = index; i < end; i += 1)
51
+ out.push(lines[i] ?? '');
52
+ }
53
+ index = end;
54
+ }
55
+ return { text: out.join('\n'), collapsed };
56
+ }
57
+ /**
58
+ * Apply the cheap, lossless transform first.
59
+ *
60
+ * Duplicate-run collapse is near-lossless (the omitted lines are identical to a
61
+ * kept one) and needs no locator, so it runs unconditionally and often removes
62
+ * enough that the heavier middle-elision never triggers.
63
+ */
64
+ export function collapseRuns(text, config) {
65
+ const collapsed = collapseDuplicateRuns(text, config.duplicateRunMin);
66
+ return {
67
+ text: collapsed.text,
68
+ changed: collapsed.collapsed > 0,
69
+ elidedChars: 0,
70
+ collapsedLines: collapsed.collapsed,
71
+ };
72
+ }
73
+ /**
74
+ * Elide the middle of an oversized block, keeping head and tail with a locator.
75
+ *
76
+ * The middle is chosen over the ends on purpose: a command's identity is at the
77
+ * top and its outcome is at the bottom, while the middle of a long log is where
78
+ * repetition lives. The locator names the omission so the agent can re-run or
79
+ * read the original rather than guess.
80
+ *
81
+ * @param text - the already run-collapsed text.
82
+ * @param config - resolved shaping configuration.
83
+ * @returns the shaped text and accounting.
84
+ */
85
+ export function elideMiddle(text, config) {
86
+ if (text.length <= config.maxResultChars) {
87
+ return { text, changed: false, elidedChars: 0, collapsedLines: 0 };
88
+ }
89
+ const head = text.slice(0, config.headChars);
90
+ const tail = text.slice(text.length - config.tailChars);
91
+ const elided = text.length - head.length - tail.length;
92
+ const marker = `\n... [${elided} characters omitted by dsh-terse; re-run the command or read the source file for the full output] ...\n`;
93
+ return { text: head + marker + tail, changed: true, elidedChars: elided, collapsedLines: 0 };
94
+ }
95
+ /** Extract the plain text of a tool result's content blocks, when it is text-only. */
96
+ export function textOf(blocks) {
97
+ const parts = [];
98
+ for (const block of blocks) {
99
+ if (typeof block !== 'object' || block === null)
100
+ return undefined;
101
+ const record = block;
102
+ if (record.type !== 'text' || typeof record.text !== 'string')
103
+ return undefined;
104
+ parts.push(record.text);
105
+ }
106
+ return parts.length === 0 ? undefined : parts.join('\n');
107
+ }
108
+ /**
109
+ * Shape one result's text.
110
+ *
111
+ * Collapse first, then elide only if a middle remains over budget. Returning
112
+ * `changed: false` lets the caller leave the original result object untouched,
113
+ * which keeps an unchanged path allocation-free and byte-identical.
114
+ *
115
+ * @param text - the result text.
116
+ * @param config - resolved shaping configuration.
117
+ * @returns the shaped text and accounting.
118
+ */
119
+ export function shapeText(text, config) {
120
+ const collapsed = collapseRuns(text, config);
121
+ const elided = elideMiddle(collapsed.text, config);
122
+ return {
123
+ text: elided.text,
124
+ changed: collapsed.changed || elided.changed,
125
+ elidedChars: elided.elidedChars,
126
+ collapsedLines: collapsed.collapsedLines,
127
+ };
128
+ }
129
+ /** Validate and apply defaults; fail loud rather than silently shape nothing. */
130
+ export function resolveShapingConfig(config = {}) {
131
+ const resolved = {
132
+ maxResultChars: positive('maxResultChars', config.maxResultChars ?? SHAPING_DEFAULTS.maxResultChars),
133
+ headChars: positive('headChars', config.headChars ?? SHAPING_DEFAULTS.headChars),
134
+ tailChars: positive('tailChars', config.tailChars ?? SHAPING_DEFAULTS.tailChars),
135
+ duplicateRunMin: positive('duplicateRunMin', config.duplicateRunMin ?? SHAPING_DEFAULTS.duplicateRunMin),
136
+ };
137
+ if (resolved.headChars + resolved.tailChars >= resolved.maxResultChars) {
138
+ throw new Error('dsh-terse: headChars + tailChars must be less than maxResultChars, else elision cannot shrink');
139
+ }
140
+ return resolved;
141
+ }
142
+ function positive(field, value) {
143
+ if (!Number.isInteger(value) || value < 1) {
144
+ throw new Error(`dsh-terse: \`${field}\` must be an integer >= 1 (got ${String(value)})`);
145
+ }
146
+ return value;
147
+ }
148
+ //# sourceMappingURL=shaping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shaping.js","sourceRoot":"","sources":["../src/shaping.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAcH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAkB;IAC7C,cAAc,EAAE,MAAM;IACtB,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,eAAe,EAAE,CAAC;CACnB,CAAA;AAaD,wEAAwE;AACxE,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,MAAc;IAChE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC9B,MAAM,GAAG,GAAa,EAAE,CAAA;IACxB,IAAI,SAAS,GAAG,CAAC,CAAA;IACjB,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,OAAO,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;QAC/B,IAAI,GAAG,GAAG,KAAK,GAAG,CAAC,CAAA;QACnB,OAAO,GAAG,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI;YAAE,GAAG,IAAI,CAAC,CAAA;QAC1D,MAAM,GAAG,GAAG,GAAG,GAAG,KAAK,CAAA;QACvB,IAAI,GAAG,IAAI,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACxC,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,EAAE,UAAU,GAAG,wCAAwC,CAAC,CAAA;YAC1E,SAAS,IAAI,GAAG,GAAG,CAAC,CAAA;QACtB,CAAC;aAAM,CAAC;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E,MAAM,QAAQ,GAAkB;QAC9B,cAAc,EAAE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,cAAc,IAAI,gBAAgB,CAAC,cAAc,CAAC;QACpG,SAAS,EAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,IAAI,gBAAgB,CAAC,SAAS,CAAC;QAChF,SAAS,EAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,IAAI,gBAAgB,CAAC,SAAS,CAAC;QAChF,eAAe,EAAE,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC,eAAe,IAAI,gBAAgB,CAAC,eAAe,CAAC;KACzG,CAAA;IACD,IAAI,QAAQ,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,cAAc,EAAE,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,+FAA+F,CAAC,CAAA;IAClH,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,KAAa;IAC5C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,gBAAgB,KAAK,mCAAmC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC3F,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
package/package.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "name": "@sagmans/dsh-terse",
3
+ "version": "0.1.0",
4
+ "description": "DeepSeek Harness plugin that makes agent output maximally terse, concise, and clean without sacrificing quality. Always-on, append-only.",
5
+ "keywords": [
6
+ "deepseek-harness",
7
+ "dsh",
8
+ "dsh-plugin",
9
+ "plugin",
10
+ "cordis",
11
+ "terse",
12
+ "concise",
13
+ "tokens"
14
+ ],
15
+ "license": "MIT",
16
+ "type": "module",
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ },
24
+ "./cordis.patch.yml": "./cordis.patch.yml",
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "cordis.patch.yml",
30
+ "README.md"
31
+ ],
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/sagmans/dsh-terse.git"
35
+ },
36
+ "homepage": "https://github.com/sagmans/dsh-terse#readme",
37
+ "bugs": {
38
+ "url": "https://github.com/sagmans/dsh-terse/issues"
39
+ },
40
+ "engines": {
41
+ "node": "^24.0.0"
42
+ },
43
+ "packageManager": "pnpm@11.21.0",
44
+ "publishConfig": {
45
+ "access": "public",
46
+ "registry": "https://registry.npmjs.org/"
47
+ },
48
+ "dsh": {
49
+ "bundle": {
50
+ "patch": "./cordis.patch.yml"
51
+ },
52
+ "compatibility": {
53
+ "dsh": ">=0.1.5-rc.1 <0.1.6",
54
+ "dshReleases": {
55
+ "0.1.5-rc.1": "compatible",
56
+ "0.1.5-rc.2": "compatible",
57
+ "0.1.5-rc.3": "compatible"
58
+ }
59
+ }
60
+ },
61
+ "scripts": {
62
+ "build": "tsc -p tsconfig.json",
63
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json",
64
+ "test": "vitest run",
65
+ "test:build": "node --test \"tests/build/*.test.mjs\"",
66
+ "test:release": "python3 -m unittest discover -s tests/release -p 'test_*.py'",
67
+ "pack-smoke": "node tools/pack-smoke.mjs",
68
+ "check": "pnpm run typecheck && pnpm test && pnpm run build && pnpm run test:build && pnpm test:release && pnpm run pack-smoke",
69
+ "prepare": "npm run build",
70
+ "prepack": "npm run build",
71
+ "prepublishOnly": "pnpm run typecheck && pnpm test && pnpm test:release"
72
+ },
73
+ "peerDependencies": {
74
+ "@deepseek-ai/cordis": "^4.0.1",
75
+ "@deepseek-ai/dsh-agent": ">=0.1.5-rc.1 <0.1.6",
76
+ "@deepseek-ai/dsh-llm": ">=0.1.5-rc.1 <0.1.6",
77
+ "@deepseek-ai/dsh-session": ">=0.1.5-rc.1 <0.1.6",
78
+ "@deepseek-ai/dsh-tools": ">=0.1.5-rc.1 <0.1.6"
79
+ },
80
+ "peerDependenciesMeta": {
81
+ "@deepseek-ai/dsh-agent": {
82
+ "optional": true
83
+ },
84
+ "@deepseek-ai/dsh-llm": {
85
+ "optional": true
86
+ },
87
+ "@deepseek-ai/dsh-session": {
88
+ "optional": true
89
+ },
90
+ "@deepseek-ai/dsh-tools": {
91
+ "optional": true
92
+ }
93
+ },
94
+ "devDependencies": {
95
+ "@deepseek-ai/cordis": "4.0.2",
96
+ "@deepseek-ai/dsh": "0.1.5-rc.2",
97
+ "@deepseek-ai/dsh-agent": "0.1.5-rc.2",
98
+ "@deepseek-ai/dsh-llm": "0.1.5-rc.2",
99
+ "@deepseek-ai/dsh-session": "0.1.5-rc.2",
100
+ "@deepseek-ai/dsh-tools": "0.1.5-rc.2",
101
+ "@deepseek-ai/schemastery": "3.18.2",
102
+ "@types/node": "22.20.0",
103
+ "typescript": "6.0.3",
104
+ "vitest": "4.1.0"
105
+ }
106
+ }