@linxin666/dsh-liangshen 0.2.6 → 0.2.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/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # node scripts/verify-docs.mjs --write <dir>
5
- README.md: 369bb8384a73650063d3d040f1aecc4d7f11f842
6
- README.zh.md: 96ce3a7db25f7696368b7e0d8440c42df457e571
5
+ README.md: cbce60fdf1c3fc52daea6f2cf6cec6f6fe96ca71
6
+ README.zh.md: c262a22537b68f5c8b1e72ba057470ec7336bedb
package/README.md CHANGED
@@ -63,6 +63,15 @@ Trajectory drift can be measured without reading raw reasoning:
63
63
  node tools/analyze-session.mjs ~/.dsh/sessions/<workspace>/<session>/session.jsonl
64
64
  ```
65
65
 
66
+ ## Configuration
67
+
68
+ | Key | Default | Behavior |
69
+ | --- | --- | --- |
70
+ | `enabled` | `true` | Master switch: when false, neither preset sync nor announcement runs. |
71
+ | `announceToAgent` | `false` | Opt-in: when true, a system-prompt section announces the plugin. Off by default so agent system prompts stay clean. |
72
+
73
+ Both fields are editable in the web settings surface (plugin config, live) or through the profile patch (`dsh plugin` / `cordis.patch.yml`).
74
+
66
75
  ## Behavior and limits
67
76
 
68
77
  - A first model response that calls no tool promotes once it has responded; an anchor-gated session also releases when its first turn ends (`turn/end`). The release is decided during prompt assembly, so the new user turn already gets the promoted PTC catalog and its messages are not stripped;
package/README.zh.md CHANGED
@@ -63,6 +63,15 @@ dsh plugin --profile web remove @linxin666/dsh-liangshen
63
63
  node tools/analyze-session.mjs <导出的 session.jsonl>
64
64
  ```
65
65
 
66
+ ## 配置
67
+
68
+ | 键 | 默认值 | 行为 |
69
+ | --- | --- | --- |
70
+ | `enabled` | `true` | 总开关:关闭后预设同步与公告都不执行。 |
71
+ | `announceToAgent` | `false` | 按需开启:开启后向 agent 系统提示注入本插件公告。默认关闭,保持系统提示词干净。 |
72
+
73
+ 两个字段都可在 Web 设置界面(插件配置,即时生效)或 profile patch(`dsh plugin` / `cordis.patch.yml`)中编辑。
74
+
66
75
  ## 行为与限制
67
76
 
68
77
  - 第一次模型响应如果没有调用工具,在响应后即自动晋升;锚定门控中的会话也会在首轮结束(`turn/end`)时释放。释放判定发生在 prompt assemble 阶段,所以新用户轮次一开始就拿到晋升后的 PTC 目录,其消息也不会再被剥离;
package/lib/index.js CHANGED
@@ -1,8 +1,206 @@
1
1
  import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, utimesSync } from "node:fs";
2
2
  import { basename, dirname, isAbsolute, join, relative } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
+ import { Service } from "@deepseek-ai/cordis";
4
5
  import z from "schemastery";
5
6
  import { homedir } from "node:os";
