@linxin666/dsh-liangshen 0.4.16 → 0.4.17

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/lib/index.js CHANGED
@@ -398,6 +398,18 @@ function readPresetDefinition(id, dir) {
398
398
  };
399
399
  }
400
400
  /**
401
+ * Parse the on-demand tool family text: comma separated, each entry a prefix
402
+ * ending in exactly one trailing `*`.
403
+ * @param text - the settings text.
404
+ * @returns the pattern list, or undefined when the text is blank or any entry is malformed.
405
+ */
406
+ function parsePagedToolPatterns(text) {
407
+ if (text === void 0) return void 0;
408
+ const entries = text.split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
409
+ if (entries.length === 0) return void 0;
410
+ return entries.every((entry) => /^[^*]+\*$/.test(entry)) ? entries : void 0;
411
+ }
412
+ /**
401
413
  * The overlay table: settings field to composition row and config key.
402
414
  *
403
415
  * `presentation` also selects the executor: the catalog declares the wire and
@@ -405,7 +417,17 @@ function readPresetDefinition(id, dir) {
405
417
  * the assembled native roster remains the only surface.
406
418
  */
407
419
  function overrideTargets(overrides) {
408
- return [["tool-catalog", { ...overrides.presentation === void 0 ? {} : { presentation: overrides.presentation } }], ["minimal-prompt", { ...overrides.dispatcher === void 0 ? {} : { dispatcher: overrides.dispatcher } }]];
420
+ const paged = parsePagedToolPatterns(overrides.pagedToolPatterns);
421
+ const pagedPatch = () => paged === void 0 ? {} : { pagedToolPatterns: [...paged] };
422
+ return [
423
+ ["tool-catalog", {
424
+ ...overrides.presentation === void 0 ? {} : { presentation: overrides.presentation },
425
+ ...pagedPatch()
426
+ }],
427
+ ["tool-activate", pagedPatch()],
428
+ ["working-context", pagedPatch()],
429
+ ["minimal-prompt", { ...overrides.dispatcher === void 0 ? {} : { dispatcher: overrides.dispatcher } }]
430
+ ];
409
431
  }
410
432
  /**
411
433
  * Apply the settings overlay to one parsed row list.
@@ -601,7 +623,7 @@ function mountOnce(packageName, fn) {
601
623
  * transport and every other tool is reached from inside the program through
602
624
  * the generated SDK ('native' keeps the assembled roster alone), declared once
603
625
  * per session instead of staged across a turn boundary. High-fan-out tool families
604
- * (default `mcp__*`) stay paged out of the executed surface through the
626
+ * (default `mcp__*`, `browser_*`, `task_board_*`, `team_*`, `squad*`, `ui_*`, `ssh_*`) stay paged out of the executed surface through the
605
627
  * host's scoped tool restriction until the preset's own `tool_activate` tool
606
628
  * loads their namespace (LRU cap three), with the activation state replayed
607
629
  * from the durable session event stream. The tool catalog — listing exactly
@@ -627,14 +649,16 @@ const Config = z.object({
627
649
  enabled: z.boolean().default(true).volatile(),
628
650
  announceToAgent: z.boolean().default(false).volatile(),
629
651
  presentation: z.union([...PRESENTATION_OPTIONS, z.transform("both", () => "ptc").deprecated().hidden()]).default("ptc").volatile(),
630
- dispatcher: z.boolean().default(true).volatile()
652
+ dispatcher: z.boolean().default(true).volatile(),
653
+ pagedToolPatterns: z.string().default("").volatile()
631
654
  });
632
655
  /** Schema defaults, re-read for hand-built test contexts. */
633
656
  const DEFAULT_CONFIG = {
634
657
  enabled: true,
635
658
  announceToAgent: false,
636
659
  presentation: "ptc",
637
- dispatcher: true
660
+ dispatcher: true,
661
+ pagedToolPatterns: ""
638
662
  };
639
663
  /**
640
664
  * Read one activation field. The Host validates the raw profile config and
@@ -659,11 +683,12 @@ function resolveConfig(config) {
659
683
  enabled: readField(config?.enabled, DEFAULT_CONFIG.enabled),
660
684
  announceToAgent: readField(config?.announceToAgent, DEFAULT_CONFIG.announceToAgent),
661
685
  presentation: rawPresentation === "both" ? "ptc" : rawPresentation,
662
- dispatcher: readField(config?.dispatcher, DEFAULT_CONFIG.dispatcher)
686
+ dispatcher: readField(config?.dispatcher, DEFAULT_CONFIG.dispatcher),
687
+ pagedToolPatterns: readField(config?.pagedToolPatterns, DEFAULT_CONFIG.pagedToolPatterns)
663
688
  };
664
689
  }
665
690
  /** Model-facing announcement: plugin presence, principle, and limits. */
666
- const LIANGSHEN_GUIDANCE = "本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」。原理:系统提示词保持极简 persona(minimal-prompt 放行该段与 plan 模式的 plan:policy),persona 内置本模式工作纪律(反思熔断——同一假设推演不超过两轮、缺事实立即闭合思考并调用原生检测工具;行动导向——思考只决定下一步具体操作、不在思考中预演代码实现;并发探索——多处独立检查或搜索在单轮内并发发射多个工具调用;YAGNI/PDCA——单步验证单一假设、不写冗余注释;有界收敛——不无限下钻依赖链、前置检查最多2-3轮后立即收敛并作答或编辑),并在组装时追加工作区目录行 Your working directory is <cwd>.。AGENTS.md 工作区指令默认交还宿主自身的 agent-instructions 行,以 user 角色注入,本插件不追加任何系统提示词段、也不改动 pre-step 的消息批次;可选 instructionSource: system-prompt 才由本插件在组装时读取 AGENTS.md 链并追加 workspace-instructions 段(65536 字节预算,每次组装重读)。wire 呈现由 tool-catalog 按会话一次声明,取值 'ptc'(默认:wire 收拢为唯一的 run_code,其余工具经生成的 SDK 调用)或 'native'(组装出的原生清单,无程序化传输),并可在插件设置界面切换(写入所声明预设的 tool-catalog 行);未挂载 code runtime 时不做声明,会话运行原生工具面。温和工具分页出厂开启(pagedToolPatterns 默认 ['mcp__*']):匹配工具在激活前被作用域级工具限制移出可见面(既不在 wire,也不在生成的 SDK 声明中),目录消息列出常驻工具签名与未激活命名空间摘要,调用 tool_activate({ namespace }) 按需激活(LRU 上限 3 个活跃命名空间,驱逐最久未用);激活状态从持久会话事件流重建,resume/压缩后自然恢复。关键事实登记簿(fact_register)让模型把硬约束/已确认决策/失败路径登记为单行事实,随 working-context 行每步投射进局部注意力窗口。working-context 插件在 pre-step 注入单行 [Working Context: ...] 就近状态投射(plan 模式、活跃命名空间、进行中 todo、登记事实,全部从事件流折叠,读不到则省略,全部为空则不注入)。历史工具结果修剪为 4096 字符阈值(head 2048 / tail 1024)。文件操作受宿主沙箱约束;shell 在每个平台都挂上游标准 Stdio 栈(POSIX 为 bash,Windows 为 pwsh),带简短描述标题卡片与确定性退出码。真实推理探针通过不等于模式集成通过,更不等于统计效果提升。预设由插件在激活时向 agent-preset registry 直接注册(不写任何预设目录),插件停用即注销;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。";
691
+ const LIANGSHEN_GUIDANCE = "本机已安装 dsh-liangshen 插件(梁神模式 agent preset):新建会话的预设选择器中可选「梁神模式」。原理:系统提示词保持极简 persona(minimal-prompt 放行该段与 plan 模式的 plan:policy),persona 内置本模式工作纪律(反思熔断——同一假设推演不超过两轮、缺事实立即闭合思考并调用原生检测工具;行动导向——思考只决定下一步具体操作、不在思考中预演代码实现;并发探索——多处独立检查或搜索在单轮内并发发射多个工具调用;YAGNI/PDCA——单步验证单一假设、不写冗余注释;有界收敛——不无限下钻依赖链、前置检查最多2-3轮后立即收敛并作答或编辑),并在组装时追加工作区目录行 Your working directory is <cwd>.。AGENTS.md 工作区指令默认交还宿主自身的 agent-instructions 行,以 user 角色注入,本插件不追加任何系统提示词段、也不改动 pre-step 的消息批次;可选 instructionSource: system-prompt 才由本插件在组装时读取 AGENTS.md 链并追加 workspace-instructions 段(65536 字节预算,每次组装重读)。wire 呈现由 tool-catalog 按会话一次声明,取值 'ptc'(默认:wire 收拢为唯一的 run_code,其余工具经生成的 SDK 调用)或 'native'(组装出的原生清单,无程序化传输),并可在插件设置界面切换(写入所声明预设的 tool-catalog 行);未挂载 code runtime 时不做声明,会话运行原生工具面。按需工具族出厂开启(pagedToolPatterns 默认 ['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*'],可在插件设置的「按需工具族」中用逗号分隔的前缀改写):匹配工具在激活前被作用域级工具限制移出可见面(既不在 wire,也不在生成的 SDK 声明中),目录消息列出常驻工具签名与未激活命名空间摘要,调用 tool_activate({ namespace }) 按需激活(LRU 上限 3 个活跃命名空间,驱逐最久未用);激活状态从持久会话事件流重建,resume/压缩后自然恢复。关键事实登记簿(fact_register)让模型把硬约束/已确认决策/失败路径登记为单行事实,随 working-context 行每步投射进局部注意力窗口。working-context 插件在 pre-step 注入单行 [Working Context: ...] 就近状态投射(plan 模式、活跃命名空间、进行中 todo、登记事实,全部从事件流折叠,读不到则省略,全部为空则不注入)。历史工具结果修剪为 4096 字符阈值(head 2048 / tail 1024)。文件操作受宿主沙箱约束;shell 在每个平台都挂上游标准 Stdio 栈(POSIX 为 bash,Windows 为 pwsh),带简短描述标题卡片与确定性退出码。真实推理探针通过不等于模式集成通过,更不等于统计效果提升。预设由插件在激活时向 agent-preset registry 直接注册(不写任何预设目录),插件停用即注销;默认预设由用户自行选择。用户提到「梁神模式 / 锚定模式 / anchored standard」时即指本插件,请据此协作。";
667
692
  /** Order of the announcement section within the tool-guidance band. */
