omp packages

@zhushanwen/pi-base-tool-enhance0.10.0

Base tool enhancement - override builtin bash tool: foreground delegates to pi official factory, incremental background mode (design decisions documented in source comments)

zhushanwen321 Published 22 hours ago MIT ~2K downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

@zhushanwen/pi-base-tool-enhance

同名 override pi 内置 bash 工具的增强层:前台行为 100% 委托 pi 官方工厂(createBashToolDefinition),增量提供 background 模式、强制后台白名单与双模式可配置超时。能力侧:测试类命令 force-test 白名单命中自动转后台(模式登记于 force-patterns.ts)、前台挂死保护(可配置前台默认超时,对一切未显式填 timeout 的前台命令生效——典型挂死场景是网络类命令)、工具报错审计(tool_error 审计 hook,entry customType 为 unified-hooks:tool-error)。

设计决策记录在案于包内源码注释与本文档。

安装

pi install npm:@zhushanwen/pi-base-tool-enhance

配置

配置指南另见随包注册的 skill:base-tool-enhance-ext-config(package.json pi.skills 注册,内容与本节一致,含热重载时机与白名单命中语义详述)。

<pi agentDir>/config/base-tool-enhance-ext-config.json(读时刷新热重载,坏键回退默认不拒载):

{
  "forceBackgroundPatterns": [],          // 用户正则,追加到内置白名单后
  "disableBuiltinForcePatterns": false,   // true = 关闭内置 force-test/force-longrun 两组
  "foregroundTimeoutSeconds": null,       // null = 不注入(pi 原生不限时)
  "backgroundTimeoutSeconds": null,       // null = 不注入
  "maxConcurrentBackground": 8
}

工具

  • bash {command, timeout?, background?} —— 白名单命中自动转后台(忽略显式 timeout,D13)
  • bash_output {task_id?} —— 省略列出任务(单例表 + registry 终态条目);指定返回状态与 tail 输出
  • bash_kill {task_id} —— 终止后台任务(限本进程任务;跨进程 running 条目由发起进程或 reaper 管理)

bash_output / bash_kill 为 exposure: "deferred"——不占常驻工具声明,由 pi 内置 tool_search 工具检索命中后按需激活。taiji 宿主内开箱即用(宿主启动时已激活 tool_search);独立 pi 使用需在 <agentDir>/settings.json(默认 ~/.pi/agent/settings.json)加 "defaultTools": ["+tool_search"](+ 前缀是增量修饰,保留 read/bash/edit/write 默认集)。未开启 tool_search 时这两个工具对模型不可见。

完成通知经 pending-notifications(type:"bash",process 生命周期档)+ sendMessage steer 注入当前 session。

退役条件(sunset)

pi 上游出现原生 background bash(或等价长时命令异步化)能力时评估退役本包;届时前台行为已收敛在 createBashToolDefinition 委托面,迁移成本可控。不登记此条件则 3 年后冗余层无人敢删(override 层与上游能力双轨漂移)。