7
+ //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-settings@0.1.1-rc.1_@deepseek-ai+cordis@4.0.1_@deepseek-ai+dsh-brand@0_8fb97b2935e1a5982886bc1738874e4d/node_modules/@deepseek-ai/dsh-settings/lib/index.js
8
+ /**
9
+ * Structural secret redaction for settings values. `role('secret')` fields are
10
+ * removed from a value before it crosses a wire boundary; a sidecar records
11
+ * each schema-declared secret position and whether it currently holds a value,
12
+ * so a configuration surface can render a write-only input without ever
13
+ * receiving the secret itself.
14
+ * @module @deepseek-ai/dsh-settings/redact
15
+ */
16
+ /** Whether a value is a plain data object the walker may recurse into. */
17
+ function isRecord(value) {
18
+ return typeof value === "object" && value !== null && !Array.isArray(value);
19
+ }
20
+ function walk(node, value, path, secrets) {
21
+ if (node === void 0) return value;
22
+ if (node.meta?.role === "secret") {
23
+ secrets.push({
24
+ path,
25
+ set: value !== void 0
26
+ });
27
+ return;
28
+ }
29
+ switch (node.type) {
30
+ case "object": {
31
+ const properties = node.dict ?? {};
32
+ const source = isRecord(value) ? value : void 0;
33
+ const rebuilt = {};
34
+ if (source !== void 0) for (const [key, entry] of Object.entries(source)) {
35
+ if (key in properties) continue;
36
+ rebuilt[key] = entry;
37
+ }
38
+ for (const [key, child] of Object.entries(properties)) {
39
+ const stripped = walk(child, source?.[key], [...path, key], secrets);
40
+ if (stripped !== void 0) rebuilt[key] = stripped;
41
+ }
42
+ return source === void 0 && Object.keys(rebuilt).length === 0 ? value : rebuilt;
43
+ }
44
+ case "dict": {
45
+ if (!isRecord(value)) return value;
46
+ const rebuilt = {};
47
+ for (const [key, entry] of Object.entries(value)) {
48
+ const stripped = walk(node.inner, entry, [...path, key], secrets);
49
+ if (stripped !== void 0) rebuilt[key] = stripped;
50
+ }
51
+ return rebuilt;
52
+ }
53
+ case "array":
54
+ if (!Array.isArray(value)) return value;
55
+ return value.map((entry, index) => walk(node.inner, entry, [...path, String(index)], secrets));
56
+ default: return value;
57
+ }
58
+ }
59
+ /**
60
+ * Service Definition for the user-settings capability seam (`ctx.settings`). Providers store one raw document of
61
+ * per-namespace sections; plugins register a namespace schema and read the
62
+ * resolved value, which layers schema defaults, the registrant's composition
63
+ * `base`, and the user document section, in that order.
64
+ * @module @deepseek-ai/dsh-settings
65
+ */
66
+ const NAMESPACE_PATTERN = /^[a-z][a-z0-9-]*$/;
67
+ /**
68
+ * Brand a raw string as a {@link SettingsNamespace}.
69
+ * @param value - candidate namespace; lowercase kebab-case, as in plugin short names.
70
+ * @returns the branded namespace.
71
+ */
72
+ function settingsNamespace(value) {
73
+ if (!NAMESPACE_PATTERN.test(value)) throw new TypeError(`settings namespace "${value}" must match ${String(NAMESPACE_PATTERN)}`);
74
+ return value;
75
+ }
76
+ /**
77
+ * Deep equality over JSON-compatible data (objects, arrays, primitives) — the
78
+ * Service Definition's single change-detection predicate, exported so the invariant
79
+ * companion checks exactly the implementation's relation.
80
+ * @param a - one JSON-compatible value.
81
+ * @param b - the other JSON-compatible value.
82
+ * @returns whether the two values are structurally equal.
83
+ */
84
+ function deepEqualJson(a, b) {
85
+ if (a === b) return true;
86
+ if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
87
+ if (Array.isArray(a) || Array.isArray(b)) {
88
+ if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
89
+ return a.every((entry, index) => deepEqualJson(entry, b[index]));
90
+ }
91
+ const left = a;
92
+ const right = b;
93
+ const keys = Object.keys(left);
94
+ if (keys.length !== Object.keys(right).length) return false;
95
+ return keys.every((key) => key in right && deepEqualJson(left[key], right[key]));
96
+ }
97
+ /** Whether a value is a plain data object (not an array, null, or class instance). */
98
+ function isPlainObject(value) {
99
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
100
+ const proto = Object.getPrototypeOf(value);
101
+ return proto === Object.prototype || proto === null;
102
+ }
103
+ /** Apply one path op to a detached section, returning the next section. */
104
+ function applyPathOp(section, op) {
105
+ const [head, ...rest] = op.path;
106
+ if (head === void 0) {
107
+ if (op.op === "unset") return {};
108
+ if (!isPlainObject(op.value)) throw new TypeError("settings mutate: setting the section root requires a plain object");
109
+ return { ...op.value };
110
+ }
111
+ if (rest.length === 0) {
112
+ if (op.op === "set") return {
113
+ ...section,
114
+ [head]: op.value
115
+ };
116
+ const { [head]: _removed, ...kept } = section;
117
+ return kept;
118
+ }
119
+ const child = section[head];
120
+ if (!isPlainObject(child)) {
121
+ if (op.op === "unset") return section;
122
+ return {
123
+ ...section,
124
+ [head]: applyPathOp({}, {
125
+ ...op,
126
+ path: rest
127
+ })
128
+ };
129
+ }
130
+ return {
131
+ ...section,
132
+ [head]: applyPathOp(child, {
133
+ ...op,
134
+ path: rest
135
+ })
136
+ };
137
+ }
138
+ /**
139
+ * Layer `over` onto `under`: plain objects merge recursively, every other
140
+ * value (arrays included) replaces the lower layer wholesale. `over` never
141
+ * carries `undefined` entries — sections come from parsed documents and write
142
+ * snapshots pass {@link cloneJsonShaped}, which strips them so a sparse patch
143
+ * cannot erase lower keys.
144
+ */
145
+ function mergeLayers(under, over) {
146
+ if (over === void 0) return under;
147
+ if (!isPlainObject(under) || !isPlainObject(over)) return over;
148
+ const merged = { ...under };
149
+ for (const [key, value] of Object.entries(over)) merged[key] = key in merged ? mergeLayers(merged[key], value) : value;
150
+ return merged;
151
+ }
152
+ /** Recursively freeze one resolved value so handed-out snapshots stay immutable. */
153
+ function deepFreeze(value) {
154
+ if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
155
+ for (const entry of Object.values(value)) deepFreeze(entry);
156
+ return Object.freeze(value);
157
+ }
158
+ Service.init;
159
+ /**
160
+ * Value mirror of the `FiberState` members {@link isUnloading} compares
161
+ * against: a const enum has no runtime object to import, and the value is
162
+ * needed at runtime (same rationale as the CLI boot driver's mirror).
163
+ */
164
+ const FIBER_DISPOSED = 4;
165
+ const FIBER_UNLOADING = 5;
166
+ /** Whether the consumer's own fiber is tearing down (not just losing the settings service). */
167
+ function isUnloading(ctx) {
168
+ const state = ctx.fiber.state;
169
+ return state === FIBER_UNLOADING || state === FIBER_DISPOSED;
170
+ }
171
+ /**
172
+ * Install the canonical optional-settings consumer wiring: while a settings
173
+ * service exists, register `ns` with the consumer's composition entry as the
174
+ * `base` layer and point the source thunk at the resolved scope; when the
175
+ * service goes away (disposal, provider reload), fall back to the entry so
176
+ * the consumer keeps working exactly as composed. The registration rides the
177
+ * scoped fiber, so no settings service ever mounted means none of this runs.
178
+ * @param ctx - consumer plugin context owning the wiring.
179
+ * @param ns - the consumer-owned settings namespace.
180
+ * @param schema - schema resolving the namespace (typically the plugin Config).
181
+ * @param entry - the consumer's composition entry config, used as `base`.
182
+ * @param hooks - source sink and change notification.
183
+ */
184
+ function installSettingsSection(ctx, ns, schema, entry, hooks) {
185
+ ctx.inject(["settings"], (sctx) => {
186
+ const scope = sctx.settings.register(ns, schema, {
187
+ base: entry,
188
+ ...hooks.validate === void 0 ? {} : { validate: hooks.validate }
189
+ });
190
+ hooks.setSource(() => scope.get());
191
+ sctx.effect(() => () => {
192
+ if (isUnloading(ctx)) return;
193
+ hooks.setSource(() => entry);
194
+ hooks.onChange();
195
+ });
196
+ hooks.onChange();
197
+ scope.watch(() => {
198
+ if (isUnloading(ctx)) return;
199
+ hooks.onChange();
200
+ });
201
+ });
202
+ }
203
+ //#endregion
6
204
  //#region src/dsh-home.ts
