@zhushanwen/pi-smart-context 0.3.7 → 0.3.8

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.
Files changed (3) hide show
  1. package/README.md +10 -0
  2. package/package.json +1 -1
  3. package/src/tool.ts +5 -3
package/README.md CHANGED
@@ -32,6 +32,16 @@
32
32
  pi install npm:@zhushanwen/pi-smart-context
33
33
  ```
34
34
 
35
+ ## 工具激活(deferred)
36
+
37
+ `compact_context` 工具为 `exposure: "deferred"`——不占常驻工具声明,由 pi 内置 `tool_search` 工具检索命中后按需激活。taiji 宿主内开箱即用(宿主启动时已激活 `tool_search`);独立 pi 使用需在 `<agentDir>/settings.json`(默认 `~/.pi/agent/settings.json`)开启:
38
+
39
+ ```json
40
+ { "defaultTools": ["+tool_search"] }
41
+ ```
42
+
43
+ `+` 前缀是增量修饰(保留 read/bash/edit/write 默认集)。未开启 `tool_search` 时该工具对模型不可见。
44
+
35
45
  ## 配置
36
46
 
37
47
  `<agentDir>/config/smart-context-ext-config.json`(读时热加载)。schema 与示例见 `skills/smart-context-ext-config/SKILL.md`。taiji 桌面端在设置页(系统 → 智能上下文压缩)可视化配置。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhushanwen/pi-smart-context",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "taiji": {
package/src/tool.ts CHANGED
@@ -65,12 +65,11 @@ export interface CompactContextDetails {
65
65
  fellBack: boolean;
66
66
  }
67
67
 
68
- /** 工具描述(§3.5:三条件自查引导)。 */
68
+ /** 工具描述(§3.5:三条件自查引导;条件即纪律,无第三层复述——D1 单源化核对通过)。 */
69
69
  const TOOL_DESCRIPTION =
70
70
  "压缩当前会话上下文(释放早期对话占用的 token;压缩由配置的模型执行,不会切换你的主模型)。" +
71
71
  "仅在同时满足以下条件时调用:1) 当前任务的一个阶段已完成并验证(如一批文件改完、测试通过);" +
72
- "2) 后续工作不再依赖将被压缩的早期细节;3) 上下文已超过提醒阈值(你会收到 [smart-context 提示])。" +
73
- "若任一条件不满足,不要调用。";
72
+ "2) 后续工作不再依赖将被压缩的早期细节;3) 上下文已超过提醒阈值(你会收到 [smart-context 提示])。";
74
73
 
75
74
  /** CompactionResult → 宽松形状的 guard 转换(onComplete 回调参数消费,避免 cast)。 */
76
75
  function toCompactionResultLike(result: unknown): CompactionResultLike {
@@ -143,6 +142,9 @@ export function registerCompactContextTool(
143
142
  pi.registerTool({
144
143
  name: "compact_context",
145
144
  label: "compact_context",
145
+ // deferred(tool-declaration-slimming D4):不常驻声明,tool_search 命中即激活;
146
+ // 迁移写入的 +tool_search 条目(runtime pi-codemode-settings)承载检索入口
147
+ exposure: "deferred",
146
148
  description: TOOL_DESCRIPTION,
147
149
  parameters: CompactContextParams,
148
150
  execute: async (_toolCallId, params, _signal, _onUpdate, ctx) => {