668
693
  const SECTION_ORDER = 150;
669
694
  /**
@@ -12,7 +12,13 @@
12
12
  import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
13
13
  import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
14
14
  import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
15
- import { type CardActions, type CardShell, type FieldState as CardFieldState } from './settings-form.ts';
15
+ import { type CardActions, type CardShell, type FieldSpec, type FieldState as CardFieldState } from './settings-form.ts';
16
+ /**
17
+ * The on-demand tool family list: comma separated entries, each a prefix with
18
+ * one trailing star. Blank clears the field; any malformed entry holds the
19
+ * draft unwritten.
20
+ */
21
+ export declare function pagedToolPatternsField(field: string): FieldSpec;
16
22
  /** Wire presentations the tool catalog accepts (mirrors the Host schema). */
17
23
  export declare const PRESENTATION_CHOICES: readonly ["ptc", "native"];
18
24
  /** The LiangShen fields this card edits (the namespace's full schema). */
@@ -25,6 +31,8 @@ export interface LiangShenSettings {
25
31
  presentation?: string;
26
32
  /** Whether the preset appends the dispatcher rules section after the persona. */
27
33
  dispatcher?: boolean;
34
+ /** Comma-separated on-demand tool families the Host writes to the tool-catalog row. */
35
+ pagedToolPatterns?: string;
28
36
  }
29
37
  /** What the LiangShen card renders. */