7
205
  /**
8
206
  * DSH_HOME resolution shared by the plugin family's Host halves: the
@@ -376,9 +574,11 @@ function mountOnce(packageName, fn) {
376
574
  *
377
575
  * Host half only: on startup it syncs the bundled `presets/` tree into the
378
576
  * harness-home agent-presets root (`~/.dsh/.agent-presets`), making the
379
- * LiangShen preset selectable for new sessions without copying files by hand,
380
- * and announces the capability through a system-prompt section. No browser
381
- * half, no routes, no agent tools — the preset itself provides the tools.
577
+ * LiangShen preset selectable for new sessions without copying files by hand.
578
+ * The capability announcement is a system-prompt section that ships OFF by
579
+ * default (`announceToAgent: false`) and can be enabled in the web settings
580
+ * surface (plugin config) or the profile patch. No browser half, no routes,
581
+ * no agent tools — the preset itself provides the tools.
382
582
  *
383
583
  * The preset is the "anchored-standard" idea shipped as a named mode: the
384
584
  * first model request sees only the builtin Minimal preset's exact two tools
@@ -388,14 +588,16 @@ function mountOnce(packageName, fn) {
388
588
  */
389
589
  /** Stable cordis plugin name. */
390
590
  const name = "liangshen";
591
+ /** Settings namespace of the plugin (the web settings surface edits it). */
592
+ const LIANGSHEN_SETTINGS_NAMESPACE = settingsNamespace("dsh-liangshen");
391
593
  /** Prompt assembly must exist before the announcement section can register. */
