pi-proactive 0.2.0-beta.2 → 0.2.0-beta.3
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/CHANGELOG.md +29 -0
- package/README.md +32 -28
- package/build/cli.mjs +121 -0
- package/build/extensions/proactive.js +47 -6
- package/build/src/commands.js +78 -2
- package/build/src/config.js +511 -4
- package/build/src/daemon-config.js +221 -0
- package/build/src/daemon-contact.js +103 -0
- package/build/src/daemon-host.js +84 -0
- package/build/src/daemon.js +193 -3
- package/build/src/health.js +84 -0
- package/build/src/lineage.js +41 -2
- package/build/src/notify.js +183 -0
- package/build/src/progress-eta.js +134 -0
- package/build/src/trigger.js +43 -0
- package/build/src/trust-loop.js +321 -0
- package/build/src/trust-metrics.js +236 -0
- package/build/src/trust-notify.js +73 -0
- package/build/src/trust-policy.js +58 -0
- package/build/src/trust-registry.js +323 -0
- package/daemon/launchd.plist +48 -0
- package/daemon/pi-proactive-daemon.service +29 -0
- package/daemon/run-daemon.sh +84 -0
- package/node_modules/typebox/build/compile/code.mjs +2 -1
- package/node_modules/typebox/build/compile/validator.mjs +1 -5
- package/node_modules/typebox/build/format/date_time.d.mts +1 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -12
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +0 -1
- package/node_modules/typebox/build/format/idn_email.mjs +0 -1
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/iri.mjs +9 -16
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/guard/emit.mjs +2 -2
- package/node_modules/typebox/build/guard/guard.d.mts +5 -7
- package/node_modules/typebox/build/guard/guard.mjs +9 -14
- package/node_modules/typebox/build/guard/index.mjs +0 -6
- package/node_modules/typebox/build/guard/{unicode/unicode_segment.mjs → string.mjs} +19 -16
- package/node_modules/typebox/build/schema/build.mjs +5 -5
- package/node_modules/typebox/build/schema/check.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/_context.d.mts +1 -5
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -16
- package/node_modules/typebox/build/schema/engine/_functions.d.mts +2 -2
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/_reducer.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/_refine.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/_refine.mjs +9 -14
- package/node_modules/typebox/build/schema/engine/_stack.d.mts +20 -34
- package/node_modules/typebox/build/schema/engine/_stack.mjs +202 -143
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +2 -4
- package/node_modules/typebox/build/schema/engine/_unique.mjs +3 -7
- package/node_modules/typebox/build/schema/engine/additionalItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +8 -5
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +32 -27
- package/node_modules/typebox/build/schema/engine/allOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/allOf.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/anyOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/anyOf.mjs +9 -4
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/boolean.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/const.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/const.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/contains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/contains.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/dependencies.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +7 -5
- package/node_modules/typebox/build/schema/engine/dependentRequired.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependentRequired.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/dependentSchemas.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +8 -12
- package/node_modules/typebox/build/schema/engine/enum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/enum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/format.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/format.mjs +8 -11
- package/node_modules/typebox/build/schema/engine/if.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/if.mjs +13 -5
- package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
- package/node_modules/typebox/build/schema/engine/items.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/items.mjs +5 -8
- package/node_modules/typebox/build/schema/engine/maxContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +8 -4
- package/node_modules/typebox/build/schema/engine/maxItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxItems.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/maxLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxLength.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/maxProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxProperties.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/maximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maximum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minContains.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/minItems.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/minItems.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minLength.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minProperties.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minimum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/multipleOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/multipleOf.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/not.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +8 -4
- package/node_modules/typebox/build/schema/engine/oneOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +11 -6
- package/node_modules/typebox/build/schema/engine/pattern.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/pattern.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/patternProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +5 -6
- package/node_modules/typebox/build/schema/engine/prefixItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/prefixItems.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/properties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/properties.mjs +3 -4
- package/node_modules/typebox/build/schema/engine/propertyNames.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +10 -7
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +8 -12
- package/node_modules/typebox/build/schema/engine/ref.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/ref.mjs +14 -18
- package/node_modules/typebox/build/schema/engine/required.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/required.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/schema.d.mts +7 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +138 -136
- package/node_modules/typebox/build/schema/engine/type.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/uniqueItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/uniqueItems.mjs +6 -2
- package/node_modules/typebox/build/schema/errors.mjs +1 -1
- package/node_modules/typebox/build/schema/intern/intern.d.mts +9 -6
- package/node_modules/typebox/build/schema/intern/intern.mjs +56 -90
- package/node_modules/typebox/build/schema/parse.mjs +0 -3
- package/node_modules/typebox/build/schema/pointer/pointer.d.mts +6 -1
- package/node_modules/typebox/build/schema/pointer/pointer.mjs +64 -47
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +32 -6
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +227 -231
- package/node_modules/typebox/build/schema/schema.d.mts +0 -1
- package/node_modules/typebox/build/schema/schema.mjs +0 -1
- package/node_modules/typebox/build/system/hashing/hash.mjs +34 -63
- package/node_modules/typebox/build/system/locale/en_US.mjs +1 -2
- package/node_modules/typebox/build/system/memory/assign.d.mts +8 -2
- package/node_modules/typebox/build/system/memory/assign.mjs +6 -13
- package/node_modules/typebox/build/system/memory/clone.d.mts +5 -4
- package/node_modules/typebox/build/system/memory/clone.mjs +96 -8
- package/node_modules/typebox/build/system/memory/create.d.mts +5 -1
- package/node_modules/typebox/build/system/memory/create.mjs +13 -18
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +8 -9
- package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +4 -1
- package/node_modules/typebox/build/system/memory/update.mjs +16 -43
- package/node_modules/typebox/build/system/settings/settings.d.mts +0 -11
- package/node_modules/typebox/build/system/settings/settings.mjs +0 -14
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +24 -2
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +29 -2
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +1 -5
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +1 -6
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +4 -1
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +4 -1
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +4 -1
- package/node_modules/typebox/build/type/extends/inference.d.mts +1 -1
- package/node_modules/typebox/build/type/extends/inference.mjs +2 -15
- package/node_modules/typebox/build/type/extends/tuple.d.mts +1 -2
- package/node_modules/typebox/build/type/extends/tuple.mjs +1 -21
- package/node_modules/typebox/build/value/clean/from_object.mjs +1 -1
- package/node_modules/typebox/build/value/clone/clone.d.mts +3 -4
- package/node_modules/typebox/build/value/clone/clone.mjs +7 -5
- package/node_modules/typebox/build/value/parse/parse.mjs +4 -10
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +14 -25
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +84 -52
- package/package.json +11 -3
- package/skills/pi-proactive/SKILL.md +27 -24
- package/tools/cli.mjs +121 -0
- package/tools/daemon-install.sh +397 -0
- package/tools/daemon-uninstall.sh +226 -0
- package/node_modules/typebox/build/guard/unicode/unicode.d.mts +0 -6
- package/node_modules/typebox/build/guard/unicode/unicode.mjs +0 -35
- package/node_modules/typebox/build/schema/engine/_pathing.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/_pathing.mjs +0 -11
- package/node_modules/typebox/build/schema/meta/draft_2019_09.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_2019_09.mjs +0 -288
- package/node_modules/typebox/build/schema/meta/draft_2020_12.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_2020_12.mjs +0 -300
- package/node_modules/typebox/build/schema/meta/draft_3.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_3.mjs +0 -143
- package/node_modules/typebox/build/schema/meta/draft_4.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_4.mjs +0 -149
- package/node_modules/typebox/build/schema/meta/draft_6.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_6.mjs +0 -155
- package/node_modules/typebox/build/schema/meta/draft_7.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_7.mjs +0 -172
- package/node_modules/typebox/build/schema/meta/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/index.mjs +0 -2
- package/node_modules/typebox/build/schema/meta/meta.d.mts +0 -9
- package/node_modules/typebox/build/schema/meta/meta.mjs +0 -15
- package/node_modules/typebox/build/schema/meta/schema.d.mts +0 -6
- package/node_modules/typebox/build/schema/meta/schema.mjs +0 -1
- package/node_modules/typebox/build/system/memory/deep.d.mts +0 -2
- package/node_modules/typebox/build/system/memory/deep.mjs +0 -108
- package/node_modules/typebox/build/system/memory/finalize.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/finalize.mjs +0 -30
- package/node_modules/typebox/build/system/memory/keys.d.mts +0 -2
- package/node_modules/typebox/build/system/memory/keys.mjs +0 -8
- package/node_modules/typebox/build/system/settings/internal.d.mts +0 -2
- package/node_modules/typebox/build/system/settings/internal.mjs +0 -20
- package/node_modules/typebox/build/type/engine/call/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/call/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +0 -30
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +0 -29
- package/node_modules/typebox/build/type/engine/this/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/this/index.mjs +0 -1
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +0 -2
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +0 -6
- /package/node_modules/typebox/build/guard/{unicode/unicode_segment.d.mts → string.d.mts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## 0.2.0-beta.3 — 2026-10-29
|
|
11
|
+
|
|
12
|
+
### 新增
|
|
13
|
+
- **交付形态**:`pi-proactive` npm 包新增 **bin 入口**(`npx pi-proactive daemon install` / `npm i -g`),无需仓库、无需 bash。
|
|
14
|
+
- **一键常驻助理**:一条命令安装常驻进程(自动检测平台/双宿主,herdr 优先、系统宿主兜底接管)→ 回执「已常驻」+ 三证据自检 → 卸载零残留。
|
|
15
|
+
- **主动联系**:常驻进程在会话离线时仍能主动联系并进入「它联系了我什么」清单;找不到已登记会话则不联系(留审计记录);会话投递与设备通知双通道去重。
|
|
16
|
+
- **ETA 与进度预期**:`/proactive progress`(人)· `progress_query`(AI)· 快照【进度与 ETA】段,三处同源同口径;输出为【区间 + 置信度 + 归因 + 第3层阻塞项】,无单点 ETA。
|
|
17
|
+
- **托付 → 目标驱动 → 自主推进**:三层主动性同一循环(目标 → 候选 → 打分 → 执行 → 结账 → 回灌),六条护栏(预算硬上限 / 权限阶梯 / 可中止 / 不越界 / 可追溯 / 未达成不得静默结账)。
|
|
18
|
+
- **配置可用性**:未知或拼错的配置项被指名(含最相近键建议),`/proactive config` 可查全部项与默认值;配置写入原子化 + 备份 + 可撤销。
|
|
19
|
+
- **跨平台交付**:安装/卸载/运行统一为 Node 入口(一份逻辑 + 三份注册)。
|
|
20
|
+
|
|
21
|
+
### 修复
|
|
22
|
+
- 产物包内路径解析按运行环境取真源(开发态 src / 产物态 build),修复「装上跑不起来」。
|
|
23
|
+
- 打包链每次先清空再构建,杜绝沿用陈旧产物(曾导致包内缺 daemon-host.js)。
|
|
24
|
+
- 安装失败自动回滚;卸载失败报告残留并给出清理命令。
|
|
25
|
+
- 门禁新增:G17 外置内容完整性 · G18 推进质量保障;G3 排除 node_modules;G5 纳入团队脚本与交付制品。
|
|
26
|
+
|
|
10
27
|
## 0.2.0-beta.2(专有 **产物包** 版:分发物不含源码)
|
|
11
28
|
|
|
12
29
|
- **许可**:`license` 由 `MIT` 改为 **`SEE LICENSE IN LICENSE`**;新增**私有协议正文**文件 `LICENSE`(版权所有 / 仅限内部授权使用 / **禁止再分发** / 禁止反编译与再授权 / 授权期限与联系)
|
|
@@ -17,6 +34,18 @@
|
|
|
17
34
|
- **新增** `scripts/tests/publish-preflight.test.sh`:上述判据的红→绿回归自测(含「`UNLICENSED` + 公开仍阻断」的回归用例)
|
|
18
35
|
- **实现修正**:`src/health.ts` 的 `pluginVersion()` 支持产物态落位(`build/src/` → 上两级读 `package.json`),否则产物包内 `/proactive doctor` 会报版本 `unknown`
|
|
19
36
|
- **前置动作**:beta.1(MIT 元数据、公开可下载)已由版权方在 npm 网页端撤销(`npm view pi-proactive` → 404),包名可重新占用
|
|
37
|
+
- **发布**:已发到公共 npm —— `pi-proactive@0.2.0-beta.2`(dist-tag `latest` / `beta`;`license: SEE LICENSE IN LICENSE`;tarball 472.6 kB / 解包 2.2 MB / 1450 文件,其中 1449 个是 bundled typebox);`npm view pi-proactive` 已复核版本 / description / license
|
|
38
|
+
|
|
39
|
+
### 分发形态变更的宿主验证(证据)
|
|
40
|
+
|
|
41
|
+
| 验证项 | 命令 | 实测结果 |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| 宿主接受 `.js` 入口 | `pi --mode rpc --no-session` + `get_commands`(隔离 agent 目录安装产物包) | 回显 `"sourceInfo":{"path":".../build/extensions/proactive.js"}` 且命令名 `proactive` 已注册 |
|
|
44
|
+
| 产物包内 typebox 可解析 | `node -e "import('.../build/extensions/proactive.js')"` | `LOADED OK, default export type = function`(不依赖宿主 alias) |
|
|
45
|
+
| 产物态版本号正确 | `/proactive doctor --json` | `"pluginVersion": "0.2.0-beta.2"`(修复前为 `unknown`) |
|
|
46
|
+
| 分发物零 `.ts` | `tar -tzf pi-proactive-0.2.0-beta.2.tgz` 后统计以 `.ts` 结尾的条目 | `0` |
|
|
47
|
+
| 发布前检查 | `bash scripts/ci/publish-preflight.sh --registry https://registry.npmjs.org --public` | 「✅ 检查通过」(退出码 0) |
|
|
48
|
+
| 公开 npm 安装 | `pi install npm:pi-proactive` + 同上 rpc 检查 | 已注册 `proactive`,路径 `.../npm/node_modules/pi-proactive/build/extensions/proactive.js` |
|
|
20
49
|
|
|
21
50
|
## 许可与分发
|
|
22
51
|
|
package/README.md
CHANGED
|
@@ -380,28 +380,30 @@ Usage: `/proactive <子命令>`。下表**逐条对应实现里实际注册的
|
|
|
380
380
|
`switch`),未列出的子命令会被拒绝并提示可用清单。
|
|
381
381
|
|
|
382
382
|
> **命令面真源 = 实现**:下表由 `scripts/gen-doc-tables.sh` 从 `pi-proactive/src/commands.ts` 的
|
|
383
|
-
> `SUBCOMMANDS` + `switch (sub)` 的 case 分派**自动生成**(共 **
|
|
383
|
+
> `SUBCOMMANDS` + `switch (sub)` 的 case 分派**自动生成**(共 **18 个命令**),**不要手改**;
|
|
384
384
|
> 要改命令面请改实现,然后跑 `bash scripts/gen-doc-tables.sh --apply`(门禁 `scripts/check-doc-tables.sh` 校验)。
|
|
385
385
|
|
|
386
386
|
<!-- BEGIN:GEN commands -->
|
|
387
387
|
| 命令 | 参数形态 | 做什么 | 状态 |
|
|
388
388
|
| --- | --- | --- | --- |
|
|
389
|
-
| `/proactive status` | `无` | 总览:开关、空闲计时、待触发任务、对端在线、上次主动、本小时用量。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
390
|
-
| `/proactive on` | `无` | 打开全部「代理自发」行为(空闲触发、模型自调度、跨会话自发请求)。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
391
|
-
| `/proactive off` | `无` | 关闭全部「代理自发」行为;已排期任务保留但不再触发。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
392
|
-
| `/proactive test` | `无` | 立即模拟一次触发(走完整「护栏 → 投递」链路),用于验证主动能力是否真的生效。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
393
|
-
| `/proactive tasks` | `无` | 列出所有待触发任务(编号 / 类型 / 下次到期 / 归属 / 触发次数)。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
394
|
-
| `/proactive cancel` | `<id>` | 取消一个任务。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
395
|
-
| `/proactive idle` | `on\|off` | 打开 / 关闭空闲触发并设定阈值(on 可带时长参数,省略 = 用上次设定)。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
396
|
-
| `/proactive peers` | `[--all\|--idle\|--name <子串>\|--detail <agentId>]` | 列出已注册的对端与在线状态(名字 / 忙闲 / 最后心跳);可加 --all / --idle / --name / --detail。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
397
|
-
| `/proactive spawn` | `[名字]` | 创建一个对端会话(子进程 pi --mode rpc);本会话退出时一并终止。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
398
|
-
| `/proactive in` | `<时长> <内容>` | 排一个延迟任务(默认只属于当前会话)。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
399
|
-
| `/proactive at` | `<HH:MM> <内容>` | 排一个绝对时间任务。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
400
|
-
| `/proactive every` | `<时长> <内容>` | 排一个周期任务。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
401
|
-
| `/proactive help` | `无` | 打印命令速查表(命令表 / 配置键 / 最常见故障 / 详细文档路径)。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
402
|
-
| `/proactive history` | `[peer\|me] [条数]` | 查看最近的主动行为记录(时间 / 类型 / 目标 / 结果 / 被护栏拦下的原因)。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
403
|
-
| `/proactive doctor` | `[--json]` | 只读体检:逐项健康判定 + 处置建议(--json 机器可读);不打扰、不耗额度。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
404
|
-
| `/proactive
|
|
389
|
+
| `/proactive status` | `无` | 总览:开关、空闲计时、待触发任务、对端在线、上次主动、本小时用量。 | 已实现 · `pi-proactive/src/commands.ts:617` |
|
|
390
|
+
| `/proactive on` | `无` | 打开全部「代理自发」行为(空闲触发、模型自调度、跨会话自发请求)。 | 已实现 · `pi-proactive/src/commands.ts:653` |
|
|
391
|
+
| `/proactive off` | `无` | 关闭全部「代理自发」行为;已排期任务保留但不再触发。 | 已实现 · `pi-proactive/src/commands.ts:654` |
|
|
392
|
+
| `/proactive test` | `无` | 立即模拟一次触发(走完整「护栏 → 投递」链路),用于验证主动能力是否真的生效。 | 已实现 · `pi-proactive/src/commands.ts:732` |
|
|
393
|
+
| `/proactive tasks` | `无` | 列出所有待触发任务(编号 / 类型 / 下次到期 / 归属 / 触发次数)。 | 已实现 · `pi-proactive/src/commands.ts:735` |
|
|
394
|
+
| `/proactive cancel` | `<id>` | 取消一个任务。 | 已实现 · `pi-proactive/src/commands.ts:761` |
|
|
395
|
+
| `/proactive idle` | `on\|off` | 打开 / 关闭空闲触发并设定阈值(on 可带时长参数,省略 = 用上次设定)。 | 已实现 · `pi-proactive/src/commands.ts:801` |
|
|
396
|
+
| `/proactive peers` | `[--all\|--idle\|--name <子串>\|--detail <agentId>]` | 列出已注册的对端与在线状态(名字 / 忙闲 / 最后心跳);可加 --all / --idle / --name / --detail。 | 已实现 · `pi-proactive/src/commands.ts:674` |
|
|
397
|
+
| `/proactive spawn` | `[名字]` | 创建一个对端会话(子进程 pi --mode rpc);本会话退出时一并终止。 | 已实现 · `pi-proactive/src/commands.ts:709` |
|
|
398
|
+
| `/proactive in` | `<时长> <内容>` | 排一个延迟任务(默认只属于当前会话)。 | 已实现 · `pi-proactive/src/commands.ts:779` |
|
|
399
|
+
| `/proactive at` | `<HH:MM> <内容>` | 排一个绝对时间任务。 | 已实现 · `pi-proactive/src/commands.ts:780` |
|
|
400
|
+
| `/proactive every` | `<时长> <内容>` | 排一个周期任务。 | 已实现 · `pi-proactive/src/commands.ts:781` |
|
|
401
|
+
| `/proactive help` | `无` | 打印命令速查表(命令表 / 配置键 / 最常见故障 / 详细文档路径)。 | 已实现 · `pi-proactive/src/commands.ts:816` |
|
|
402
|
+
| `/proactive history` | `[peer\|me] [条数]` | 查看最近的主动行为记录(时间 / 类型 / 目标 / 结果 / 被护栏拦下的原因)。 | 已实现 · `pi-proactive/src/commands.ts:739` |
|
|
403
|
+
| `/proactive doctor` | `[--json]` | 只读体检:逐项健康判定 + 处置建议(--json 机器可读);不打扰、不耗额度。 | 已实现 · `pi-proactive/src/commands.ts:625` |
|
|
404
|
+
| `/proactive progress` | `无` | 项目进度 + ETA:区间 + 置信度 + 归因 + 阻塞项(不给单点数字;口径 = scripts/progress-clock.py)。 | 已实现 · `pi-proactive/src/commands.ts:633` |
|
|
405
|
+
| `/proactive tell` | `<peer> <内容> [--kind ask\|task\|notify]` | 人侧给另一个会话下指令(--kind ask\|task\|notify,缺省 ask 要回话);回信落回本会话。 | 已实现 · `pi-proactive/src/commands.ts:729` |
|
|
406
|
+
| `/proactive config` | `[undo] [--json]` | 列出全部配置项(当前值 / 缺省值 / 取值范围 / 一句说明),先报警写错的项;config undo 撤销上一次配置改动。 | 已实现 · `pi-proactive/src/commands.ts:640` |
|
|
405
407
|
<!-- END:GEN commands -->
|
|
406
408
|
|
|
407
409
|
排期命令的排期结果会**当场回执**(任务 id、相对到期、绝对到期),任务**落盘**在任务表里,进程退出后仍在,
|
|
@@ -419,17 +421,18 @@ Usage: `/proactive <子命令>`。下表**逐条对应实现里实际注册的
|
|
|
419
421
|
<!-- BEGIN:GEN tools -->
|
|
420
422
|
| 工具 | 参数 | 作用 | 定义位置 |
|
|
421
423
|
| --- | --- | --- | --- |
|
|
422
|
-
| `schedule_task` | prompt(必填):任务提示词<br>intent(可选):投递意图,默认 wake(取值:wake \| interrupt \| queue \| notify)<br>askUser(可选):触发时是否向用户提问(仅本地)<br>when(可选):触发时间:时长(10m)/ 时刻(18:30)/ ISO 8601;缺省按 10m 处理 | 预约一个稍后触发的任务(真正落库到任务表,到点由调度器投递)。when 支持时长(10m)、时刻(18:30)或 ISO 时间;缺省按 10m 处理。 | `pi-proactive/extensions/proactive.ts:
|
|
423
|
-
| `message_agent` | to(必填):目标 agent 的名字或 agentId<br>kind(可选):消息语义(对方要不要回我);缺省 notify(取值:notify \| ask \| task \| reply \| broadcast)<br>subject(可选):标题<br>body(必填):正文<br>intent(可选):投递意图(怎么投给对方);缺省 wake(取值:wake \| interrupt \| queue \| notify)<br>threadId(可选):话题 / 会话 id(可选) | 给另一个正在运行的 agent 会话发消息(跨进程协作)。对端在线时走 socket 直达;不在线时消息落盘到对端邮箱,待其上线后处理。 | `pi-proactive/extensions/proactive.ts:
|
|
424
|
-
| `list_peers` | name(可选):名字子串(大小写敏感;也命中 agentId)。同名歧义时返回与 message_agent 报错完全一致的候选<br>status(可选):按在场状态过滤(online = 在线 = 空闲 ∪ 忙碌)(取值:online \| idle \| busy \| offline)<br>capability(可选):按能力标签过滤(如 message_agent)<br>includeOffline(可选):是否包含离线对端(缺省 false = 只给在线) | 列出本机可见的其它 agent 对端(名字 / agentId / 在场状态 / 心跳龄 / 能力标签 / 在途任务数 / 传输方式),可按名字、状态、能力过滤。**只读**:不产生任何对外行为。发消息前先查它(先查后发),别盲发 —— 离线对端现在打扰它不合适。 | `pi-proactive/extensions/proactive.ts:
|
|
425
|
-
| `proactive_query` | action(必填):查询动作(与 /proactive 子命令同名)(取值:peers \| history \| status \| tasks \| doctor \| help)<br>name(可选):peers:名字子串过滤<br>all(可选):peers:是否包含离线对端<br>idle(可选):peers:只看空闲对端<br>detail(可选):peers:只看这一个 agentId<br>scope(可选):history:范围(对端 / 我)(取值:peer \| me)<br>peer(可选):history:按对端 agentId 过滤<br>limit(可选):history:条数(1-200 的整数)<br>json(可选):doctor:输出 JSON | 查询域:查对端(peers)/ 看主动行为历史(history)/ 看状态(status)/ 看任务(tasks)/ 只读体检(doctor)/ 看命令手册(help)。**只读**:不产生任何对外行为。 | `pi-proactive/extensions/proactive.ts:
|
|
426
|
-
| `
|
|
427
|
-
| `
|
|
428
|
-
| `
|
|
424
|
+
| `schedule_task` | prompt(必填):任务提示词<br>intent(可选):投递意图,默认 wake(取值:wake \| interrupt \| queue \| notify)<br>askUser(可选):触发时是否向用户提问(仅本地)<br>when(可选):触发时间:时长(10m)/ 时刻(18:30)/ ISO 8601;缺省按 10m 处理 | 预约一个稍后触发的任务(真正落库到任务表,到点由调度器投递)。when 支持时长(10m)、时刻(18:30)或 ISO 时间;缺省按 10m 处理。 | `pi-proactive/extensions/proactive.ts:640` |
|
|
425
|
+
| `message_agent` | to(必填):目标 agent 的名字或 agentId<br>kind(可选):消息语义(对方要不要回我);缺省 notify(取值:notify \| ask \| task \| reply \| broadcast)<br>subject(可选):标题<br>body(必填):正文<br>intent(可选):投递意图(怎么投给对方);缺省 wake(取值:wake \| interrupt \| queue \| notify)<br>threadId(可选):话题 / 会话 id(可选) | 给另一个正在运行的 agent 会话发消息(跨进程协作)。对端在线时走 socket 直达;不在线时消息落盘到对端邮箱,待其上线后处理。 | `pi-proactive/extensions/proactive.ts:685` |
|
|
426
|
+
| `list_peers` | name(可选):名字子串(大小写敏感;也命中 agentId)。同名歧义时返回与 message_agent 报错完全一致的候选<br>status(可选):按在场状态过滤(online = 在线 = 空闲 ∪ 忙碌)(取值:online \| idle \| busy \| offline)<br>capability(可选):按能力标签过滤(如 message_agent)<br>includeOffline(可选):是否包含离线对端(缺省 false = 只给在线) | 列出本机可见的其它 agent 对端(名字 / agentId / 在场状态 / 心跳龄 / 能力标签 / 在途任务数 / 传输方式),可按名字、状态、能力过滤。**只读**:不产生任何对外行为。发消息前先查它(先查后发),别盲发 —— 离线对端现在打扰它不合适。 | `pi-proactive/extensions/proactive.ts:759` |
|
|
427
|
+
| `proactive_query` | action(必填):查询动作(与 /proactive 子命令同名)(取值:peers \| history \| status \| tasks \| doctor \| help \| config)<br>name(可选):peers:名字子串过滤<br>all(可选):peers:是否包含离线对端<br>idle(可选):peers:只看空闲对端<br>detail(可选):peers:只看这一个 agentId<br>scope(可选):history:范围(对端 / 我)(取值:peer \| me)<br>peer(可选):history:按对端 agentId 过滤<br>limit(可选):history:条数(1-200 的整数)<br>json(可选):doctor / config:输出 JSON | 查询域:查对端(peers)/ 看主动行为历史(history)/ 看状态(status)/ 看任务(tasks)/ 只读体检(doctor)/ 看命令手册(help)/ 查配置清单(config)。**只读**:不产生任何对外行为。 | `pi-proactive/extensions/proactive.ts:796` |
|
|
428
|
+
| `progress_query` | | 查项目进度与 ETA:返回**区间 + 置信度 + 归因 + 阻塞项**(不给单点数字)。口径唯一(scripts/progress-clock.py),与人侧 `/proactive progress` 同源同口径、逐字一致。**只读**:不产生任何对外行为。 | `pi-proactive/extensions/proactive.ts:822` |
|
|
429
|
+
| `proactive_schedule` | action(必填):排程动作(与 /proactive 子命令同名)(取值:in \| at \| every \| cancel)<br>when(可选):in/at/every:触发时间(时长 10m / 时刻 18:30)<br>content(可选):in/at/every:任务内容<br>id(可选):cancel:任务 id | 排程域:定时(in)/ 定点(at)/ 周期(every)/ 取消(cancel)。落到真实任务表,到点由调度器投递;与命令面 `/proactive in\|at\|every\|cancel` 同源。 | `pi-proactive/extensions/proactive.ts:836` |
|
|
430
|
+
| `proactive_peer` | action(必填):对端动作(与 /proactive 子命令同名)(取值:tell \| spawn)<br>peer(可选):tell:目标对端(名字或 agentId)<br>content(可选):tell:指令内容<br>kind(可选):tell:指令类型(缺省 ask)(取值:ask \| task \| notify)<br>subject(可选):tell:标题<br>thread(可选):tell:线程 id<br>name(可选):spawn:对端名字 | 对端协作域:给对端下指令(tell)/ 创建对端会话(spawn,受同时存活数上限)。tell 的目标解析与回执三态与命令面 `/proactive tell` 完全同源。 | `pi-proactive/extensions/proactive.ts:855` |
|
|
431
|
+
| `proactive_manage` | action(必填):管理动作(与 /proactive 子命令同名)(取值:on \| off \| idle \| test)<br>state(可选):idle:开 / 关(取值:on \| off) | 管理域:主动性总开关(on/off)、空闲触发开关(idle)、自检(test)。这些能力属 human-gated:调用只会回报「需人工确认」并给出可复制的人工指令,**不会**自行改动全局开关。 | `pi-proactive/extensions/proactive.ts:877` |
|
|
429
432
|
<!-- END:GEN tools -->
|
|
430
433
|
|
|
431
434
|
> **模型工具面真源 = 实现**:上表由 `scripts/gen-doc-tables.sh` 从 `pi-proactive/extensions/proactive.ts` 的
|
|
432
|
-
> `pi.registerTool({ name: … })` 注册项与参数 schema **自动生成**(共 **
|
|
435
|
+
> `pi.registerTool({ name: … })` 注册项与参数 schema **自动生成**(共 **8 个模型工具**),**不要手改**;
|
|
433
436
|
> 表中参数即真实 schema。下面三个小节是逐个工具的展开说明。
|
|
434
437
|
|
|
435
438
|
### `schedule_task`
|
|
@@ -534,7 +537,7 @@ Usage: `/proactive <子命令>`。下表**逐条对应实现里实际注册的
|
|
|
534
537
|
| `limits.quietHours` | `未设` | 静默时段 {from,to}(HH:MM,from 大于 to 表示跨零点),时段内不主动打扰。 | `pi-proactive/src/config.ts:386` |
|
|
535
538
|
| `peerWatch.enabled` | `false` | 跨会话空闲协作(peer watch)开关。 | `pi-proactive/src/config.ts:351` |
|
|
536
539
|
| `peerWatch.afterIdleMs` | `600000` | 连续空闲多久后才去询问 peer(毫秒)。 | `pi-proactive/src/config.ts:352` |
|
|
537
|
-
| `version` | `"v1"` | 落盘格式版本;无法识别时拒绝按已知格式解析(保留原文件,不覆盖)。 | `pi-proactive/src/config.ts:
|
|
540
|
+
| `version` | `"v1"` | 落盘格式版本;无法识别时拒绝按已知格式解析(保留原文件,不覆盖)。 | `pi-proactive/src/config.ts:1100` |
|
|
538
541
|
<!-- END:GEN config -->
|
|
539
542
|
|
|
540
543
|
> **配置面真源 = 实现**:上表由 `scripts/gen-doc-tables.sh` 从 `pi-proactive/src/config.ts` 的
|
|
@@ -583,8 +586,9 @@ agents/<ref>.md # agent 定义
|
|
|
583
586
|
- 解析后的路径必须留在配置根目录内(越界路径与指向外部的符号链接都拒绝);
|
|
584
587
|
- 内容**单次读入快照**(外部程序同时改文件也不会读到半截内容)。
|
|
585
588
|
|
|
586
|
-
示例:`pi-proactive/agents/example-reviewer.md
|
|
587
|
-
|
|
589
|
+
示例:`pi-proactive/agents/example-reviewer.md`(agent 定义)与 `pi-proactive/prompts/idle-probe.md`(提示词)——
|
|
590
|
+
复制到 `<agent-dir>/proactive/agents/` 或 `<agent-dir>/proactive/prompts/` 后,
|
|
591
|
+
即可被上面的 `agentRef` / `promptRef` 引用。
|
|
588
592
|
|
|
589
593
|
> `<agent-dir>/proactive/agents/` 下同时存在**两种**东西:对端注册表 `agents/<agentId>.json`
|
|
590
594
|
> 与外置 agent 定义 `agents/<ref>.md` —— 按扩展名区分,互不覆盖。
|
package/build/cli.mjs
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// pi-proactive CLI —— 交付入口(npm bin / npx / 全局安装都指向这里)
|
|
3
|
+
// 目标:用户只跑 `npx pi-proactive daemon install`,不需要仓库、不需要 bash。
|
|
4
|
+
//
|
|
5
|
+
// 单一真源:本文件是 build/cli.mjs 的**源文件**(build/ 是编译产物,不入库)。
|
|
6
|
+
// build-release.sh 负责把它复制到 build/cli.mjs → npm 包的 bin 入口。
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
|
|
12
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const pkgRoot = path.resolve(here, "..");
|
|
14
|
+
const argv = process.argv.slice(2);
|
|
15
|
+
const cmd = argv[0];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 本 CLI 会转发给常驻脚本的参数(**参数契约的单一真源**)。
|
|
19
|
+
*
|
|
20
|
+
* 为什么要有它:cli 转发参数、被调 .sh 解析参数,两边各写各的就会出现
|
|
21
|
+
* 「cli 传 --host、.sh 报未知参数」这类契约漂移(2026-10-29 实测根因 2)。
|
|
22
|
+
* 契约测试(pi-proactive/tests/daemon-packaged-runtime.test.ts)据此断言:
|
|
23
|
+
* **这里列出的每个参数,两个 .sh 都必须接受**。
|
|
24
|
+
*/
|
|
25
|
+
const CLI_FLAGS = {
|
|
26
|
+
install: [
|
|
27
|
+
"--host",
|
|
28
|
+
"--agent-dir",
|
|
29
|
+
"--agent-id",
|
|
30
|
+
"--label",
|
|
31
|
+
"--service-name",
|
|
32
|
+
"--no-start",
|
|
33
|
+
],
|
|
34
|
+
uninstall: [
|
|
35
|
+
"--host",
|
|
36
|
+
"--agent-dir",
|
|
37
|
+
"--agent-id",
|
|
38
|
+
"--label",
|
|
39
|
+
"--service-name",
|
|
40
|
+
"--no-start",
|
|
41
|
+
"--purge-data",
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const USAGE = `pi-proactive — 给 Pi 增加主动性(空闲主动、按点主动、多会话协作)
|
|
46
|
+
|
|
47
|
+
用法:
|
|
48
|
+
pi-proactive daemon install 安装并启动常驻助理(回执「已常驻」)
|
|
49
|
+
pi-proactive daemon uninstall 卸载常驻助理(残留终检为空)
|
|
50
|
+
pi-proactive doctor 巡检健康
|
|
51
|
+
pi-proactive progress 进度与 ETA(区间/置信度/阻塞项)
|
|
52
|
+
pi-proactive config 查看配置(全部项/当前值/默认值/范围/说明)
|
|
53
|
+
pi-proactive history 主动行为与应答的血缘记录
|
|
54
|
+
|
|
55
|
+
安装(任选其一):
|
|
56
|
+
npx pi-proactive daemon install
|
|
57
|
+
npm i -g pi-proactive && pi-proactive daemon install
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
function run(file, args) {
|
|
61
|
+
return new Promise((resolve) => {
|
|
62
|
+
const p = spawn(file, args, { stdio: "inherit" });
|
|
63
|
+
p.on("close", (code) => resolve(code ?? 1));
|
|
64
|
+
p.on("error", () => resolve(2));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!cmd || cmd === "--help" || cmd === "-h" || cmd === "help") {
|
|
69
|
+
console.log(USAGE);
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const script = (name) => {
|
|
74
|
+
const p = path.join(pkgRoot, "tools", name);
|
|
75
|
+
return fs.existsSync(p) ? p : null;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** 参数白名单校验(**转发前**拦下未知参数 → 不把错误留给脚本去猜)。 */
|
|
79
|
+
function checkFlags(sub, args) {
|
|
80
|
+
const allowed = CLI_FLAGS[sub] ?? [];
|
|
81
|
+
for (const a of args) {
|
|
82
|
+
if (!a.startsWith("--")) continue;
|
|
83
|
+
const name = a.split("=")[0];
|
|
84
|
+
if (!allowed.includes(name)) {
|
|
85
|
+
console.error(`未知参数:${a}\n可用参数:${allowed.join(" ")}`);
|
|
86
|
+
process.exit(2);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (cmd === "daemon") {
|
|
92
|
+
const sub = argv[1];
|
|
93
|
+
const map = {
|
|
94
|
+
install: "daemon-install.sh",
|
|
95
|
+
uninstall: "daemon-uninstall.sh",
|
|
96
|
+
};
|
|
97
|
+
const file = map[sub];
|
|
98
|
+
if (!file) {
|
|
99
|
+
console.error(`未知子命令:daemon ${sub ?? ""}\n${USAGE}`);
|
|
100
|
+
process.exit(2);
|
|
101
|
+
}
|
|
102
|
+
const s = script(file);
|
|
103
|
+
if (!s) {
|
|
104
|
+
console.error(`包内缺少 ${file} —— 请重新安装 pi-proactive`);
|
|
105
|
+
process.exit(2);
|
|
106
|
+
}
|
|
107
|
+
const rest = argv.slice(2);
|
|
108
|
+
checkFlags(sub, rest);
|
|
109
|
+
const code = await run("bash", [s, ...rest]);
|
|
110
|
+
if (code !== 0 && sub === "install") {
|
|
111
|
+
// 失败即回滚(不给自己留 launchd 任务 / 进程 / 单元文件)。
|
|
112
|
+
console.error("[pi-proactive] 安装未成功 → 自动回滚(卸载自己刚注册的),避免留下残留");
|
|
113
|
+
const u = script("daemon-uninstall.sh");
|
|
114
|
+
if (u) await run("bash", [u, ...rest]);
|
|
115
|
+
}
|
|
116
|
+
process.exit(code);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 其余子命令暂由宿主命令面提供(保持"同一分派"口径);此处给出明确指引而非另写实现
|
|
120
|
+
console.error(`「${cmd}」由 Pi 宿主内的 /proactive ${cmd} 提供;请在 Pi 会话中执行。`);
|
|
121
|
+
process.exit(2);
|
|
@@ -27,7 +27,7 @@ import { randomUUID } from "node:crypto";
|
|
|
27
27
|
import os from "node:os";
|
|
28
28
|
import path from "node:path";
|
|
29
29
|
import { Type } from "typebox";
|
|
30
|
-
import { PROACTIVE_FILE_MODE, chmodQuiet, defaultConfig, ensureDir, hardenProactivePermissions, loadConfig, resolveAgentDir, saveEnabled, } from "../src/config.js";
|
|
30
|
+
import { PROACTIVE_FILE_MODE, chmodQuiet, defaultConfig, ensureDir, hardenProactivePermissions, loadConfig, resolveAgentDir, saveEnabled, ConfigValidationError } from "../src/config.js";
|
|
31
31
|
import { ActivityTracker } from "../src/activity.js";
|
|
32
32
|
import { Guard } from "../src/guard.js";
|
|
33
33
|
import { Trigger } from "../src/trigger.js";
|
|
@@ -286,11 +286,27 @@ let peerWatch;
|
|
|
286
286
|
const threadStores = new Map();
|
|
287
287
|
/** peer watch 扫描节流(ms):注册表读盘不必每秒做。 */
|
|
288
288
|
let lastPeerWatchAt = 0;
|
|
289
|
+
/**
|
|
290
|
+
* 最近一次**配置校验错误**(拼错的配置项 → 必须让用户看见,不得静默忽略)。
|
|
291
|
+
*
|
|
292
|
+
* 通道限制:配置加载发生在宿主给出 `ctx` 之前 → 先存起来,
|
|
293
|
+
* 由 `session_start`(拿得到 `ctx.ui.notify`)呈现给用户(stderr 亦有一份)。
|
|
294
|
+
*/
|
|
295
|
+
let pendingConfigError;
|
|
289
296
|
function safeConfig() {
|
|
290
297
|
try {
|
|
298
|
+
pendingConfigError = undefined;
|
|
291
299
|
return loadConfig();
|
|
292
300
|
}
|
|
293
|
-
catch {
|
|
301
|
+
catch (err) {
|
|
302
|
+
if (err instanceof ConfigValidationError) {
|
|
303
|
+
// M8:未知配置项 → **报错并指名**(键名 + 文件路径 + 建议值)。
|
|
304
|
+
pendingConfigError = err.message;
|
|
305
|
+
console.error(err.message);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
console.error("[proactive] 配置加载失败:", err);
|
|
309
|
+
}
|
|
294
310
|
return defaultConfig();
|
|
295
311
|
}
|
|
296
312
|
}
|
|
@@ -332,7 +348,7 @@ const scheduleTaskParameters = Type.Object({
|
|
|
332
348
|
* 参数名与命令面一致(`when` / `content` / `id` / `peer` / `scope` / `limit` / `name` / `all` …),
|
|
333
349
|
* `action` 的取值就是命令面的子命令名 → 语义同源、可机检。
|
|
334
350
|
*/
|
|
335
|
-
/** 查询域:查对端 / 看历史 / 看状态 / 看任务 / 只读体检 /
|
|
351
|
+
/** 查询域:查对端 / 看历史 / 看状态 / 看任务 / 只读体检 / 看手册 / 查配置清单。 */
|
|
336
352
|
const proactiveQueryParameters = Type.Object({
|
|
337
353
|
action: Type.Union([
|
|
338
354
|
Type.Literal("peers"),
|
|
@@ -341,6 +357,7 @@ const proactiveQueryParameters = Type.Object({
|
|
|
341
357
|
Type.Literal("tasks"),
|
|
342
358
|
Type.Literal("doctor"),
|
|
343
359
|
Type.Literal("help"),
|
|
360
|
+
Type.Literal("config"),
|
|
344
361
|
], { description: "查询动作(与 /proactive 子命令同名)" }),
|
|
345
362
|
name: Type.Optional(Type.String({ description: "peers:名字子串过滤" })),
|
|
346
363
|
all: Type.Optional(Type.Boolean({ description: "peers:是否包含离线对端" })),
|
|
@@ -349,8 +366,15 @@ const proactiveQueryParameters = Type.Object({
|
|
|
349
366
|
scope: Type.Optional(Type.Union([Type.Literal("peer"), Type.Literal("me")], { description: "history:范围(对端 / 我)" })),
|
|
350
367
|
peer: Type.Optional(Type.String({ description: "history:按对端 agentId 过滤" })),
|
|
351
368
|
limit: Type.Optional(Type.String({ description: "history:条数(1-200 的整数)" })),
|
|
352
|
-
json: Type.Optional(Type.Boolean({ description: "doctor:输出 JSON" })),
|
|
369
|
+
json: Type.Optional(Type.Boolean({ description: "doctor / config:输出 JSON" })),
|
|
353
370
|
});
|
|
371
|
+
/**
|
|
372
|
+
* 进度 / ETA 查询(任务卡 ETA · E3)。
|
|
373
|
+
*
|
|
374
|
+
* 与人侧 `/proactive progress` **同源同口径**:同一个分派(`dispatchProactiveCommand`)→
|
|
375
|
+
* 同一份快照 → 两侧正文逐字一致。
|
|
376
|
+
*/
|
|
377
|
+
const progressQueryParameters = Type.Object({});
|
|
354
378
|
/** 排程域:定时 / 定点 / 周期 / 取消。 */
|
|
355
379
|
const proactiveScheduleParameters = Type.Object({
|
|
356
380
|
action: Type.Union([Type.Literal("in"), Type.Literal("at"), Type.Literal("every"), Type.Literal("cancel")], { description: "排程动作(与 /proactive 子命令同名)" }),
|
|
@@ -651,7 +675,7 @@ export default function proactiveExtension(pi) {
|
|
|
651
675
|
pi.registerTool({
|
|
652
676
|
name: "proactive_query",
|
|
653
677
|
label: "Proactive Query",
|
|
654
|
-
description: "查询域:查对端(peers)/ 看主动行为历史(history)/ 看状态(status)/ 看任务(tasks)/ 只读体检(doctor)/ 看命令手册(help)。" +
|
|
678
|
+
description: "查询域:查对端(peers)/ 看主动行为历史(history)/ 看状态(status)/ 看任务(tasks)/ 只读体检(doctor)/ 看命令手册(help)/ 查配置清单(config)。" +
|
|
655
679
|
"**只读**:不产生任何对外行为。",
|
|
656
680
|
parameters: proactiveQueryParameters,
|
|
657
681
|
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
@@ -675,12 +699,24 @@ export default function proactiveExtension(pi) {
|
|
|
675
699
|
if (params.limit !== undefined && /^\d+$/.test(params.limit))
|
|
676
700
|
parts.push(params.limit);
|
|
677
701
|
}
|
|
678
|
-
else if (params.action === "doctor" && params.json === true) {
|
|
702
|
+
else if ((params.action === "doctor" || params.action === "config") && params.json === true) {
|
|
679
703
|
parts.push("--json");
|
|
680
704
|
}
|
|
681
705
|
return dispatchTool(parts.join(" "), { action: params.action });
|
|
682
706
|
},
|
|
683
707
|
});
|
|
708
|
+
pi.registerTool({
|
|
709
|
+
name: "progress_query",
|
|
710
|
+
label: "Progress Query",
|
|
711
|
+
description: "查项目进度与 ETA:返回**区间 + 置信度 + 归因 + 阻塞项**(不给单点数字)。" +
|
|
712
|
+
"口径唯一(scripts/progress-clock.py),与人侧 `/proactive progress` 同源同口径、逐字一致。" +
|
|
713
|
+
"**只读**:不产生任何对外行为。",
|
|
714
|
+
parameters: progressQueryParameters,
|
|
715
|
+
async execute(_toolCallId, _params, _signal, _onUpdate, _ctx) {
|
|
716
|
+
// **同源**:与人侧 `/proactive progress` 走同一个分派 → 同一份快照 → 逐字一致。
|
|
717
|
+
return dispatchTool("progress", { capability: "progress-eta" });
|
|
718
|
+
},
|
|
719
|
+
});
|
|
684
720
|
pi.registerTool({
|
|
685
721
|
name: "proactive_schedule",
|
|
686
722
|
label: "Proactive Schedule",
|
|
@@ -785,8 +821,12 @@ export default function proactiveExtension(pi) {
|
|
|
785
821
|
return "activity-history";
|
|
786
822
|
case "doctor":
|
|
787
823
|
return "health-diagnose";
|
|
824
|
+
case "progress":
|
|
825
|
+
return "progress-eta";
|
|
788
826
|
case "help":
|
|
789
827
|
return "manual-help";
|
|
828
|
+
case "config":
|
|
829
|
+
return "config-inspect";
|
|
790
830
|
default:
|
|
791
831
|
return "unknown";
|
|
792
832
|
}
|
|
@@ -2184,6 +2224,7 @@ function formatHelp() {
|
|
|
2184
2224
|
" every <时长> <内容> 排期重复",
|
|
2185
2225
|
" test 强制走一次投递链路自检(不受总开关与冷却影响)",
|
|
2186
2226
|
" doctor [--json] 只读体检:插件面各面状态 + 判据 + 处置建议(不打扰、不耗额度)",
|
|
2227
|
+
" progress 项目进度 + ETA:区间 + 置信度 + 归因 + 阻塞项(不给单点数字)",
|
|
2187
2228
|
" tell <peer> <内容> 人侧给对端 agent 下指令(--kind ask|task|notify;缺省 ask)",
|
|
2188
2229
|
" help 本页",
|
|
2189
2230
|
"",
|
package/build/src/commands.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { IDLE_ENABLE_HINT, effectiveIdleDetect } from "./idle.js";
|
|
3
3
|
import { DEFAULT_WHEN_MS, SUPPORTED_DURATION_FORMATS, SUPPORTED_WHEN_FORMATS, parseScheduleExpression, } from "./scheduler.js";
|
|
4
|
-
import { resolveAgentDir } from "./config.js";
|
|
4
|
+
import { readConfigReport, resolveAgentDir, undoConfigChange, } from "./config.js";
|
|
5
5
|
import { formatHealthReport, healthToJson } from "./health.js";
|
|
6
6
|
import { formatLineageHistory } from "./lineage.js";
|
|
7
7
|
import { formatPeerDirectory, formatPeerList } from "./peer.js";
|
|
8
|
+
import { readProgressEta } from "./progress-eta.js";
|
|
8
9
|
import { Registry } from "./registry.js";
|
|
9
10
|
const DETECT_LABEL = {
|
|
10
11
|
terminal: "终端输入",
|
|
@@ -210,6 +211,59 @@ export function formatScheduleResult(task, now = Date.now(), info = {}) {
|
|
|
210
211
|
export function errText(err) {
|
|
211
212
|
return err instanceof Error ? err.message : String(err);
|
|
212
213
|
}
|
|
214
|
+
/** 配置值 → 人话(长文本截断,避免一屏塞不下)。 */
|
|
215
|
+
function formatConfigValue(value) {
|
|
216
|
+
if (value === undefined)
|
|
217
|
+
return "(未设置)";
|
|
218
|
+
if (typeof value === "string") {
|
|
219
|
+
if (value.length <= 60)
|
|
220
|
+
return `"${value}"`;
|
|
221
|
+
return `"${value.slice(0, 60)}…(共 ${value.length} 字)"`;
|
|
222
|
+
}
|
|
223
|
+
if (typeof value === "object") {
|
|
224
|
+
const text = JSON.stringify(value);
|
|
225
|
+
return text.length <= 60 ? text : `${text.slice(0, 60)}…`;
|
|
226
|
+
}
|
|
227
|
+
return String(value);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* `/proactive config` 的清单(M6):**全部配置项 + 当前值 + 默认值 + 取值范围 + 一句说明**。
|
|
231
|
+
*
|
|
232
|
+
* 为什么当前值取自**文件**(`readConfigReport` 的口径):文件才是用户写的东西;
|
|
233
|
+
* 运行期配置在有未知项时会整体回落缺省 → 用它会把「你写的值」显示成「缺省值」(更迷惑)。
|
|
234
|
+
*/
|
|
235
|
+
export function formatConfigReport(report) {
|
|
236
|
+
const lines = [];
|
|
237
|
+
lines.push(`配置清单(文件:${report.file}${report.exists ? "" : "(尚不存在 → 全部用缺省)"})`);
|
|
238
|
+
const unknown = report.issues.filter((issue) => issue.category === "unknown-key");
|
|
239
|
+
if (unknown.length > 0) {
|
|
240
|
+
lines.push("");
|
|
241
|
+
lines.push(`⚠ 有 ${unknown.length} 个配置项写错了(不会被静默忽略):`);
|
|
242
|
+
for (const issue of unknown) {
|
|
243
|
+
lines.push(` · 键 "${issue.key}"` + (issue.suggestion === undefined ? "" : ` → 你是不是想写 "${issue.suggestion}"?`));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const typeIssues = report.issues.filter((issue) => issue.category === "type-mismatch");
|
|
247
|
+
if (typeIssues.length > 0) {
|
|
248
|
+
lines.push("");
|
|
249
|
+
lines.push(`⚠ 有 ${typeIssues.length} 个配置项类型不对(已按缺省值处理):`);
|
|
250
|
+
for (const issue of typeIssues)
|
|
251
|
+
lines.push(` · ${issue.message}`);
|
|
252
|
+
}
|
|
253
|
+
let section = "";
|
|
254
|
+
for (const item of report.items) {
|
|
255
|
+
if (item.section !== section) {
|
|
256
|
+
section = item.section;
|
|
257
|
+
lines.push("");
|
|
258
|
+
lines.push(`【${section}】`);
|
|
259
|
+
}
|
|
260
|
+
lines.push(` ${item.path.padEnd(30)}当前:${formatConfigValue(item.current)} 缺省:${formatConfigValue(item.defaultValue)} 取值:${item.range}`);
|
|
261
|
+
lines.push(` ${item.description}`);
|
|
262
|
+
}
|
|
263
|
+
lines.push("");
|
|
264
|
+
lines.push("改法:直接改上面的文件(写错的键会被指名,不会静默忽略);开关类用 /proactive on|off;撤销上一次改动:/proactive config undo。");
|
|
265
|
+
return lines.join("\n");
|
|
266
|
+
}
|
|
213
267
|
/**
|
|
214
268
|
* human-gated 回执文案(**单一真源**:模型工具面用;命令面不经过这里 —— 命令面由人触发)。
|
|
215
269
|
*
|
|
@@ -223,7 +277,9 @@ export function formatHumanGatedNotice(notice) {
|
|
|
223
277
|
export const SUBCOMMANDS = "status | on | off | test | tasks | cancel <id> | idle on|off | peers [--all|--idle|--name <子串>|--detail <agentId>] | spawn [名字]" +
|
|
224
278
|
" | in <时长> <内容> | at <HH:MM> <内容> | every <时长> <内容> | help" +
|
|
225
279
|
" | history [peer|me] [条数] | doctor [--json]" +
|
|
226
|
-
" |
|
|
280
|
+
" | progress" +
|
|
281
|
+
" | tell <peer> <内容> [--kind ask|task|notify]" +
|
|
282
|
+
" | config [undo] [--json]";
|
|
227
283
|
/** `/proactive status` 末尾的指路行(MANUAL)。 */
|
|
228
284
|
export const HELP_POINTER = "指路:/proactive help 看命令表与最常见故障;详细文档见 <安装目录>/README.md(随包分发)。";
|
|
229
285
|
/**
|
|
@@ -321,6 +377,26 @@ export async function dispatchProactiveCommand(args, ctx, opts = {}) {
|
|
|
321
377
|
const asJson = parts.slice(1).includes("--json");
|
|
322
378
|
return { text: asJson ? healthToJson(report) : formatHealthReport(report), level: "info" };
|
|
323
379
|
}
|
|
380
|
+
case "progress": {
|
|
381
|
+
// 进度 + ETA(任务卡 ETA):**唯一口径**在 scripts/progress-clock.py(src/progress-eta.ts 接线)。
|
|
382
|
+
// 人侧命令与 AI 侧工具(progress_query)走同一段 → 逐字一致(同一快照)。
|
|
383
|
+
// 输出 = 区间 + 置信度 + 归因 + 阻塞项;**没有单点 ETA**。
|
|
384
|
+
const eta = await readProgressEta();
|
|
385
|
+
return { text: eta.text, level: eta.ok ? "info" : "error" };
|
|
386
|
+
}
|
|
387
|
+
case "config": {
|
|
388
|
+
// M6「配置可查」:全部项 + 当前值 + 缺省值 + 取值范围 + 一句说明;M9 的撤销入口同在此。
|
|
389
|
+
const action = (parts[1] ?? "").toLowerCase();
|
|
390
|
+
if (action === "undo") {
|
|
391
|
+
const result = undoConfigChange();
|
|
392
|
+
return { text: result.message, level: result.ok ? "info" : "error" };
|
|
393
|
+
}
|
|
394
|
+
const report = readConfigReport();
|
|
395
|
+
if (parts.slice(1).includes("--json")) {
|
|
396
|
+
return { text: JSON.stringify(report, null, 2), level: "info" };
|
|
397
|
+
}
|
|
398
|
+
return { text: formatConfigReport(report), level: "info" };
|
|
399
|
+
}
|
|
324
400
|
case "on":
|
|
325
401
|
case "off": {
|
|
326
402
|
const on = sub === "on";
|