30
38
  export interface LiangShenSettingsCardState extends CardShell {
@@ -32,6 +40,7 @@ export interface LiangShenSettingsCardState extends CardShell {
32
40
  announceToAgent: CardFieldState;
33
41
  presentation: CardFieldState;
34
42
  dispatcher: CardFieldState;
43
+ pagedToolPatterns: CardFieldState;
35
44
  }
36
45
  /** The registration-side face the card's slot entry injects. */
37
46
  export interface LiangShenSettingsCardFace extends CardActions {
@@ -30,6 +30,9 @@ export declare const zh: {
30
30
  'settings.presentationHint': string;
31
31
  'settings.dispatcher': string;
32
32
  'settings.dispatcherHint': string;
33
+ 'settings.pagedToolPatterns': string;
34
+ 'settings.pagedToolPatternsHint': string;
35
+ 'settings.pagedToolPatternsInvalid': string;
33
36
  'settings.on': string;
34
37
  'settings.off': string;
35
38
  'settings.inherit': string;
@@ -92,7 +92,20 @@ export interface PresetOverrides {
92
92
  presentation?: string;
93
93
  /** The `minimal-prompt` row's `dispatcher` switch. */
94
94
  dispatcher?: boolean;
95
+ /**
96
+ * Comma-separated on-demand tool families; written as an array to every row
97
+ * that pages from it (tool-catalog, tool-activate, working-context), skipped
98
+ * when blank or malformed.
99
+ */
100
+ pagedToolPatterns?: string;
95
101
  }
102
+ /**
103
+ * Parse the on-demand tool family text: comma separated, each entry a prefix
104
+ * ending in exactly one trailing `*`.
105
+ * @param text - the settings text.
106
+ * @returns the pattern list, or undefined when the text is blank or any entry is malformed.
107
+ */
108
+ export declare function parsePagedToolPatterns(text: string | undefined): string[] | undefined;
96
109
  /**
97
110
  * Apply the settings overlay to one parsed row list.
98
111
  *
@@ -23,7 +23,7 @@
23
23
  * transport and every other tool is reached from inside the program through
24
24
  * the generated SDK ('native' keeps the assembled roster alone), declared once
25
25
  * per session instead of staged across a turn boundary. High-fan-out tool families
26
- * (default `mcp__*`) stay paged out of the executed surface through the
26
+ * (default `mcp__*`, `browser_*`, `task_board_*`, `team_*`, `squad*`, `ui_*`, `ssh_*`) stay paged out of the executed surface through the
27
27
  * host's scoped tool restriction until the preset's own `tool_activate` tool
28
28
  * loads their namespace (LRU cap three), with the activation state replayed
29
29
  * from the durable session event stream. The tool catalog — listing exactly
@@ -87,17 +87,27 @@ export interface Config {
87
87
  * and the switch is what returns a session to the bare persona.
88
88
  */
89
89
  dispatcher?: ConfigField<boolean>;
90
+ /**
91
+ * On-demand tool families, comma separated (each entry a prefix ending in one
92
+ * `*`), written to every row that pages from the list — the catalog, the
93
+ * activation tool and the working context all replay the session log with it,
94
+ * so the three must never disagree. Empty keeps the preset's shipped list; a
95
+ * malformed text is ignored.
96
+ */
97
+ pagedToolPatterns?: ConfigField<string>;
90
98
  }
91
99
  export declare const Config: z<Schemastery.ObjectS<NoInfer<{
92
100
  enabled: z<boolean, boolean, "volatile-defined">;
93
101
  announceToAgent: z<boolean, boolean, "volatile-defined">;
94
102
  presentation: z<string, "ptc" | "native", "volatile-defined">;
95
103
  dispatcher: z<boolean, boolean, "volatile-defined">;
104
+ pagedToolPatterns: z<string, string, "volatile-defined">;
96
105
  }>>, Schemastery.ObjectT<NoInfer<{
97
106
  enabled: z<boolean, boolean, "volatile-defined">;
98
107
  announceToAgent: z<boolean, boolean, "volatile-defined">;
99
108
  presentation: z<string, "ptc" | "native", "volatile-defined">;
100
109
  dispatcher: z<boolean, boolean, "volatile-defined">;
110
+ pagedToolPatterns: z<string, string, "volatile-defined">;
101
111
  }>>, "plain">;
102
112
  /** The settings the runtime acts on, every field read at its use site. */
103
113
  export interface ResolvedConfig {
@@ -109,6 +119,8 @@ export interface ResolvedConfig {
109
119
  presentation: Presentation;
110
120
  /** Whether the declared preset's minimal-prompt row appends the dispatcher rule block. */
111
121
  dispatcher: boolean;
122
+ /** On-demand tool family text; empty inherits the preset's shipped list. */
123
+ pagedToolPatterns: string;
112
124
  }
113
125
  /** Schema defaults, re-read for hand-built test contexts. */
114
126
  export declare const DEFAULT_CONFIG: ResolvedConfig;
@@ -119,7 +131,7 @@ export declare const DEFAULT_CONFIG: ResolvedConfig;
119
131
  */
120
132
  export declare function resolveConfig(config?: Config): ResolvedConfig;
121
133
  /** Model-facing announcement: plugin presence, principle, and limits. */
122
- export declare const LIANGSHEN_GUIDANCE = "\u672C\u673A\u5DF2\u5B89\u88C5 dsh-liangshen \u63D2\u4EF6\uFF08\u6881\u795E\u6A21\u5F0F agent preset\uFF09\uFF1A\u65B0\u5EFA\u4F1A\u8BDD\u7684\u9884\u8BBE\u9009\u62E9\u5668\u4E2D\u53EF\u9009\u300C\u6881\u795E\u6A21\u5F0F\u300D\u3002\u539F\u7406\uFF1A\u7CFB\u7EDF\u63D0\u793A\u8BCD\u4FDD\u6301\u6781\u7B80 persona\uFF08minimal-prompt \u653E\u884C\u8BE5\u6BB5\u4E0E plan \u6A21\u5F0F\u7684 plan:policy\uFF09\uFF0Cpersona \u5185\u7F6E\u672C\u6A21\u5F0F\u5DE5\u4F5C\u7EAA\u5F8B\uFF08\u53CD\u601D\u7194\u65AD\u2014\u2014\u540C\u4E00\u5047\u8BBE\u63A8\u6F14\u4E0D\u8D85\u8FC7\u4E24\u8F6E\u3001\u7F3A\u4E8B\u5B9E\u7ACB\u5373\u95ED\u5408\u601D\u8003\u5E76\u8C03\u7528\u539F\u751F\u68C0\u6D4B\u5DE5\u5177\uFF1B\u884C\u52A8\u5BFC\u5411\u2014\u2014\u601D\u8003\u53EA\u51B3\u5B9A\u4E0B\u4E00\u6B65\u5177\u4F53\u64CD\u4F5C\u3001\u4E0D\u5728\u601D\u8003\u4E2D\u9884\u6F14\u4EE3\u7801\u5B9E\u73B0\uFF1B\u5E76\u53D1\u63A2\u7D22\u2014\u2014\u591A\u5904\u72EC\u7ACB\u68C0\u67E5\u6216\u641C\u7D22\u5728\u5355\u8F6E\u5185\u5E76\u53D1\u53D1\u5C04\u591A\u4E2A\u5DE5\u5177\u8C03\u7528\uFF1BYAGNI/PDCA\u2014\u2014\u5355\u6B65\u9A8C\u8BC1\u5355\u4E00\u5047\u8BBE\u3001\u4E0D\u5199\u5197\u4F59\u6CE8\u91CA\uFF1B\u6709\u754C\u6536\u655B\u2014\u2014\u4E0D\u65E0\u9650\u4E0B\u94BB\u4F9D\u8D56\u94FE\u3001\u524D\u7F6E\u68C0\u67E5\u6700\u591A2-3\u8F6E\u540E\u7ACB\u5373\u6536\u655B\u5E76\u4F5C\u7B54\u6216\u7F16\u8F91\uFF09\uFF0C\u5E76\u5728\u7EC4\u88C5\u65F6\u8FFD\u52A0\u5DE5\u4F5C\u533A\u76EE\u5F55\u884C Your working directory is <cwd>.\u3002AGENTS.md \u5DE5\u4F5C\u533A\u6307\u4EE4\u9ED8\u8BA4\u4EA4\u8FD8\u5BBF\u4E3B\u81EA\u8EAB\u7684 agent-instructions \u884C\uFF0C\u4EE5 user \u89D2\u8272\u6CE8\u5165\uFF0C\u672C\u63D2\u4EF6\u4E0D\u8FFD\u52A0\u4EFB\u4F55\u7CFB\u7EDF\u63D0\u793A\u8BCD\u6BB5\u3001\u4E5F\u4E0D\u6539\u52A8 pre-step \u7684\u6D88\u606F\u6279\u6B21\uFF1B\u53EF\u9009 instructionSource: system-prompt \u624D\u7531\u672C\u63D2\u4EF6\u5728\u7EC4\u88C5\u65F6\u8BFB\u53D6 AGENTS.md \u94FE\u5E76\u8FFD\u52A0 workspace-instructions \u6BB5\uFF0865536 \u5B57\u8282\u9884\u7B97\uFF0C\u6BCF\u6B21\u7EC4\u88C5\u91CD\u8BFB\uFF09\u3002wire \u5448\u73B0\u7531 tool-catalog \u6309\u4F1A\u8BDD\u4E00\u6B21\u58F0\u660E\uFF0C\u53D6\u503C 'ptc'\uFF08\u9ED8\u8BA4\uFF1Awire \u6536\u62E2\u4E3A\u552F\u4E00\u7684 run_code\uFF0C\u5176\u4F59\u5DE5\u5177\u7ECF\u751F\u6210\u7684 SDK \u8C03\u7528\uFF09\u6216 'native'\uFF08\u7EC4\u88C5\u51FA\u7684\u539F\u751F\u6E05\u5355\uFF0C\u65E0\u7A0B\u5E8F\u5316\u4F20\u8F93\uFF09\uFF0C\u5E76\u53EF\u5728\u63D2\u4EF6\u8BBE\u7F6E\u754C\u9762\u5207\u6362\uFF08\u5199\u5165\u6240\u58F0\u660E\u9884\u8BBE\u7684 tool-catalog \u884C\uFF09\uFF1B\u672A\u6302\u8F7D code runtime \u65F6\u4E0D\u505A\u58F0\u660E\uFF0C\u4F1A\u8BDD\u8FD0\u884C\u539F\u751F\u5DE5\u5177\u9762\u3002\u6E29\u548C\u5DE5\u5177\u5206\u9875\u51FA\u5382\u5F00\u542F\uFF08pagedToolPatterns \u9ED8\u8BA4 ['mcp__*']\uFF09\uFF1A\u5339\u914D\u5DE5\u5177\u5728\u6FC0\u6D3B\u524D\u88AB\u4F5C\u7528\u57DF\u7EA7\u5DE5\u5177\u9650\u5236\u79FB\u51FA\u53EF\u89C1\u9762\uFF08\u65E2\u4E0D\u5728 wire\uFF0C\u4E5F\u4E0D\u5728\u751F\u6210\u7684 SDK \u58F0\u660E\u4E2D\uFF09\uFF0C\u76EE\u5F55\u6D88\u606F\u5217\u51FA\u5E38\u9A7B\u5DE5\u5177\u7B7E\u540D\u4E0E\u672A\u6FC0\u6D3B\u547D\u540D\u7A7A\u95F4\u6458\u8981\uFF0C\u8C03\u7528 tool_activate({ namespace }) \u6309\u9700\u6FC0\u6D3B\uFF08LRU \u4E0A\u9650 3 \u4E2A\u6D3B\u8DC3\u547D\u540D\u7A7A\u95F4\uFF0C\u9A71\u9010\u6700\u4E45\u672A\u7528\uFF09\uFF1B\u6FC0\u6D3B\u72B6\u6001\u4ECE\u6301\u4E45\u4F1A\u8BDD\u4E8B\u4EF6\u6D41\u91CD\u5EFA\uFF0Cresume/\u538B\u7F29\u540E\u81EA\u7136\u6062\u590D\u3002\u5173\u952E\u4E8B\u5B9E\u767B\u8BB0\u7C3F\uFF08fact_register\uFF09\u8BA9\u6A21\u578B\u628A\u786C\u7EA6\u675F/\u5DF2\u786E\u8BA4\u51B3\u7B56/\u5931\u8D25\u8DEF\u5F84\u767B\u8BB0\u4E3A\u5355\u884C\u4E8B\u5B9E\uFF0C\u968F working-context \u884C\u6BCF\u6B65\u6295\u5C04\u8FDB\u5C40\u90E8\u6CE8\u610F\u529B\u7A97\u53E3\u3002working-context \u63D2\u4EF6\u5728 pre-step \u6CE8\u5165\u5355\u884C [Working Context: ...] \u5C31\u8FD1\u72B6\u6001\u6295\u5C04\uFF08plan \u6A21\u5F0F\u3001\u6D3B\u8DC3\u547D\u540D\u7A7A\u95F4\u3001\u8FDB\u884C\u4E2D todo\u3001\u767B\u8BB0\u4E8B\u5B9E\uFF0C\u5168\u90E8\u4ECE\u4E8B\u4EF6\u6D41\u6298\u53E0\uFF0C\u8BFB\u4E0D\u5230\u5219\u7701\u7565\uFF0C\u5168\u90E8\u4E3A\u7A7A\u5219\u4E0D\u6CE8\u5165\uFF09\u3002\u5386\u53F2\u5DE5\u5177\u7ED3\u679C\u4FEE\u526A\u4E3A 4096 \u5B57\u7B26\u9608\u503C\uFF08head 2048 / tail 1024\uFF09\u3002\u6587\u4EF6\u64CD\u4F5C\u53D7\u5BBF\u4E3B\u6C99\u7BB1\u7EA6\u675F\uFF1Bshell \u5728\u6BCF\u4E2A\u5E73\u53F0\u90FD\u6302\u4E0A\u6E38\u6807\u51C6 Stdio \u6808\uFF08POSIX \u4E3A bash\uFF0CWindows \u4E3A pwsh\uFF09\uFF0C\u5E26\u7B80\u77ED\u63CF\u8FF0\u6807\u9898\u5361\u7247\u4E0E\u786E\u5B9A\u6027\u9000\u51FA\u7801\u3002\u771F\u5B9E\u63A8\u7406\u63A2\u9488\u901A\u8FC7\u4E0D\u7B49\u4E8E\u6A21\u5F0F\u96C6\u6210\u901A\u8FC7\uFF0C\u66F4\u4E0D\u7B49\u4E8E\u7EDF\u8BA1\u6548\u679C\u63D0\u5347\u3002\u9884\u8BBE\u7531\u63D2\u4EF6\u5728\u6FC0\u6D3B\u65F6\u5411 agent-preset registry \u76F4\u63A5\u6CE8\u518C\uFF08\u4E0D\u5199\u4EFB\u4F55\u9884\u8BBE\u76EE\u5F55\uFF09\uFF0C\u63D2\u4EF6\u505C\u7528\u5373\u6CE8\u9500\uFF1B\u9ED8\u8BA4\u9884\u8BBE\u7531\u7528\u6237\u81EA\u884C\u9009\u62E9\u3002\u7528\u6237\u63D0\u5230\u300C\u6881\u795E\u6A21\u5F0F / \u951A\u5B9A\u6A21\u5F0F / anchored standard\u300D\u65F6\u5373\u6307\u672C\u63D2\u4EF6\uFF0C\u8BF7\u636E\u6B64\u534F\u4F5C\u3002";
134
+ export declare const LIANGSHEN_GUIDANCE = "\u672C\u673A\u5DF2\u5B89\u88C5 dsh-liangshen \u63D2\u4EF6\uFF08\u6881\u795E\u6A21\u5F0F agent preset\uFF09\uFF1A\u65B0\u5EFA\u4F1A\u8BDD\u7684\u9884\u8BBE\u9009\u62E9\u5668\u4E2D\u53EF\u9009\u300C\u6881\u795E\u6A21\u5F0F\u300D\u3002\u539F\u7406\uFF1A\u7CFB\u7EDF\u63D0\u793A\u8BCD\u4FDD\u6301\u6781\u7B80 persona\uFF08minimal-prompt \u653E\u884C\u8BE5\u6BB5\u4E0E plan \u6A21\u5F0F\u7684 plan:policy\uFF09\uFF0Cpersona \u5185\u7F6E\u672C\u6A21\u5F0F\u5DE5\u4F5C\u7EAA\u5F8B\uFF08\u53CD\u601D\u7194\u65AD\u2014\u2014\u540C\u4E00\u5047\u8BBE\u63A8\u6F14\u4E0D\u8D85\u8FC7\u4E24\u8F6E\u3001\u7F3A\u4E8B\u5B9E\u7ACB\u5373\u95ED\u5408\u601D\u8003\u5E76\u8C03\u7528\u539F\u751F\u68C0\u6D4B\u5DE5\u5177\uFF1B\u884C\u52A8\u5BFC\u5411\u2014\u2014\u601D\u8003\u53EA\u51B3\u5B9A\u4E0B\u4E00\u6B65\u5177\u4F53\u64CD\u4F5C\u3001\u4E0D\u5728\u601D\u8003\u4E2D\u9884\u6F14\u4EE3\u7801\u5B9E\u73B0\uFF1B\u5E76\u53D1\u63A2\u7D22\u2014\u2014\u591A\u5904\u72EC\u7ACB\u68C0\u67E5\u6216\u641C\u7D22\u5728\u5355\u8F6E\u5185\u5E76\u53D1\u53D1\u5C04\u591A\u4E2A\u5DE5\u5177\u8C03\u7528\uFF1BYAGNI/PDCA\u2014\u2014\u5355\u6B65\u9A8C\u8BC1\u5355\u4E00\u5047\u8BBE\u3001\u4E0D\u5199\u5197\u4F59\u6CE8\u91CA\uFF1B\u6709\u754C\u6536\u655B\u2014\u2014\u4E0D\u65E0\u9650\u4E0B\u94BB\u4F9D\u8D56\u94FE\u3001\u524D\u7F6E\u68C0\u67E5\u6700\u591A2-3\u8F6E\u540E\u7ACB\u5373\u6536\u655B\u5E76\u4F5C\u7B54\u6216\u7F16\u8F91\uFF09\uFF0C\u5E76\u5728\u7EC4\u88C5\u65F6\u8FFD\u52A0\u5DE5\u4F5C\u533A\u76EE\u5F55\u884C Your working directory is <cwd>.\u3002AGENTS.md \u5DE5\u4F5C\u533A\u6307\u4EE4\u9ED8\u8BA4\u4EA4\u8FD8\u5BBF\u4E3B\u81EA\u8EAB\u7684 agent-instructions \u884C\uFF0C\u4EE5 user \u89D2\u8272\u6CE8\u5165\uFF0C\u672C\u63D2\u4EF6\u4E0D\u8FFD\u52A0\u4EFB\u4F55\u7CFB\u7EDF\u63D0\u793A\u8BCD\u6BB5\u3001\u4E5F\u4E0D\u6539\u52A8 pre-step \u7684\u6D88\u606F\u6279\u6B21\uFF1B\u53EF\u9009 instructionSource: system-prompt \u624D\u7531\u672C\u63D2\u4EF6\u5728\u7EC4\u88C5\u65F6\u8BFB\u53D6 AGENTS.md \u94FE\u5E76\u8FFD\u52A0 workspace-instructions \u6BB5\uFF0865536 \u5B57\u8282\u9884\u7B97\uFF0C\u6BCF\u6B21\u7EC4\u88C5\u91CD\u8BFB\uFF09\u3002wire \u5448\u73B0\u7531 tool-catalog \u6309\u4F1A\u8BDD\u4E00\u6B21\u58F0\u660E\uFF0C\u53D6\u503C 'ptc'\uFF08\u9ED8\u8BA4\uFF1Awire \u6536\u62E2\u4E3A\u552F\u4E00\u7684 run_code\uFF0C\u5176\u4F59\u5DE5\u5177\u7ECF\u751F\u6210\u7684 SDK \u8C03\u7528\uFF09\u6216 'native'\uFF08\u7EC4\u88C5\u51FA\u7684\u539F\u751F\u6E05\u5355\uFF0C\u65E0\u7A0B\u5E8F\u5316\u4F20\u8F93\uFF09\uFF0C\u5E76\u53EF\u5728\u63D2\u4EF6\u8BBE\u7F6E\u754C\u9762\u5207\u6362\uFF08\u5199\u5165\u6240\u58F0\u660E\u9884\u8BBE\u7684 tool-catalog \u884C\uFF09\uFF1B\u672A\u6302\u8F7D code runtime \u65F6\u4E0D\u505A\u58F0\u660E\uFF0C\u4F1A\u8BDD\u8FD0\u884C\u539F\u751F\u5DE5\u5177\u9762\u3002\u6309\u9700\u5DE5\u5177\u65CF\u51FA\u5382\u5F00\u542F\uFF08pagedToolPatterns \u9ED8\u8BA4 ['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']\uFF0C\u53EF\u5728\u63D2\u4EF6\u8BBE\u7F6E\u7684\u300C\u6309\u9700\u5DE5\u5177\u65CF\u300D\u4E2D\u7528\u9017\u53F7\u5206\u9694\u7684\u524D\u7F00\u6539\u5199\uFF09\uFF1A\u5339\u914D\u5DE5\u5177\u5728\u6FC0\u6D3B\u524D\u88AB\u4F5C\u7528\u57DF\u7EA7\u5DE5\u5177\u9650\u5236\u79FB\u51FA\u53EF\u89C1\u9762\uFF08\u65E2\u4E0D\u5728 wire\uFF0C\u4E5F\u4E0D\u5728\u751F\u6210\u7684 SDK \u58F0\u660E\u4E2D\uFF09\uFF0C\u76EE\u5F55\u6D88\u606F\u5217\u51FA\u5E38\u9A7B\u5DE5\u5177\u7B7E\u540D\u4E0E\u672A\u6FC0\u6D3B\u547D\u540D\u7A7A\u95F4\u6458\u8981\uFF0C\u8C03\u7528 tool_activate({ namespace }) \u6309\u9700\u6FC0\u6D3B\uFF08LRU \u4E0A\u9650 3 \u4E2A\u6D3B\u8DC3\u547D\u540D\u7A7A\u95F4\uFF0C\u9A71\u9010\u6700\u4E45\u672A\u7528\uFF09\uFF1B\u6FC0\u6D3B\u72B6\u6001\u4ECE\u6301\u4E45\u4F1A\u8BDD\u4E8B\u4EF6\u6D41\u91CD\u5EFA\uFF0Cresume/\u538B\u7F29\u540E\u81EA\u7136\u6062\u590D\u3002\u5173\u952E\u4E8B\u5B9E\u767B\u8BB0\u7C3F\uFF08fact_register\uFF09\u8BA9\u6A21\u578B\u628A\u786C\u7EA6\u675F/\u5DF2\u786E\u8BA4\u51B3\u7B56/\u5931\u8D25\u8DEF\u5F84\u767B\u8BB0\u4E3A\u5355\u884C\u4E8B\u5B9E\uFF0C\u968F working-context \u884C\u6BCF\u6B65\u6295\u5C04\u8FDB\u5C40\u90E8\u6CE8\u610F\u529B\u7A97\u53E3\u3002working-context \u63D2\u4EF6\u5728 pre-step \u6CE8\u5165\u5355\u884C [Working Context: ...] \u5C31\u8FD1\u72B6\u6001\u6295\u5C04\uFF08plan \u6A21\u5F0F\u3001\u6D3B\u8DC3\u547D\u540D\u7A7A\u95F4\u3001\u8FDB\u884C\u4E2D todo\u3001\u767B\u8BB0\u4E8B\u5B9E\uFF0C\u5168\u90E8\u4ECE\u4E8B\u4EF6\u6D41\u6298\u53E0\uFF0C\u8BFB\u4E0D\u5230\u5219\u7701\u7565\uFF0C\u5168\u90E8\u4E3A\u7A7A\u5219\u4E0D\u6CE8\u5165\uFF09\u3002\u5386\u53F2\u5DE5\u5177\u7ED3\u679C\u4FEE\u526A\u4E3A 4096 \u5B57\u7B26\u9608\u503C\uFF08head 2048 / tail 1024\uFF09\u3002\u6587\u4EF6\u64CD\u4F5C\u53D7\u5BBF\u4E3B\u6C99\u7BB1\u7EA6\u675F\uFF1Bshell \u5728\u6BCF\u4E2A\u5E73\u53F0\u90FD\u6302\u4E0A\u6E38\u6807\u51C6 Stdio \u6808\uFF08POSIX \u4E3A bash\uFF0CWindows \u4E3A pwsh\uFF09\uFF0C\u5E26\u7B80\u77ED\u63CF\u8FF0\u6807\u9898\u5361\u7247\u4E0E\u786E\u5B9A\u6027\u9000\u51FA\u7801\u3002\u771F\u5B9E\u63A8\u7406\u63A2\u9488\u901A\u8FC7\u4E0D\u7B49\u4E8E\u6A21\u5F0F\u96C6\u6210\u901A\u8FC7\uFF0C\u66F4\u4E0D\u7B49\u4E8E\u7EDF\u8BA1\u6548\u679C\u63D0\u5347\u3002\u9884\u8BBE\u7531\u63D2\u4EF6\u5728\u6FC0\u6D3B\u65F6\u5411 agent-preset registry \u76F4\u63A5\u6CE8\u518C\uFF08\u4E0D\u5199\u4EFB\u4F55\u9884\u8BBE\u76EE\u5F55\uFF09\uFF0C\u63D2\u4EF6\u505C\u7528\u5373\u6CE8\u9500\uFF1B\u9ED8\u8BA4\u9884\u8BBE\u7531\u7528\u6237\u81EA\u884C\u9009\u62E9\u3002\u7528\u6237\u63D0\u5230\u300C\u6881\u795E\u6A21\u5F0F / \u951A\u5B9A\u6A21\u5F0F / anchored standard\u300D\u65F6\u5373\u6307\u672C\u63D2\u4EF6\uFF0C\u8BF7\u636E\u6B64\u534F\u4F5C\u3002";
123
135
  /**
124
136
  * Absolute path of the bundled LiangShen preset directory: the composition,
125
137
  * the display map, and the preset-local `.mjs` plugins this plugin declares.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-liangshen",
3
- "description": "LiangShen (梁神) agent preset plus its composer lever for the dsh web GUI. The host half declares the bundled preset to the harness's agent-preset registry at activation (declare = enabled), so the preset is selectable for new sessions without writing anything into the harness home; the preset keeps a minimal persona with standing working discipline while the harness's own user-role agent-instructions injection delivers the workspace instructions (the optional `instructionSource: system-prompt` mode lifts them into the prompt instead), and declares one tool presentation for the session's whole lifetime: `ptc` by default (the wire collapses to `run_code` and every other tool is reached through the generated SDK), with `native` as the explicit assembled-roster option. High-fan-out tool families (default `mcp__*`) stay paged out of the wire until the preset's own `tool_activate` tool loads their namespace (LRU cap three, state replayed from the durable session event stream), and the tool catalog — exactly the reachable tools plus paged-out namespace summaries — and a one-line working-context projection travel as durable user messages republished only on change. The browser half adds a slot-machine lever left of the model selector on the new-session screen to toggle the mode. Hot-pluggable via cordis.patch.yml + profile symlink, no dsh source changes.",
4
- "version": "0.4.16",
3
+ "description": "LiangShen (梁神) agent preset plus its composer lever for the dsh web GUI. The host half declares the bundled preset to the harness's agent-preset registry at activation (declare = enabled), so the preset is selectable for new sessions without writing anything into the harness home; the preset keeps a minimal persona with standing working discipline while the harness's own user-role agent-instructions injection delivers the workspace instructions (the optional `instructionSource: system-prompt` mode lifts them into the prompt instead), and declares one tool presentation for the session's whole lifetime: `ptc` by default (the wire collapses to `run_code` and every other tool is reached through the generated SDK), with `native` as the explicit assembled-roster option. High-fan-out tool families (default `['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']`, while every host builtin stays resident; customizable via `pagedToolPatterns`) stay paged out of the wire and generated SDK until the preset's own `tool_activate` tool loads their namespace (LRU cap three, state replayed from the durable session event stream), and the tool catalog — exactly the reachable tools plus paged-out namespace summaries — and a one-line working-context projection travel as durable user messages republished only on change. The browser half adds a slot-machine lever left of the model selector on the new-session screen to toggle the mode. Hot-pluggable via cordis.patch.yml + profile symlink, no dsh source changes.",
4
+ "version": "0.4.17",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",
7
7
  "engines": {
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dsh": {
27
27
  "engines": {
28
- "dsh": ">=0.2.2-rc.1"
28
+ "dsh": ">=0.2.2-rc.2"
29
29
  },
30
30
  "bundle": {
31
31
  "patch": "./cordis.patch.yml"
@@ -42,25 +42,25 @@
42
42
  }
43
43
  },
44
44
  "peerDependencies": {
45
- "@deepseek-ai/dsh": ">=0.2.2-rc.1"
45
+ "@deepseek-ai/dsh": ">=0.2.2-rc.2"
46
46
  },
47
47
  "dependencies": {
48
48
  "@deepseek-ai/schemastery": "^3.19.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@deepseek-ai/cordis": "^4.1.0",
52
- "@deepseek-ai/dsh-agent-preset-registry": "^0.2.2-rc.1",
53
- "@deepseek-ai/dsh-api-remotes": "^0.2.2-rc.1",
54
- "@deepseek-ai/dsh-api-session-controller": "^0.2.2-rc.1",
55
- "@deepseek-ai/dsh-client-connection": "^0.2.2-rc.1",
56
- "@deepseek-ai/dsh-client-locale": "^0.2.2-rc.1",
57
- "@deepseek-ai/dsh-client-store": "^0.2.2-rc.1",
58
- "@deepseek-ai/dsh-client-ui-conversation": "^0.2.2-rc.1",
59
- "@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.1",
60
- "@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.1",
61
- "@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.1",
62
- "@deepseek-ai/dsh-settings": "^0.2.2-rc.1",
63
- "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.1",
52
+ "@deepseek-ai/dsh-agent-preset-registry": "^0.2.2-rc.2",
53
+ "@deepseek-ai/dsh-api-remotes": "^0.2.2-rc.2",
54
+ "@deepseek-ai/dsh-api-session-controller": "^0.2.2-rc.2",
55
+ "@deepseek-ai/dsh-client-connection": "^0.2.2-rc.2",
56
+ "@deepseek-ai/dsh-client-locale": "^0.2.2-rc.2",
57
+ "@deepseek-ai/dsh-client-store": "^0.2.2-rc.2",
58
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.2.2-rc.2",
59
+ "@deepseek-ai/dsh-client-ui-renderer": "^0.2.2-rc.2",
60
+ "@deepseek-ai/dsh-client-ui-settings": "^0.2.2-rc.2",
61
+ "@deepseek-ai/dsh-client-ui-slots": "^0.2.2-rc.2",
62
+ "@deepseek-ai/dsh-settings": "^0.2.2-rc.2",
63
+ "@deepseek-ai/dsh-system-prompt": "^0.2.2-rc.2",
64
64
  "@testing-library/react": "^16.1.0",
65
65
  "@types/node": "^22.20.0",
66
66
  "@types/react": "~18.3.1",
@@ -18,11 +18,27 @@
18
18
  # true -> 'ptc' and false -> 'native') but only warn once.
19
19
  #
20
20
  # Gentle tool paging keeps high-fan-out families out of reach until needed:
21
- # tools matching `pagedToolPatterns` (default `mcp__*`) stay paged out, the
22
- # durable tool-catalog message summarizes their namespaces with an activation
23
- # pointer, and the preset's own `tool_activate` tool (the tool-activate row)
24
- # loads one namespace back — at most three stay active, LRU eviction pages the
25
- # oldest back out. The activation state replays from the durable session event
21
+ # tools matching `pagedToolPatterns` — by default the MCP bridge plus the plugin
22
+ # families `browser_*`, `task_board_*`, `team_*`, `squad*`, `ui_*` and
23
+ # `ssh_*` — stay paged out, the durable tool-catalog message summarizes their
24
+ # namespaces with an activation pointer, and the preset's own `tool_activate`
25
+ # tool (the tool-activate row) loads one namespace back — at most three stay
26
+ # active, LRU eviction pages the oldest back out. The pattern's own head decides
27
+ # the family: a head ending in `__` is an MCP bridge and takes the first `__`
28
+ # segment of the tool name (`mcp__codegraph__x` -> `codegraph`), any other head
29
+ # names the family literally with one trailing `_` dropped (`task_board_*` ->
30
+ # `task_board`), so `squad*` covers `squads_*` and `squad_member_*` alike.
31
+ # Every host builtin the rows below mount stays resident: no shipped pattern
32
+ # names one, so the shell, filesystem, job, skill, delegation, plan, goal and web
33
+ # tools never page.
34
+ # The pattern list is ONE fact shared by THREE rows: `tool-catalog` installs the
35
+ # registry restriction, `tool-activate` replays the log to answer it, and
36
+ # `working-context` renders the resulting active set. All three therefore carry
37
+ # the same shipped list and the settings overlay rewrites all three together: a
38
+ # row left on its own default would disagree about what is active, and the
39
+ # activation tool would refuse to re-activate a namespace the registry had
40
+ # already withheld.
41
+ # The activation state replays from the durable session event
26
42
  # stream on every assembly, so resume and compaction rebuild it without process
27
43
  # memory. Paging is enforced twice, because the wire is not the only surface a
28
44
  # tool can be reached through: the assembled tool list loses the paged families,
@@ -140,8 +156,11 @@
140
156
  # the assembled roster alone. The shipped default is a static-context choice,
141
157
  # not a measured win: the official scaffold comparison ranks this presentation
142
158
  # below the native surface on both code-agent benchmarks, and the bundled
143
- # benchmark matrix is how that trade would be settled locally. `pagedToolPatterns` (default `['mcp__*']`) names the
144
- # high-fan-out families that stay paged out of the wire until activated; the
159
+ # benchmark matrix is how that trade would be settled locally.
160
+ # `pagedToolPatterns` names the high-fan-out families that stay paged out of the
161
+ # wire until activated: the MCP bridge plus the plugin families `browser_*`,
162
+ # `task_board_*`, `team_*`, `squad*`, `ui_*` and `ssh_*`. Every host builtin
163
+ # the rows below mount stays resident, because no shipped pattern names one; the
145
164
  # active set replays from the session event stream, so resume and compaction
146
165
  # rebuild it. `maxResidentTokens` (default 6000, calibrated above the shipped
147
166
  # roster so the guard flags real growth rather than the factory configuration)
@@ -182,7 +201,7 @@
182
201
  config:
183
202
  descriptionMaxLength: 200
184
203
  presentation: 'ptc'
185
- pagedToolPatterns: ['mcp__*']
204
+ pagedToolPatterns: ['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']
186
205
  maxResidentTokens: 8000
187
206
 
188
207
  # ── the wire ────────────────────────────────────────────────────────────────
@@ -204,14 +223,26 @@
204
223
  # the settings overlay rewrites the SAME key, so the settings switch and the
205
224
  # composition never disagree.
206
225
 
226
+ # The working-context line folds the SAME active set the catalog pages from, so
227
+ # this row carries the same `pagedToolPatterns` list as the tool-catalog row:
228
+ # two pattern sources would let the rendered line name a namespace active that
229
+ # the registry has already withheld.
207
230
  - id: working-context
208
231
  name: ./working-context.mjs
232
+ config:
233
+ pagedToolPatterns: ['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']
209
234
 
210
235
  # The paging activation handle the catalog points at: with `pagedToolPatterns`
211
236
  # non-empty this row is what lets `tool_activate({ namespace })` bring one
212
237
  # paged namespace back onto the wire (and the generated SDK) for the session.
238
+ # It carries the SAME list as the tool-catalog and working-context rows, because
239
+ # it replays the log with its own copy: a different list would let it answer
240
+ # "already active" for a namespace the catalog's restriction had withheld,
241
+ # leaving that namespace unreachable for the rest of the session.
213
242
  - id: tool-activate
214
243
  name: ./tool-activate.mjs
244
+ config:
245
+ pagedToolPatterns: ['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']
215
246
 
216
247
  # The key-fact register: the model pins a hard constraint / confirmed decision /
217
248
  # failed path with `fact_register`, the fold rebuilds the register from the
@@ -177,9 +177,6 @@ export function isDelegatedCaller(agent, ctx) {
177
177
  if (header?.['origin'] === 'subagent') return true
178
178
 
179
179
  const agents = readService(ctx, 'agents')
180
- if (asRecord(agents) === undefined) return false
181
- const roots = rootsOf(agents)
182
- if (roots === undefined) return false
183
180
  const id = idOf(caller)
184
181
  const get = asRecord(agents)?.['get']
185
182
  if (id !== undefined && typeof get === 'function') {
@@ -191,7 +188,22 @@ export function isDelegatedCaller(agent, ctx) {
191
188
  }
192
189
  if (live !== agent) return false
193
190
  }
194
- return !roots.includes(agent)
191
+
192
+ const roots = asRecord(agents) === undefined ? undefined : rootsOf(agents)
193
+ if (roots !== undefined) return !roots.includes(agent)
194
+
195
+ // Starting in 0.2.2-rc.2 `agents.roots()` was replaced by `subagents.rootOf(caller)`.
196
+ const subagents = readService(ctx, 'subagents')
197
+ const rootOf = asRecord(subagents)?.['rootOf']
198
+ if (typeof rootOf === 'function') {
199
+ try {
200
+ const root = rootOf.call(subagents, agent)
201
+ if (asRecord(root) !== undefined) return root !== agent
202
+ } catch {
203
+ return false
204
+ }
205
+ }
206
+ return false
195
207
  }
196
208
 
197
209
  /**
@@ -356,10 +368,14 @@ export function hasRunningChildSubagent(agent, ctx) {
356
368
  if (ownId !== undefined) parentIds.add(ownId)
357
369
  const headerId = sessionIdOf(caller)
358
370
  if (headerId !== undefined) parentIds.add(headerId)
359
- const running = entriesOf(listed).some(entry =>
360
- entry['status'] === 'running'
361
- && typeof entry['parent'] === 'string'
362
- && parentIds.has(entry['parent']))
371
+ const running = entriesOf(listed).some((entry) => {
372
+ const active = entry['status'] === 'running' || entry['running'] === true
373
+ if (!active) return false
374
+ const directParent = typeof entry['parent'] === 'string'
375
+ ? entry['parent']
376
+ : asRecord(asRecord(entry['session'])?.['header'])?.['parentSession']
377
+ return typeof directParent === 'string' && parentIds.has(directParent)
378
+ })
363
379
  if (running) return true
364
380
  }
365
381
 
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * paging — pure helpers for the LiangShen preset's gentle tool paging.
3
3
  *
4
- * Paging keeps high-fan-out tool families (MCP servers and similar plugins)
5
- * off the wire until the session actually needs them: a tool whose name
6
- * matches one of the configured prefix patterns is PAGED, everything else is
7
- * RESIDENT and stays on the wire. A paged tool returns to the wire once its
4
+ * Paging keeps high-fan-out tool families (MCP servers and plugin tool
5
+ * families) off the wire until the session actually needs them: a tool whose
6
+ * name matches one of the configured prefix patterns is PAGED, everything else
7
+ * is RESIDENT and stays on the wire. A paged tool returns to the wire once its
8
8
  * namespace is activated through the `tool_activate` tool.
9
9
  *
10
10
  * The activation state is derived from the durable session event stream, never
@@ -18,8 +18,14 @@
18
18
  * oldest, returning its tools to the paged summary.
19
19
  */
20
20
 
21
- /** The default paging pattern: every MCP-bridged tool (`mcp__<server>__<fn>`). */
22
- export const DEFAULT_PAGED_TOOL_PATTERNS = ['mcp__*']
21
+ /**
22
+ * The default paging patterns: the MCP bridge (`mcp__<server>__<fn>`, one
23
+ * namespace per server) plus the plugin tool families this preset mounts and
24
+ * would otherwise carry resident for the whole session — the browser view, the
25
+ * task board, the team issue channel, the squad roster, the client presentation
26
+ * tool and the SSH host tools.
27
+ */
28
+ export const DEFAULT_PAGED_TOOL_PATTERNS = ['mcp__*', 'browser_*', 'task_board_*', 'team_*', 'squad*', 'ui_*', 'ssh_*']
23
29
 
24
30
  /** The LRU cap on simultaneously active paged namespaces. */
25
31
  export const DEFAULT_MAX_ACTIVE_NAMESPACES = 3
@@ -38,7 +44,9 @@ export function integerAtLeast(plugin, value, field, minimum, fallback) {
38
44
 
39
45
  /**
40
46
  * Validate the pagedToolPatterns config: an array of prefix globs, each a
41
- * non-empty literal prefix ending in exactly one trailing `*`.
47
+ * non-empty literal head ending in exactly one trailing `*`. A head-less `*`
48
+ * is refused rather than accepted and inert: the family derivation reads the
49
+ * head, so a bare wildcard would claim every tool and page none of them.
42
50
  */
43
51
  export function validatePagedToolPatterns(plugin, value, fallback = DEFAULT_PAGED_TOOL_PATTERNS) {
44
52
  if (value === undefined) return fallback
@@ -49,7 +57,7 @@ export function validatePagedToolPatterns(plugin, value, fallback = DEFAULT_PAGE
49
57
  if (typeof entry !== 'string' || entry.trim() === '') {
50
58
  throw new TypeError(`${plugin}: pagedToolPatterns entries must be non-empty strings`)
51
59
  }
52
- if (!entry.endsWith('*') || entry.slice(0, -1).includes('*')) {
60
+ if (!entry.endsWith('*') || entry.slice(0, -1).includes('*') || entry.slice(0, -1).trim() === '') {
53
61
  throw new TypeError(`${plugin}: pagedToolPatterns entries must be prefix patterns ending in one trailing "*"`)
54
62
  }
55
63
  return entry
@@ -58,10 +66,17 @@ export function validatePagedToolPatterns(plugin, value, fallback = DEFAULT_PAGE
58
66
 
59
67
  /**
60
68
  * The namespace one tool name belongs to under one pattern, or undefined when
61
- * the pattern does not match. The prefix strips the pattern's literal head and
62
- * the namespace is the first `__`-delimited segment of the remainder
63
- * (`mcp__codegraph__codegraph_explore` under `mcp__*` is `codegraph`); a
64
- * remainder without `__` is the namespace as a whole.
69
+ * the pattern does not match. The pattern's own head decides how the namespace
70
+ * is derived:
71
+ * - a head ending in `__` is an MCP bridge, whose namespace lives in the tool
72
+ * name: the first `__`-delimited segment of the remainder
73
+ * (`mcp__codegraph__codegraph_explore` under `mcp__*` is `codegraph`);
74
+ * - any other head names the family literally, with one trailing `_` dropped
75
+ * (`task_board_*` is `task_board`, `squad*` is `squad`), so a plugin whose
76
+ * tools share a literal prefix shares one namespace — and `squad*` covers
77
+ * `squads_*` and `squad_member_*` alike.
78
+ * An empty remainder, or a head that leaves no family name at all, means the
79
+ * tool is not paged.
65
80
  */
66
81
  export function patternNamespace(name, pattern) {
67
82
  if (typeof name !== 'string' || typeof pattern !== 'string' || !pattern.endsWith('*')) return undefined
@@ -69,7 +84,9 @@ export function patternNamespace(name, pattern) {
69
84
  if (!name.startsWith(prefix)) return undefined
70
85
  const rest = name.slice(prefix.length)
71
86
  if (rest === '') return undefined
72
- const namespace = rest.split('__')[0]
87
+ const namespace = prefix.endsWith('__')
88
+ ? rest.split('__')[0]
89
+ : prefix.endsWith('_') ? prefix.slice(0, -1) : prefix
73
90
  return namespace === '' ? undefined : namespace
74
91
  }
75
92
 
@@ -198,17 +215,26 @@ export function replayActivations(events, capacity = DEFAULT_MAX_ACTIVE_NAMESPAC
198
215
  }
199
216
  for (const event of list) {
200
217
  // Under the `ptc` presentation the wire carries `run_code` alone, so the model
201
- // reaches `tool_activate` from inside a program and the harness records that as
218
+ // reaches EVERY tool from inside a program and the harness records each call as
202
219
  // a `tool/ptc-dispatch` event — never as a top-level `tool/call`. Reading only
203
220
  // `tool/call` therefore found no activation at all: every activation reported
204
221
  // success, the page never lifted, and the same namespace could be activated
205
222
  // again for ever. Both event shapes feed the same recency list, in the order
206
- // the session recorded them.
223
+ // the session recorded them, and the dispatch branch repeats BOTH rules the
224
+ // top-level branch applies: an activation activates, and any other call into
225
+ // an already-active family refreshes it. Without the second rule the LRU
226
+ // silently degraded to activation order — the only shape a real tool call
227
+ // takes under the default presentation refreshed nothing.
207
228
  if (event?.type === 'tool/ptc-dispatch') {
208
229
  const dispatch = event.data
209
- if (dispatch?.name !== TOOL_ACTIVATE_NAME || dispatch?.isError === true) continue
210
- const namespace = callArguments(dispatch)?.namespace
211
- if (typeof namespace === 'string' && namespace !== '') touch(namespace)
230
+ if (dispatch?.isError === true) continue
231
+ if (dispatch?.name === TOOL_ACTIVATE_NAME) {
232
+ const namespace = callArguments(dispatch)?.namespace
233
+ if (typeof namespace === 'string' && namespace !== '') touch(namespace)
234
+ continue
235
+ }
236
+ const namespace = namespaceOf(dispatch?.name, patterns)
237
+ if (namespace !== undefined && active.includes(namespace)) touch(namespace)
212
238
  continue
213
239
  }
214
240
  if (event?.type !== 'tool/call') continue
@@ -2,12 +2,15 @@
2
2
  * tool-activate — the LiangShen preset's `tool_activate` tool: the activation
3
3
  * handle for the gentle tool paging the sibling tool-catalog plugin applies.
4
4
  *
5
- * Tools whose names match the paging patterns (default `mcp__*`) stay out of
6
- * reach until their namespace is activated here: off the wire, and — under a
7
- * presentation whose wire has already collapsed to the single `run_code`
8
- * transport, where the wire carries nothing left to filter — also out of the
9
- * scope's registry view, which is what the generated SDK and every program
10
- * dispatch resolve against. The activation itself is the durable `tool/call`
5
+ * Tools whose names match the paging patterns — by default the MCP bridge plus
6
+ * the plugin families `browser_*`, `task_board_*`, `team_*`, `squad*`, `ui_*`
7
+ * and `ssh_*` — stay out of reach until their namespace is activated here: off
8
+ * the wire, and, under a presentation whose wire has already collapsed to the
9
+ * single `run_code` transport where the wire carries nothing left to filter,
10
+ * also out of the scope's registry view, which is what the generated SDK and
11
+ * every program dispatch resolve against.
12
+ *
13
+ * The activation itself is the durable `tool/call`
11
14
  * event this call appends to the session log: the catalog plugin re-pages the
12
15
  * scope at the end of the call (its `tools/post-execute` hook) and the wire
13
16
  * partition replays the same event stream at the next assembly, so both halves
@@ -131,7 +134,7 @@ export function apply(ctx, config) {
131
134
  properties: {
132
135
  namespace: {
133
136
  type: 'string',
134
- description: 'The paged namespace to activate, exactly as the catalog names it (for example "codegraph" for mcp__codegraph__* tools).',
137
+ description: 'The paged namespace to activate, exactly as the catalog names it (for example "codegraph" for mcp__codegraph__* tools, or "task_board" for task_board_* tools).',
135
138
  },
136
139
  },
137
140
  required: ['namespace'],
@@ -21,9 +21,13 @@
21
21
  * boolean `ptcPresentation` maps onto the enum (true -> 'ptc', false ->
22
22
  * 'native') with a one-time deprecation warning.
23
23
  *
24
- * TOOL PAGING: tools whose names match `pagedToolPatterns` (default
25
- * `['mcp__*']`) stay off the wire until their namespace is activated through
26
- * the `tool_activate` tool (registered by the sibling tool-activate plugin).
24
+ * TOOL PAGING: tools whose names match `pagedToolPatterns` — by default the
25
+ * MCP bridge plus the plugin families `browser_*`, `task_board_*`, `team_*`,
26
+ * `squad*`, `ui_*` and `ssh_*` — stay off the wire until their namespace is
27
+ * activated through the `tool_activate` tool (registered by the sibling
28
+ * tool-activate plugin). Every host builtin stays resident: no shipped pattern
29
+ * names one, so the session keeps its shell, filesystem, job, skill, delegation,
30
+ * plan, goal and web tools on the wire for its whole lifetime.
27
31
  * The active set replays from the durable session event stream on every
28
32
  * assembly, so resume, reload, and compaction rebuild it without any
29
33
  * process-memory state. At most a few namespaces stay active; the LRU
@@ -179,9 +183,10 @@ export const DEFAULT_PRESENTATION = 'ptc'
179
183
  * surface small.
180
184
  *
181
185
  * The value is calibrated ABOVE this preset's own shipped roster rather than at
182
- * the theoretical core-set ideal: with gentle paging every non-\`mcp__*\` tool the
183
- * preset mounts stays resident, and that roster measures in the low thousands of
184
- * estimated tokens. A ceiling below the factory baseline would fire on every
186
+ * the theoretical core-set ideal: with gentle paging the resident surface is the
187
+ * host builtins plus every tool family no shipped pattern claims, and that
188
+ * roster measures in the low thousands of estimated tokens. A ceiling below the
189
+ * factory baseline would fire on every
185
190
  * ordinary session and train the reader to ignore it. It therefore flags real
186
191
  * growth — a deployment adding tool families of its own — instead of the shipped
187
192
  * configuration. The guard warns once per session and never truncates: silently
@@ -297,9 +302,9 @@ function validateRetiredAnchorTools(value) {
297
302
  * line instead.
298
303
  *
299
304
  * SCOPE: exactly the host builtins the preset's own `agent.cordis.yml` rows
300
- * mount for a session, which is the surface the paging wildcard leaves resident
301
- * (`pagedToolPatterns` defaults to `mcp__*`, so no host builtin is ever paged
302
- * out):
305
+ * mount for a session, which is the surface the shipped paging patterns leave
306
+ * resident (they name the MCP bridge and the plugin tool families, and no host
307
+ * builtin matches one):
303
308
  * - the shell (one of bash / pwsh per platform), the filesystem and discovery
304
309
  * tools, the background-job controls, and the editor;
305
310
  * - the prompt/skill surface, the todo list, the user question tool, and