392
594
  const inject = ["systemPrompt"];
393
595
  const Config = z.object({
394
596
  enabled: z.boolean().default(true),
395
- announceToAgent: z.boolean().default(true)
597
+ announceToAgent: z.boolean().default(false)
396
598
  });
397
599
  /** Schema default, re-read for hand-built test contexts. */
398
- const DEFAULT_ANNOUNCE = true;
600
+ const DEFAULT_ANNOUNCE = false;
399
601
  /** Order of the announcement section within the tool-guidance band. */
400
602
  const SECTION_ORDER = 150;
401
603
  /** Model-facing announcement: plugin presence, principle, and limits. */
@@ -406,15 +608,18 @@ function bundledPresetsRoot() {
406
608
  }
407
609
  /**
408
610
  * Mount the plugin: sync bundled presets into the harness-home agent-presets
409
- * root, then announce through a system-prompt section.
611
+ * root, register the settings namespace (enabled / announceToAgent, live),
612
+ * and announce through a system-prompt section when announceToAgent is on
613
+ * (off by default).
410
614
  * @param ctx - host plugin context carrying systemPrompt.
411
615
  * @param config - resolved plugin config (schema defaults applied by the loader).
412
616
  */
413
617
  const apply = mountOnce("@linxin666/dsh-liangshen", applyImpl);
414
618
  function applyImpl(ctx, config) {
619
+ let current = () => config ?? {};
415
620
  const resolve = () => ({
416
- announceToAgent: config?.announceToAgent ?? DEFAULT_ANNOUNCE,
417
- enabled: config?.enabled ?? true
621
+ announceToAgent: current().announceToAgent ?? DEFAULT_ANNOUNCE,
622
+ enabled: current().enabled ?? true
418
623
  });
419
624
  const sync = () => {
420
625
  const targetRoot = join(dshHome(), ".agent-presets");
@@ -440,6 +645,13 @@ function applyImpl(ctx, config) {
440
645
  text: LIANGSHEN_GUIDANCE
441
646
  });
442
647
  };
648
+ installSettingsSection(ctx, LIANGSHEN_SETTINGS_NAMESPACE, Config, config ?? {}, {
649
+ setSource: (source) => {
650
+ current = source;
651
+ refresh();
652
+ },
653
+ onChange: refresh
654
+ });
443
655
  refresh();
444
656
  ctx.effect(() => () => {
445
657
  disposeSection?.();
@@ -447,4 +659,4 @@ function applyImpl(ctx, config) {
447
659
  }, "dsh-liangshen: announcement");
448
660
  }
449
661
  //#endregion
450
- export { Config, LIANGSHEN_GUIDANCE, apply, bundledPresetsRoot, dshHome, inject, name };
662
+ export { Config, LIANGSHEN_GUIDANCE, LIANGSHEN_SETTINGS_NAMESPACE, apply, bundledPresetsRoot, dshHome, inject, name };
@@ -3,9 +3,11 @@
3
3
  *
