@morlay/dsh-context-assembler 0.0.11 → 0.0.13

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/dist/index.mjs CHANGED
@@ -125,9 +125,11 @@ const Config = z.object({
125
125
  function apply(ctx, config) {
126
126
  const channel = new ContextAssembler(ctx);
127
127
  const keep = new Set(config.keep ?? DEFAULT_KEEP);
128
- for (const name of config.suppress ?? DEFAULT_SUPPRESS) channel.suppressSection(name);
129
- for (const [name, text] of Object.entries(config.replace ?? DEFAULT_REPLACE)) channel.replaceSection(name, text);
130
- ctx.systemPrompt.section({
128
+ const suppress = config.suppress ?? DEFAULT_SUPPRESS;
129
+ const replace = config.replace ?? DEFAULT_REPLACE;
130
+ for (const name of suppress) channel.suppressSection(name);
131
+ for (const [name, text] of Object.entries(replace)) channel.replaceSection(name, text);
132
+ if (keep.size > 0 || suppress.length > 0 || Object.keys(replace).length > 0) ctx.systemPrompt.section({
131
133
  name: RULES_SECTION,
132
134
  order: RULES_ORDER,
133
135
  text: RULES_TEXT
@@ -145,7 +147,7 @@ function apply(ctx, config) {
145
147
  }
146
148
  const text = channel.replacement(section.name) ?? section.text;
147
149
  if (text !== section.text) changed = true;
148
- if (keep.has(section.name) || text.length === 0) {
150
+ if (keep.size === 0 || keep.has(section.name) || text.length === 0) {
149
151
  sections.push(text === section.text ? section : {
150
152
  ...section,
151
153
  text
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morlay/dsh-context-assembler",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Prompt channel for dsh: assembly-result text conversion (replace / suppress) plus per-step delivery of demoted sections. Workspace instructions and the skill catalog use the official rows (@deepseek-ai/dsh-agent-instructions / @deepseek-ai/dsh-tool-skill); the per-session scope gate lives in @morlay/dsh-session-mode. Reference expansion is its own package (@morlay/dsh-reference).",
5
5
  "keywords": [
6
6
  "context",
@@ -35,31 +35,31 @@
35
35
  "./locale/*.json": "./locale/*.json"
36
36
  },
37
37
  "dependencies": {
38
- "@deepseek-ai/schemastery": "^3.18.6-alpha.2"
38
+ "@deepseek-ai/schemastery": "^3.19.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@deepseek-ai/cordis": "^4.0.6-alpha.2",
42
- "@deepseek-ai/dsh-agent": "^0.2.2-alpha.3",
43
- "@deepseek-ai/dsh-agent-loop": "^0.2.2-alpha.3",
44
- "@deepseek-ai/dsh-agent-loop-testkit": "^0.2.2-alpha.3",
45
- "@deepseek-ai/dsh-compaction-basic": "^0.2.2-alpha.3",
46
- "@deepseek-ai/dsh-llm": "^0.2.2-alpha.3",
47
- "@deepseek-ai/dsh-scope": "^0.2.2-alpha.3",
48
- "@deepseek-ai/dsh-session": "^0.2.2-alpha.3",
49
- "@deepseek-ai/dsh-session-persistence-jsonl": "^0.2.2-alpha.3",
50
- "@deepseek-ai/dsh-system-prompt": "^0.2.2-alpha.3",
51
- "@deepseek-ai/dsh-token-meter": "^0.2.2-alpha.3",
52
- "@morlay/session-rdb": "0.1.10"
41
+ "@deepseek-ai/cordis": "^4.1.0",
42
+ "@deepseek-ai/dsh-agent": "^0.2.2-rc.1",
43
+ "@deepseek-ai/dsh-agent-loop": "^0.2.2-rc.1",
44
+ "@deepseek-ai/dsh-agent-loop-testkit": "^0.2.2-rc.1",
45
+ "@deepseek-ai/dsh-compaction-basic": "^0.2.2-rc.1",
46
+ "@deepseek-ai/dsh-llm": "^0.2.2-rc.1",
47
+ "@deepseek-ai/dsh-scope": "^0.2.2-rc.1",
48
+ "@deepseek-ai/dsh-session": "^0.2.2-rc.1",
49
+ "@deepseek-ai/dsh-session-persistence-jsonl": "^0.2.2-rc.1",
50
+ "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.1",
51
+ "@deepseek-ai/dsh-token-meter": "^0.2.2-rc.1",
52
+ "@morlay/session-rdb": "0.1.12"
53
53
  },
54
54
  "peerDependencies": {
55
- "@deepseek-ai/cordis": "^4.0.6-alpha.2",
56
- "@deepseek-ai/dsh-agent": "^0.2.2-alpha.3",
57
- "@deepseek-ai/dsh-llm": "^0.2.2-alpha.3",
58
- "@deepseek-ai/dsh-session": "^0.2.2-alpha.3",
59
- "@deepseek-ai/dsh-system-prompt": "^0.2.2-alpha.3"
55
+ "@deepseek-ai/cordis": "^4.1.0",
56
+ "@deepseek-ai/dsh-agent": "^0.2.2-rc.1",
57
+ "@deepseek-ai/dsh-llm": "^0.2.2-rc.1",
58
+ "@deepseek-ai/dsh-session": "^0.2.2-rc.1",
59
+ "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.1"
60
60
  },
61
61
  "engines": {
62
- "dsh": ">= 0.2.2-alpha.3 < 0.2.3"
62
+ "dsh": ">= 0.2.2-rc.1 < 0.2.3"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "pnpm exec tsdown"
package/src/index.ts CHANGED
@@ -43,12 +43,16 @@ export const Config: z<Config> = z.object({
43
43
  export function apply(ctx: Context, config: Config): void {
44
44
  const channel = new ContextAssembler(ctx);
45
45
  const keep = new Set(config.keep ?? DEFAULT_KEEP);
46
- for (const name of config.suppress ?? DEFAULT_SUPPRESS) channel.suppressSection(name);
47
- for (const [name, text] of Object.entries(config.replace ?? DEFAULT_REPLACE)) {
46
+ const suppress = config.suppress ?? DEFAULT_SUPPRESS;
47
+ const replace = config.replace ?? DEFAULT_REPLACE;
48
+ for (const name of suppress) channel.suppressSection(name);
49
+ for (const [name, text] of Object.entries(replace)) {
48
50
  channel.replaceSection(name, text);
49
51
  }
50
-
51
- ctx.systemPrompt.section({ name: RULES_SECTION, order: RULES_ORDER, text: RULES_TEXT });
52
+ // 三段清单都显式留空 = 上游原版:不降级、不抑制、不换文案,规则声明也不注册。
53
+ if (keep.size > 0 || suppress.length > 0 || Object.keys(replace).length > 0) {
54
+ ctx.systemPrompt.section({ name: RULES_SECTION, order: RULES_ORDER, text: RULES_TEXT });
55
+ }
52
56
 
53
57
  ctx.on("system-prompt/assemble", async (_assembly, context, next) => {
54
58
  const result = await next();
@@ -64,7 +68,8 @@ export function apply(ctx: Context, config: Config): void {
64
68
  }
65
69
  const text = channel.replacement(section.name) ?? section.text;
66
70
  if (text !== section.text) changed = true;
67
- if (keep.has(section.name) || text.length === 0) {
71
+ // `keep` 显式留空 = 全部保留(只在有白名单时才把其余 section 降级成 reminder)。
72
+ if (keep.size === 0 || keep.has(section.name) || text.length === 0) {
68
73
  sections.push(text === section.text ? section : { ...section, text });
69
74
  continue;
70
75
  }