4
4
  * Host half only: on startup it syncs the bundled `presets/` tree into the
5
5
  * harness-home agent-presets root (`~/.dsh/.agent-presets`), making the
6
- * LiangShen preset selectable for new sessions without copying files by hand,
7
- * and announces the capability through a system-prompt section. No browser
8
- * half, no routes, no agent tools — the preset itself provides the tools.
6
+ * LiangShen preset selectable for new sessions without copying files by hand.
7
+ * The capability announcement is a system-prompt section that ships OFF by
8
+ * default (`announceToAgent: false`) and can be enabled in the web settings
9
+ * surface (plugin config) or the profile patch. No browser half, no routes,
10
+ * no agent tools — the preset itself provides the tools.
9
11
  *
10
12
  * The preset is the "anchored-standard" idea shipped as a named mode: the
11
13
  * first model request sees only the builtin Minimal preset's exact two tools
@@ -17,13 +19,15 @@ import type { Context } from '@deepseek-ai/cordis';
17
19
  import z from 'schemastery';
18
20
  /** Stable cordis plugin name. */
19
21
  export declare const name = "liangshen";
22
+ /** Settings namespace of the plugin (the web settings surface edits it). */
23
+ export declare const LIANGSHEN_SETTINGS_NAMESPACE: import("@deepseek-ai/dsh-settings").SettingsNamespace;
20
24
  /** Prompt assembly must exist before the announcement section can register. */
21
25
  export declare const inject: string[];
22
26
  /** Plugin config, validated by the same-named schemastery schema. */
23
27
  export interface Config {
24
28
  /** Master switch: when false, neither sync nor announcement runs. */
25
29
  enabled?: boolean;
26
- /** When true (default), a system-prompt section announces the plugin. */
30
+ /** When true, a system-prompt section announces the plugin (default false — keep prompts clean unless the user opts in). */
27
31
  announceToAgent?: boolean;
28
32
  }
29
33
  export declare const Config: z<Config>;
@@ -34,7 +38,9 @@ export { dshHome } from './dsh-home.ts';
34
38
  export declare function bundledPresetsRoot(): string;
35
39
  /**
36
40
  * Mount the plugin: sync bundled presets into the harness-home agent-presets
37
- * root, then announce through a system-prompt section.
41
+ * root, register the settings namespace (enabled / announceToAgent, live),
42
+ * and announce through a system-prompt section when announceToAgent is on
43
+ * (off by default).
38
44
  * @param ctx - host plugin context carrying systemPrompt.
39
45
  * @param config - resolved plugin config (schema defaults applied by the loader).
40
46
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-liangshen",
3
3
  "description": "LiangShen (梁神) agent preset for the dsh web GUI: a two-phase anchored-standard preset — the first model request exposes only the builtin Minimal exact two-tool surface (persistent bash plus str_replace_editor) with no runtime contexts or injected instructions (Minimal-aligned trajectory anchor), promotion is gated on the first minimal-like reasoning block with a fallback, and the wire then switches to PTC Mode (a single run_code tool over the full registry) with the ordinary injections returning afterwards. The preset files are synced into ~/.dsh/.agent-presets on host startup. Hot-pluggable — mounted via cordis.patch.yml + a profile node_modules symlink, no dsh source changes.",
4
- "version": "0.2.6",
4
+ "version": "0.2.7",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": "^22.19.0 || >=24.0.0"
@@ -26,7 +26,8 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@deepseek-ai/cordis": "^4.0.1",
29
- "@deepseek-ai/dsh-system-prompt": "^0.1.0-rc.8",
29
+ "@deepseek-ai/dsh-settings": "^0.1.1-rc.1",
30
+ "@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.1",
30
31
  "@types/node": "^22.20.0",
31
32
  "tsdown": "0.22.2",
32
33
  "typescript": "~5.7.2",
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Announcement behavior (issue #839): the system-prompt announcement ships
3
+ * OFF by default and only registers when announceToAgent is on. The apply
4
+ * path is exercised against a minimal fake context; each test re-imports the
5
+ * module so the mount-once guard cannot swallow a second apply call.
6
+ */
7
+ import { mkdtempSync } from 'node:fs'
8
+ import { tmpdir } from 'node:os'
9
+ import { join } from 'node:path'
10
+ import process from 'node:process'
11
+ import { describe, expect, it, vi } from 'vitest'
12
+
13
+ interface FakePrompt {
14
+ section: (spec: { name: string; order: number; text: string }) => () => void
15
+ }
16
+
17
+ function makeCtx(sections: ReturnType<typeof vi.fn>[] = []) {
18
+ const registered: Array<{ name: string; order: number; text: string }> = []
19
+ const systemPrompt: FakePrompt = {
20
+ section(spec) {
21
+ registered.push(spec)
22
+ return () => {}
23
+ },
24
+ }
25
+ return {
26
+ ctx: {
27
+ systemPrompt,
28
+ effect: (fn: () => () => void) => fn(),
29
+ inject: vi.fn(),
30
+ logger: { warn: vi.fn(), info: vi.fn() },
31
+ } as never,
32
+ registered,
33
+ }
34
+ }
35
+
36
+ describe('dsh-liangshen announcement (issue #839)', () => {
37
+ it('resolves announceToAgent to false by default in the schema', async () => {
38
+ vi.resetModules()
39
+ const mod = await import('../src/index.ts')
40
+ const value = mod.Config({})
41
+ expect(value.announceToAgent).toBe(false)
42
+ expect(value.enabled).toBe(true)
43
+ })
44
+
45
+ it('registers the announcement section when announceToAgent is on', async () => {
46
+ vi.resetModules()
47
+ const home = mkdtempSync(join(tmpdir(), 'liangshen-announce-'))
48
+ const previous = process.env.DSH_HOME
49
+ process.env.DSH_HOME = home
50
+ try {
51
+ const mod = await import('../src/index.ts')
52
+ const { ctx, registered } = makeCtx()
53
+ mod.apply(ctx, { announceToAgent: true })
54
+ expect(registered.length).toBe(1)
55
+ expect(registered[0]?.name).toBe('plugin:dsh-liangshen')
56
+ expect(registered[0]?.text).toBe(mod.LIANGSHEN_GUIDANCE)
57
+ } finally {
58
+ process.env.DSH_HOME = previous
59
+ }
60
+ })
61
+
62
+ it('keeps silent with the default config (announceToAgent off)', async () => {
63
+ vi.resetModules()
64
+ const home = mkdtempSync(join(tmpdir(), 'liangshen-announce-'))
65
+ const previous = process.env.DSH_HOME
66
+ process.env.DSH_HOME = home
67
+ try {
68
+ const mod = await import('../src/index.ts')
69
+ const { ctx, registered } = makeCtx()
70
+ mod.apply(ctx, undefined)
71
+ expect(registered.length).toBe(0)
72
+ } finally {
73
+ process.env.DSH_HOME = previous
74
+ }
75
+ })
76
+ })
package/src/index.ts CHANGED
@@ -3,9 +3,11 @@
3
3
  *
4
4
  * Host half only: on startup it syncs the bundled `presets/` tree into the
5
5
  * harness-home agent-presets root (`~/.dsh/.agent-presets`), making the
6
- * LiangShen preset selectable for new sessions without copying files by hand,
7
- * and announces the capability through a system-prompt section. No browser
8
- * half, no routes, no agent tools — the preset itself provides the tools.
6
+ * LiangShen preset selectable for new sessions without copying files by hand.
7
+ * The capability announcement is a system-prompt section that ships OFF by
8
+ * default (`announceToAgent: false`) and can be enabled in the web settings
9
+ * surface (plugin config) or the profile patch. No browser half, no routes,
10
+ * no agent tools — the preset itself provides the tools.
9
11
  *
10
12
  * The preset is the "anchored-standard" idea shipped as a named mode: the
11
13
  * first model request sees only the builtin Minimal preset's exact two tools
@@ -18,6 +20,7 @@ import { mkdirSync } from 'node:fs'
18
20
  import { join } from 'node:path'
19
21
  import { fileURLToPath } from 'node:url'
20
22
  import type { Context } from '@deepseek-ai/cordis'
23
+ import { installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings'
21
24
  import type {} from '@deepseek-ai/dsh-system-prompt'
22
25
  import z from 'schemastery'
23
26
  import { dshHome } from './dsh-home.ts'
@@ -27,6 +30,9 @@ import { mountOnce } from './mount-once.ts'
27
30
  /** Stable cordis plugin name. */
28
31
  export const name = 'liangshen'
29
32
 
33
+ /** Settings namespace of the plugin (the web settings surface edits it). */
34
+ export const LIANGSHEN_SETTINGS_NAMESPACE = settingsNamespace('dsh-liangshen')
35
+
30
36
  /** Prompt assembly must exist before the announcement section can register. */
31
37
  export const inject = ['systemPrompt']
32
38
 
@@ -34,17 +40,17 @@ export const inject = ['systemPrompt']
34
40
  export interface Config {
35
41
  /** Master switch: when false, neither sync nor announcement runs. */
36
42
  enabled?: boolean
37
- /** When true (default), a system-prompt section announces the plugin. */
43
+ /** When true, a system-prompt section announces the plugin (default false — keep prompts clean unless the user opts in). */
38
44
  announceToAgent?: boolean
39
45
  }
40
46
 
41
47
  export const Config: z<Config> = z.object({
42
48
  enabled: z.boolean().default(true),
43
- announceToAgent: z.boolean().default(true),
49
+ announceToAgent: z.boolean().default(false),
44
50
  })
45
51
 
46
52
  /** Schema default, re-read for hand-built test contexts. */
47
- const DEFAULT_ANNOUNCE = true
53
+ const DEFAULT_ANNOUNCE = false
48
54
 
49
55
  /** Order of the announcement section within the tool-guidance band. */
50
56
  const SECTION_ORDER = 150
@@ -65,16 +71,22 @@ export function bundledPresetsRoot(): string {
65
71
 
66
72
  /**
67
73
  * Mount the plugin: sync bundled presets into the harness-home agent-presets
68
- * root, then announce through a system-prompt section.
74
+ * root, register the settings namespace (enabled / announceToAgent, live),
75
+ * and announce through a system-prompt section when announceToAgent is on
76
+ * (off by default).
69
77
  * @param ctx - host plugin context carrying systemPrompt.
70
78
  * @param config - resolved plugin config (schema defaults applied by the loader).
71
79
  */
72
80
  export const apply = mountOnce('@linxin666/dsh-liangshen', applyImpl)
73
81
 
74
82
  function applyImpl(ctx: Context, config?: Config): void {
83
+ // The live source the announcement reads: the settings section once the web
84
+ // settings surface is served, the composition entry otherwise
85
+ // (installSettingsSection swaps it when the namespace registers).
86
+ let current: () => Config = () => config ?? {}
75
87
  const resolve = (): Config => ({
76
- announceToAgent: config?.announceToAgent ?? DEFAULT_ANNOUNCE,
77
- enabled: config?.enabled ?? true,
88
+ announceToAgent: current().announceToAgent ?? DEFAULT_ANNOUNCE,
89
+ enabled: current().enabled ?? true,
78
90
  })
79
91
 
80
92
  const sync = (): void => {
@@ -111,6 +123,17 @@ function applyImpl(ctx: Context, config?: Config): void {
111
123
  }
112
124
  }
113
125
 
126
+ // The web settings surface gets the plugin's enabled / announceToAgent
127
+ // fields from this namespace; a settings edit re-runs refresh live, and
128
+ // deployments without a settings service keep the composition entry.
129
+ installSettingsSection(ctx, LIANGSHEN_SETTINGS_NAMESPACE, Config, config ?? {}, {
130
+ setSource: (source) => {
131
+ current = source
132
+ refresh()
133
+ },
134
+ onChange: refresh,
135
+ })
136
+
114
137
  refresh()
115
138
  ctx.effect(() => () => { disposeSection?.(); disposeSection = undefined }, 'dsh-liangshen: announcement')
116
139
  }