@oyasmi/pipiclaw 0.9.1 → 0.9.2-beta.2

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 (167) hide show
  1. package/dist/agent/channel-runner.d.ts +15 -1
  2. package/dist/agent/channel-runner.js +76 -24
  3. package/dist/agent/effect-ledger.js +9 -2
  4. package/dist/agent/job-manager.d.ts +4 -0
  5. package/dist/agent/job-manager.js +17 -2
  6. package/dist/agent/prompt/manifest.d.ts +1 -1
  7. package/dist/agent/prompt/manifest.js +1 -1
  8. package/dist/agent/prompt/sections.js +8 -5
  9. package/dist/agent/session-events.d.ts +2 -0
  10. package/dist/agent/session-events.js +29 -14
  11. package/dist/agent/turn-recovery.js +2 -2
  12. package/dist/agent/type-guards.js +5 -1
  13. package/dist/agent/workspace-resources.d.ts +2 -2
  14. package/dist/agent/workspace-resources.js +41 -3
  15. package/dist/executor.d.ts +14 -0
  16. package/dist/executor.js +96 -24
  17. package/dist/file-store.d.ts +96 -0
  18. package/dist/file-store.js +189 -0
  19. package/dist/memory/consolidation.js +2 -26
  20. package/dist/memory/files.js +7 -7
  21. package/dist/memory/maintenance-jobs.js +2 -34
  22. package/dist/memory/maintenance-state.js +2 -1
  23. package/dist/memory/recall.d.ts +10 -0
  24. package/dist/memory/recall.js +15 -7
  25. package/dist/memory/session-search.js +6 -22
  26. package/dist/memory/transcript.d.ts +10 -0
  27. package/dist/memory/transcript.js +39 -0
  28. package/dist/playbooks/agent-delegation.md +7 -5
  29. package/dist/playbooks/background-jobs.md +1 -1
  30. package/dist/playbooks/catalog.d.ts +1 -1
  31. package/dist/playbooks/catalog.js +1 -1
  32. package/dist/playbooks/event-scheduling.md +2 -0
  33. package/dist/playbooks/memory-and-learning.md +11 -11
  34. package/dist/playbooks/runtime-orientation.md +3 -3
  35. package/dist/playbooks/task-driving.md +7 -7
  36. package/dist/playbooks/task-planning.md +5 -5
  37. package/dist/runtime/app-home.js +1 -1
  38. package/dist/runtime/bootstrap.js +10 -0
  39. package/dist/runtime/dingtalk.js +3 -2
  40. package/dist/runtime/durable-dispatch.d.ts +26 -1
  41. package/dist/runtime/durable-dispatch.js +51 -5
  42. package/dist/runtime/event-commands.js +7 -16
  43. package/dist/runtime/events.d.ts +4 -2
  44. package/dist/runtime/events.js +15 -20
  45. package/dist/runtime/subagent-commands.js +1 -1
  46. package/dist/runtime/task-commands.d.ts +1 -1
  47. package/dist/runtime/task-commands.js +17 -12
  48. package/dist/runtime/task-driver.js +2 -2
  49. package/dist/runtime/task-wake.d.ts +2 -2
  50. package/dist/runtime/task-wake.js +2 -2
  51. package/dist/security/block-message.d.ts +11 -0
  52. package/dist/security/block-message.js +12 -0
  53. package/dist/security/path-guard-check.d.ts +13 -0
  54. package/dist/security/path-guard-check.js +39 -0
  55. package/dist/security/path-guard.js +32 -14
  56. package/dist/settings.js +3 -2
  57. package/dist/shared/atomic-file.d.ts +17 -1
  58. package/dist/shared/atomic-file.js +50 -3
  59. package/dist/shared/duration.d.ts +2 -0
  60. package/dist/shared/duration.js +7 -0
  61. package/dist/shared/safe-id.d.ts +19 -0
  62. package/dist/shared/safe-id.js +24 -0
  63. package/dist/shared/text-utils.d.ts +1 -1
  64. package/dist/shared/text-utils.js +3 -8
  65. package/dist/shared/type-guards.d.ts +2 -0
  66. package/dist/shared/type-guards.js +4 -0
  67. package/dist/subagents/discovery.d.ts +44 -17
  68. package/dist/subagents/discovery.js +82 -111
  69. package/dist/subagents/external/claude-code.js +1 -3
  70. package/dist/subagents/external/harness.d.ts +1 -1
  71. package/dist/subagents/external/run.d.ts +6 -0
  72. package/dist/subagents/external/run.js +122 -58
  73. package/dist/subagents/external/settlement.d.ts +3 -0
  74. package/dist/subagents/external/settlement.js +19 -5
  75. package/dist/subagents/format.d.ts +3 -2
  76. package/dist/subagents/format.js +3 -7
  77. package/dist/subagents/runs.d.ts +45 -9
  78. package/dist/subagents/runs.js +184 -64
  79. package/dist/subagents/tool.d.ts +35 -24
  80. package/dist/subagents/tool.js +631 -577
  81. package/dist/subagents/verification-outcome.js +1 -1
  82. package/dist/subagents/workspace-lease.js +1 -1
  83. package/dist/tasks/artifact-subject.d.ts +30 -4
  84. package/dist/tasks/artifact-subject.js +257 -25
  85. package/dist/tasks/control.js +7 -9
  86. package/dist/tasks/ledger.d.ts +2 -2
  87. package/dist/tasks/ledger.js +3 -7
  88. package/dist/tasks/transitions.d.ts +5 -1
  89. package/dist/tasks/transitions.js +2 -2
  90. package/dist/tasks/verification.d.ts +24 -2
  91. package/dist/tasks/verification.js +113 -21
  92. package/dist/tools/bash.d.ts +0 -1
  93. package/dist/tools/bash.js +45 -40
  94. package/dist/tools/config.d.ts +6 -1
  95. package/dist/tools/config.js +9 -0
  96. package/dist/tools/edit.d.ts +2 -3
  97. package/dist/tools/edit.js +274 -86
  98. package/dist/tools/event-manage.d.ts +13 -7
  99. package/dist/tools/event-manage.js +52 -14
  100. package/dist/tools/glob-match.d.ts +11 -0
  101. package/dist/tools/glob-match.js +75 -0
  102. package/dist/tools/glob.d.ts +15 -0
  103. package/dist/tools/glob.js +113 -0
  104. package/dist/tools/grep.d.ts +0 -1
  105. package/dist/tools/grep.js +57 -42
  106. package/dist/tools/ignore-dirs.d.ts +6 -0
  107. package/dist/tools/ignore-dirs.js +15 -0
  108. package/dist/tools/index.d.ts +3 -0
  109. package/dist/tools/index.js +50 -40
  110. package/dist/tools/job.d.ts +0 -1
  111. package/dist/tools/job.js +1 -8
  112. package/dist/tools/line-index.d.ts +16 -0
  113. package/dist/tools/line-index.js +76 -0
  114. package/dist/tools/memory-manage.d.ts +20 -8
  115. package/dist/tools/memory-manage.js +65 -92
  116. package/dist/tools/presentation.d.ts +2 -0
  117. package/dist/tools/presentation.js +109 -0
  118. package/dist/tools/read.d.ts +2 -2
  119. package/dist/tools/read.js +97 -133
  120. package/dist/tools/registry.d.ts +4 -1
  121. package/dist/tools/registry.js +89 -22
  122. package/dist/tools/send-media.d.ts +6 -6
  123. package/dist/tools/send-media.js +16 -49
  124. package/dist/tools/session-search.d.ts +0 -1
  125. package/dist/tools/session-search.js +0 -1
  126. package/dist/tools/skill-security.d.ts +0 -2
  127. package/dist/tools/skill-security.js +0 -24
  128. package/dist/tools/skill.d.ts +31 -0
  129. package/dist/tools/skill.js +153 -0
  130. package/dist/tools/subagent-manage.d.ts +6 -5
  131. package/dist/tools/subagent-manage.js +60 -60
  132. package/dist/tools/task-manage/create.d.ts +2 -2
  133. package/dist/tools/task-manage/create.js +1 -3
  134. package/dist/tools/task-manage/lifecycle.d.ts +9 -6
  135. package/dist/tools/task-manage/lifecycle.js +56 -60
  136. package/dist/tools/task-manage/schema.d.ts +27 -15
  137. package/dist/tools/task-manage/schema.js +58 -74
  138. package/dist/tools/task-manage/shared.d.ts +11 -6
  139. package/dist/tools/task-manage/shared.js +30 -21
  140. package/dist/tools/task-manage/types.d.ts +14 -15
  141. package/dist/tools/task-manage/verification.d.ts +5 -5
  142. package/dist/tools/task-manage/verification.js +18 -15
  143. package/dist/tools/task-manage.d.ts +8 -11
  144. package/dist/tools/task-manage.js +63 -50
  145. package/dist/tools/tool-details.d.ts +17 -1
  146. package/dist/tools/tool-details.js +24 -0
  147. package/dist/tools/truncate.d.ts +5 -5
  148. package/dist/tools/truncate.js +5 -5
  149. package/dist/tools/web-fetch.d.ts +0 -1
  150. package/dist/tools/web-fetch.js +0 -1
  151. package/dist/tools/web-search.d.ts +0 -1
  152. package/dist/tools/web-search.js +0 -1
  153. package/dist/tools/write-content.d.ts +3 -3
  154. package/dist/tools/write-content.js +12 -51
  155. package/dist/tools/write.d.ts +2 -3
  156. package/dist/tools/write.js +3 -4
  157. package/dist/tui/pitui-frontend.js +3 -3
  158. package/dist/usage/ledger.js +7 -4
  159. package/examples/sub-agents/README.md +13 -13
  160. package/examples/sub-agents/documenter.md +2 -1
  161. package/examples/sub-agents/reviewer.md +2 -0
  162. package/examples/sub-agents/scout.md +2 -1
  163. package/examples/sub-agents/verifier.md +6 -4
  164. package/examples/sub-agents/worker.md +2 -1
  165. package/package.json +5 -5
  166. package/dist/tools/skill-manage.d.ts +0 -41
  167. package/dist/tools/skill-manage.js +0 -232
@@ -5,16 +5,19 @@ import { USAGE_STATE_DIR } from "../paths.js";
5
5
  import { createJsonlAppender } from "../shared/jsonl-appender.js";
6
6
  import { formatLocalTime, parseLocalTime } from "../shared/local-time.js";
7
7
  export const UNTRACKED_CHANNEL_ID = "(untracked)";
8
+ // Bucketed by the host's local calendar month, matching `ts: formatLocalTime()` below — entries
9
+ // are written and queried on local wall-clock time, so a UTC month boundary here would file an
10
+ // entry into the wrong month's ledger file near midnight in any timezone offset from UTC.
8
11
  function monthKey(date) {
9
- return `${date.getUTCFullYear()}-${String(date.getUTCMonth() + 1).padStart(2, "0")}`;
12
+ return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}`;
10
13
  }
11
14
  function monthKeysBetween(since, until) {
12
15
  const keys = [];
13
- const cursor = new Date(Date.UTC(since.getUTCFullYear(), since.getUTCMonth(), 1));
14
- const end = new Date(Date.UTC(until.getUTCFullYear(), until.getUTCMonth(), 1));
16
+ const cursor = new Date(since.getFullYear(), since.getMonth(), 1);
17
+ const end = new Date(until.getFullYear(), until.getMonth(), 1);
15
18
  while (cursor <= end) {
16
19
  keys.push(monthKey(cursor));
17
- cursor.setUTCMonth(cursor.getUTCMonth() + 1);
20
+ cursor.setMonth(cursor.getMonth() + 1);
18
21
  }
19
22
  return keys;
20
23
  }
@@ -45,22 +45,22 @@ planner(需求 / 方案 / 验收 / 拆解)
45
45
 
46
46
  reviewer 发现的问题回流给产出角色;verifier 失败回流给 builder,不在验证环节就地修复。闭环之外:worker 承接通用多步分析与产出,scout 只做单点事实查询。
47
47
 
48
- | 角色 | harness | `mutates` | `thinkingLevel` | 用途 |
49
- |---|---|---|---|---|
50
- | `planner` | claude-code (opus) | `read` | high | 只读需求收敛、方案设计、验收定义、任务拆解 |
51
- | `builder` | claude-code (sonnet) | `write` | medium | 边界清晰、验收已定义的实现 + 单元测试 |
52
- | `builder-hard` | claude-code (opus) | `write` | xhigh | builder 已失败、根因难定位或多契约耦合的实现 |
53
- | `reviewer` | codex-cli(只读沙箱) | `read` | high | 与产出者分离的方案 / 代码 / 文档挑错,也可承担只读 `purpose=verify` |
54
- | `verifier` | codex-cli(工作区写沙箱) | `write` | medium | 实际运行系统、复现、冒烟、回归、取证 |
55
- | `scout` | codex-cli(只读沙箱) | `read` | low | 大仓库里的单点事实查询 |
56
- | `worker` | codex-cli(工作区写沙箱) | `write` | medium | 闭环外的数据对比、指标计算、批量处理、专项报告 |
57
- | `documenter` | codex-cli(工作区写沙箱) | `write` | medium | 文档、变更记录和迁移说明;提交统一用 `git-committer` |
48
+ | 角色 | harness | `model` | `mutates` | `thinkingLevel` | 用途 |
49
+ |---|---|---|---|---|---|
50
+ | `planner` | claude-code | `opus` | `read` | high | 只读需求收敛、方案设计、验收定义、任务拆解 |
51
+ | `builder` | claude-code | `sonnet` | `write` | medium | 边界清晰、验收已定义的实现 + 单元测试 |
52
+ | `builder-hard` | claude-code | `opus` | `write` | xhigh | builder 已失败、根因难定位或多契约耦合的实现 |
53
+ | `reviewer` | codex-cli | `gpt-5.6-sol` | `read` | high | 与产出者分离的方案 / 代码 / 文档挑错,也可承担只读 `purpose=verify` |
54
+ | `verifier` | codex-cli | `gpt-5.6-luna` | `write` | high | 实际运行系统、复现、冒烟、回归、取证 |
55
+ | `scout` | codex-cli | `gpt-5.6-luna` | `read` | medium | 大仓库里的单点事实查询 |
56
+ | `worker` | codex-cli | `gpt-5.6-luna` | `write` | max | 闭环外的数据对比、指标计算、批量处理、专项报告 |
57
+ | `documenter` | codex-cli | `gpt-5.6-luna` | `write` | high | 文档、变更记录和迁移说明;提交统一用 `git-committer` |
58
58
 
59
59
  `planner` 用 Claude 的 `--permission-mode plan`,`reviewer` / `scout` 用 Codex 的 `--sandbox read-only`;三者的 `mutates: read` 都有目标 CLI 的权限模式支撑,而不只是提示词声明。它们不占工作区写锁,但评审仍应针对稳定的 diff / commit,不要一边让 builder 改同一工作树、一边评审移动中的目标。
60
60
 
61
- `reviewer` 的完整输出由 runtime 自动保存在 run 的 `output.md`,无需为了“落盘报告”给它工作区写权限。它可以承担 `purpose=verify`;runtime 会追加验收协议并检查工作区 subject 未变化。不过外部 attestation 仍是 `advisory`,而且只读沙箱会阻止产生工作区构建产物的测试,主代理需要按风险补充抽查或另派 verifier。
61
+ `reviewer` 的完整输出由 runtime 自动保存在 run 的 `output.md`,无需为了“落盘报告”给它工作区写权限。它可以承担不产生工作区写入的 `purpose=verify` 检查;runtime 会追加验收协议并检查工作区 subject 未变化。需要运行会生成产物的测试或构建时,应另派 `verifier`;外部 attestation 仍是 `advisory`,主代理需要按风险补充抽查。
62
62
 
63
- `verifier`、`worker`、`documenter` 使用 `--sandbox workspace-write`:足以在 checkout 和系统临时目录中生成测试或文档产物,同时不授予任意宿主文件访问。模板不让这些角色操作 Git 历史或外部系统;如任务确实需要网络、额外可写目录或更高权限,请复制角色后按目标 CLI 的能力最小化放宽,而不是把通用模板整体改成无沙箱。
63
+ `verifier`、`worker`、`documenter` 使用 `--sandbox workspace-write`:足以在 checkout 和系统临时目录中生成测试或文档产物,同时不授予任意宿主文件访问。`verifier` 用于 `purpose=verify` 时会持有目标工作区排他写锁,且 attestation 明确是 `advisory`;它可以生成 `.run/`、`coverage/`、`build/`、`dist/` 等约定临时产物,但不得修改被验收实现或既有 untracked 产品文件。模板不让这些角色操作 Git 历史或外部系统;如任务确实需要网络、额外可写目录或更高权限,请复制角色后按目标 CLI 的能力最小化放宽,而不是把通用模板整体改成无沙箱。
64
64
 
65
65
  `builder` / `builder-hard` 仍用 Claude 的 `--dangerously-skip-permissions`,因为它们需要非交互地完成实现;这是本目录权限最高的默认配置。务必在可信 checkout、最小权限宿主账号中使用。角色文件只声明 `model` 和 `thinkingLevel`,具体的 `--model` / `--effort` 参数由 claude-code harness 自动拼接,不应重复写进 `command`。
66
66
 
@@ -82,7 +82,7 @@ Pipiclaw 只加载工作区 `sub-agents/` 中实际存在且有效的 Markdown
82
82
  ## 需要按本机调整的地方
83
83
 
84
84
  - **`command` 用的是裸命令**(`claude` / `codex`),它们必须在 pipiclaw 进程的 `PATH` 上。如果你本机用的是包装脚本(换 base URL、换额度账号、注入环境变量),把 `command` 换成那个脚本即可——pipiclaw 只做 shell 词法分词,不解释命令内容。找不到可执行文件时角色不会消失,而是标为 `unavailable` 并在调用时给出安装提示。
85
- - **`model` 原样透传给目标 CLI,pipiclaw 不校验**。Claude 角色用了 `opus` / `sonnet`;Codex 角色**没有写 `model`**,交给 CLI 自身的默认配置——请按你的账号可用模型自行填写。
85
+ - **`model` 原样透传给目标 CLI,pipiclaw 不校验**。Claude 角色使用 `opus` / `sonnet`;Codex 角色使用 `gpt-5.6-sol` 或 `gpt-5.6-luna`。如果本机账号不可用,请按目标 CLI 支持的模型替换。
86
86
  - **目标 CLI 参数会变化**。模板按当前 Claude Code / Codex CLI 维护;升级 CLI 后先用 `claude --help`、`codex exec --help` 核对命令。Pipiclaw 只分词和追加协议参数,不会替你校验 flag 是否仍受支持。
87
87
  - **`--dangerously-skip-permissions`** 是 Claude Code 自身的权限跳过标记,Pipiclaw 原样传入。若不接受这个边界,只使用只读角色,或为写角色换成你已验证可在非交互模式工作的更严格权限配置。
88
88
  - **`maxWallTimeSec` 是墙钟上限**,超时会杀进程组但仍解析并回传已产生的输出。按仓库规模和任务量级调整,不要把示例值当成固定答案。
@@ -5,7 +5,8 @@ description: >-
5
5
  runtime: external
6
6
  harness: codex-cli
7
7
  command: codex exec --sandbox workspace-write --skip-git-repo-check
8
- thinkingLevel: medium
8
+ model: gpt-5.6-luna
9
+ thinkingLevel: high
9
10
  workload: heavy
10
11
  mutates: write
11
12
  maxWallTimeSec: 1800
@@ -5,6 +5,7 @@ description: >-
5
5
  runtime: external
6
6
  harness: codex-cli
7
7
  command: codex exec --sandbox read-only --skip-git-repo-check
8
+ model: gpt-5.6-sol
8
9
  thinkingLevel: high
9
10
  workload: heavy
10
11
  mutates: read
@@ -20,6 +21,7 @@ maxWallTimeSec: 1800
20
21
  - **方案**:边界是否收敛,是否适配现有架构,关键契约、迁移、回滚、风险和验收是否闭环。
21
22
  - **代码**:需求符合性、正确性、兼容性和安全性,重点检查边界、并发、错误处理、资源、数据完整性及漏改调用方。
22
23
  - **文档**:对照实现与配置核对事实,检查目标读者能否按步骤完成任务,以及前置、参数、失败处理和迁移是否完整。
24
+ - 需要启动测试或构建时不要把静态评审当作运行验收;本角色可承担 `purpose=verify` 的只读检查,但只适合不会产生工作区写入的检查。需要 `npm test`、`npm run build` 或其他可能生成产物的验证时,改派 `verifier`,并接受其 advisory attestation。
23
25
 
24
26
  ## 发现门槛
25
27
 
@@ -5,7 +5,8 @@ description: >-
5
5
  runtime: external
6
6
  harness: codex-cli
7
7
  command: codex exec --sandbox read-only --skip-git-repo-check
8
- thinkingLevel: low
8
+ model: gpt-5.6-luna
9
+ thinkingLevel: medium
9
10
  workload: heavy
10
11
  mutates: read
11
12
  maxWallTimeSec: 600
@@ -1,11 +1,12 @@
1
1
  ---
2
2
  name: verifier
3
3
  description: >-
4
- 重型运行验证(外部 Codex,可写工作区)。用于复现问题、启动系统、冒烟和回归,按验收项给出可复现的通过/失败/阻塞证据;不负责实现修复。测试可能生成构建产物,因此不能用于要求只读的 purpose=verify。
4
+ 重型运行验证(外部 Codex,可写工作区)。用于复现问题、启动系统、冒烟和回归,按验收项给出可复现的通过/失败/阻塞证据;不负责实现修复。可用于 purpose=verify,但会占用目标工作区排他写锁,attestation 为 advisory。
5
5
  runtime: external
6
6
  harness: codex-cli
7
7
  command: codex exec --sandbox workspace-write --skip-git-repo-check
8
- thinkingLevel: medium
8
+ model: gpt-5.6-luna
9
+ thinkingLevel: high
9
10
  workload: heavy
10
11
  mutates: write
11
12
  maxWallTimeSec: 3600
@@ -16,13 +17,14 @@ maxWallTimeSec: 3600
16
17
  ## 独立性与产物
17
18
 
18
19
  - 先读当前目录适用的仓库指令,记录待验证的 commit/diff 边界和初始状态。发现缺陷时先保存失败证据,不修改产品实现来让验证通过。
19
- - 可以创建验证脚本、夹具、测试数据和报告;优先放在仓库既有测试位置、忽略目录或系统临时目录,并记录用途。只清理本轮创建且可再生的产物。
20
+ - 可以创建验证脚本、夹具、测试数据和报告;优先放在仓库既有测试位置、`.run/`、`coverage/`、`build/`、`dist/` 等约定的临时产物目录或系统临时目录,并记录用途。验证期间新建的临时产物仅在 runtime 识别的明确范围内不计入 subject(Cypress 仅 `cypress/screenshots/`、`cypress/videos/`);验证开始前已存在的 untracked 文件,以及 ignored 的非临时产品文件始终受保护。`cypress/e2e/`、fixtures、support 和 downloads 不是临时产物。只清理本轮创建且可再生的产物。
21
+ - 即使角色声明 `mutates: write`,也不得修改被验收的实现、既有 untracked 产品文件,或为了通过测试而修代码;写锁只保证验证期间没有其他声明写入的委派并发运行,不是宿主机权限沙箱。
20
22
  - 不 commit、push、部署或修改共享环境,不写入真实生产数据。外部服务、凭据、费用、特权或不可逆操作缺失时,将对应条目标为阻塞并说明最小条件。
21
23
 
22
24
  ## 验证方法
23
25
 
24
26
  - 把每条验收标准转成可执行检查:前置环境、输入或操作、预期结果和取证方式。优先使用任务或仓库已有命令,不改写验收口径。
25
- - 顺序执行:环境与依赖预检 → 最小启动与健康检查 → 主路径冒烟 → 关键边界和失败路径 → 受影响范围的定向回归。是否执行全量回归或长时间性能测试,按验收计划、改动风险、可用环境和时间成本决定,并在报告中说明取舍。
27
+ - 顺序执行:环境与依赖预检 → 最小启动与健康检查 → 主路径冒烟 → 关键边界和失败路径 → 受影响范围的定向回归。是否执行全量回归或长时间性能测试,按验收计划、改动风险、可用环境和时间成本决定,并在报告中说明取舍。`purpose=verify` 的 PASS 是 advisory,必须报告实际 diff/subject 检查结果,不能只引用进程退出码。
26
28
  - 保留精确命令、退出码、关键输出或日志和必要的数据摘要。性能或效果结论需说明基线、样本、指标和允许偏差。
27
29
  - 对每项判定为**通过**、**失败**、**阻塞**或**不适用**。通过必须有实际执行证据;实际结果违反预期是失败;环境或输入缺失导致无法判定是阻塞;确认与本次变更无关的条目可标为不适用并给出依据。不把环境故障写成产品缺陷,也不用环境问题掩盖已观测到的产品错误。
28
30
 
@@ -5,7 +5,8 @@ description: >-
5
5
  runtime: external
6
6
  harness: codex-cli
7
7
  command: codex exec --sandbox workspace-write --skip-git-repo-check
8
- thinkingLevel: medium
8
+ model: gpt-5.6-luna
9
+ thinkingLevel: max
9
10
  workload: heavy
10
11
  mutates: write
11
12
  maxWallTimeSec: 1800
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oyasmi/pipiclaw",
3
- "version": "0.9.1",
3
+ "version": "0.9.2-beta.2",
4
4
  "description": "An AI assistant runtime for coding and team workflows, with DingTalk AI Cards, sub-agents, memory, and scheduled events.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -42,10 +42,10 @@
42
42
  "test:evals": "vitest --run --config vitest.config.evals.ts"
43
43
  },
44
44
  "dependencies": {
45
- "@earendil-works/pi-agent-core": "0.83.0",
46
- "@earendil-works/pi-ai": "0.83.0",
47
- "@earendil-works/pi-coding-agent": "0.83.0",
48
- "@earendil-works/pi-tui": "0.83.0",
45
+ "@earendil-works/pi-agent-core": "0.84.3",
46
+ "@earendil-works/pi-ai": "0.84.3",
47
+ "@earendil-works/pi-coding-agent": "0.84.3",
48
+ "@earendil-works/pi-tui": "0.84.3",
49
49
  "@mozilla/readability": "^0.6.0",
50
50
  "axios": "^1.7.0",
51
51
  "croner": "^9.1.0",
@@ -1,41 +0,0 @@
1
- import type { AgentTool } from "@earendil-works/pi-agent-core";
2
- import { Type } from "typebox";
3
- declare const skillManageSchema: Type.TObject<{
4
- label: Type.TString;
5
- action: Type.TUnion<[Type.TLiteral<"list">, Type.TLiteral<"view">, Type.TLiteral<"create">, Type.TLiteral<"patch">, Type.TLiteral<"write_file">]>;
6
- name: Type.TOptional<Type.TString>;
7
- content: Type.TOptional<Type.TString>;
8
- filePath: Type.TOptional<Type.TString>;
9
- find: Type.TOptional<Type.TString>;
10
- replace: Type.TOptional<Type.TString>;
11
- }>;
12
- type SkillWriteAction = "create" | "patch" | "write_file";
13
- export interface SkillManageResult {
14
- action: SkillWriteAction;
15
- name: string;
16
- path: string;
17
- bytesWritten: number;
18
- requiresResourceRefresh: boolean;
19
- notice: string;
20
- }
21
- export interface SkillManageRequest {
22
- action: SkillWriteAction;
23
- name: string;
24
- content?: string;
25
- filePath?: string;
26
- find?: string;
27
- replace?: string;
28
- }
29
- export interface WorkspaceSkillSummary {
30
- name: string;
31
- description: string;
32
- path: string;
33
- warning?: string;
34
- }
35
- export interface SkillManageToolOptions {
36
- workspaceDir: string;
37
- }
38
- export declare function listWorkspaceSkills(options: SkillManageToolOptions): Promise<WorkspaceSkillSummary[]>;
39
- export declare function manageWorkspaceSkill(options: SkillManageToolOptions, request: SkillManageRequest): Promise<SkillManageResult>;
40
- export declare function createSkillManageTool(options: SkillManageToolOptions): AgentTool<typeof skillManageSchema>;
41
- export {};
@@ -1,232 +0,0 @@
1
- import { existsSync } from "node:fs";
2
- import { readdir, readFile, stat } from "node:fs/promises";
3
- import { join } from "node:path";
4
- import { Type } from "typebox";
5
- import { createAtomicTempPath, writeFileAtomically } from "../shared/atomic-file.js";
6
- import { RecoverableToolError } from "../shared/recoverable-error.js";
7
- import { resolveSkillPath, resolveSkillSupportingFile, scanSkillContent, validateSkillFrontmatter, validateSkillMarkdown, validateSkillName, } from "./skill-security.js";
8
- import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
9
- const skillManageSchema = Type.Object({
10
- label: Type.String({ description: "Brief description of the skill action (shown to user)" }),
11
- action: Type.Union([
12
- Type.Literal("list"),
13
- Type.Literal("view"),
14
- Type.Literal("create"),
15
- Type.Literal("patch"),
16
- Type.Literal("write_file"),
17
- ], {
18
- description: '"list" workspace skills, "view" one skill\'s contents, or "create"/"patch"/"write_file" to author them.',
19
- }),
20
- name: Type.Optional(Type.String({ description: "Workspace skill name (required for all actions except list)." })),
21
- content: Type.Optional(Type.String({ description: "Full content for create/write_file." })),
22
- filePath: Type.Optional(Type.String({
23
- description: "Supporting file path inside the skill for view/patch/write_file. Defaults to SKILL.md. Supporting files must be under references/, templates/, scripts/, or assets/.",
24
- })),
25
- find: Type.Optional(Type.String({ description: "Exact text to replace when action is patch." })),
26
- replace: Type.Optional(Type.String({ description: "Replacement text when action is patch." })),
27
- });
28
- function isNodeError(error) {
29
- return error instanceof Error && "code" in error;
30
- }
31
- function extractDescription(content) {
32
- const match = content.replace(/\r\n/g, "\n").match(/^---\n([\s\S]*?)\n---/);
33
- if (!match) {
34
- return "";
35
- }
36
- for (const line of (match[1] ?? "").split("\n")) {
37
- const fieldMatch = line.match(/^description:\s*(.*)$/);
38
- if (fieldMatch) {
39
- return fieldMatch[1].replace(/^["']|["']$/g, "").trim();
40
- }
41
- }
42
- return "";
43
- }
44
- export async function listWorkspaceSkills(options) {
45
- const skillsDir = join(options.workspaceDir, "skills");
46
- let names;
47
- try {
48
- names = await readdir(skillsDir);
49
- }
50
- catch (error) {
51
- if (isNodeError(error) && error.code === "ENOENT") {
52
- return [];
53
- }
54
- throw error;
55
- }
56
- const summaries = [];
57
- for (const name of names.sort()) {
58
- const nameValidation = validateSkillName(name);
59
- if (!nameValidation.ok) {
60
- continue;
61
- }
62
- const skillDir = join(skillsDir, name);
63
- const skillStats = await stat(skillDir).catch(() => null);
64
- if (!skillStats?.isDirectory()) {
65
- continue;
66
- }
67
- const skillPath = join(skillDir, "SKILL.md");
68
- let content;
69
- try {
70
- const skillFileStats = await stat(skillPath);
71
- if (!skillFileStats.isFile()) {
72
- continue;
73
- }
74
- content = await readFile(skillPath, "utf-8");
75
- }
76
- catch (error) {
77
- if (isNodeError(error) && error.code === "ENOENT") {
78
- continue;
79
- }
80
- throw error;
81
- }
82
- const validation = validateSkillFrontmatter(content, name);
83
- summaries.push({
84
- name,
85
- description: extractDescription(content),
86
- path: `${options.workspaceDir}/skills/${name}/SKILL.md`,
87
- warning: validation.ok ? undefined : validation.error,
88
- });
89
- }
90
- return summaries;
91
- }
92
- function parseWriteAction(action) {
93
- if (action === "create" || action === "patch" || action === "write_file") {
94
- return action;
95
- }
96
- throw new RecoverableToolError('Unsupported skill action. Use "list", "view", "create", "patch", or "write_file".');
97
- }
98
- function ensureSkillMarkdownSafe(content, name) {
99
- const validation = validateSkillMarkdown(content, name);
100
- if (!validation.ok) {
101
- throw new RecoverableToolError(validation.error ?? "Skill content failed validation.");
102
- }
103
- }
104
- function ensureSupportingFileSafe(content) {
105
- const validation = scanSkillContent(content);
106
- if (!validation.ok) {
107
- throw new RecoverableToolError(validation.error ?? "Skill content failed validation.");
108
- }
109
- }
110
- function applyUniquePatch(content, find, replace) {
111
- if (!find) {
112
- throw new RecoverableToolError("Patch requires a non-empty find string.");
113
- }
114
- const first = content.indexOf(find);
115
- if (first < 0) {
116
- throw new RecoverableToolError("Patch find string was not found.");
117
- }
118
- if (content.indexOf(find, first + find.length) >= 0) {
119
- throw new RecoverableToolError("Patch find string matched multiple locations.");
120
- }
121
- return `${content.slice(0, first)}${replace}${content.slice(first + find.length)}`;
122
- }
123
- export async function manageWorkspaceSkill(options, request) {
124
- const skillDir = resolveSkillPath(options.workspaceDir, request.name);
125
- const skillPath = join(skillDir, "SKILL.md");
126
- if (request.action === "create") {
127
- if (existsSync(skillPath)) {
128
- throw new RecoverableToolError(`Workspace skill "${request.name}" already exists.`);
129
- }
130
- const content = request.content ?? "";
131
- ensureSkillMarkdownSafe(content, request.name);
132
- await writeFileAtomically(skillPath, content);
133
- return {
134
- action: "create",
135
- name: request.name,
136
- path: skillPath,
137
- bytesWritten: Buffer.byteLength(content, "utf-8"),
138
- requiresResourceRefresh: true,
139
- notice: `已沉淀:创建 workspace skill \`${request.name}\`。`,
140
- };
141
- }
142
- if (!existsSync(skillPath)) {
143
- throw new RecoverableToolError(`Workspace skill "${request.name}" does not exist.`);
144
- }
145
- if (request.action === "write_file") {
146
- if (!request.filePath) {
147
- throw new RecoverableToolError("write_file requires filePath.");
148
- }
149
- const content = request.content ?? "";
150
- const targetPath = resolveSkillSupportingFile(skillDir, request.filePath);
151
- ensureSupportingFileSafe(content);
152
- await writeFileAtomically(targetPath, content);
153
- return {
154
- action: "write_file",
155
- name: request.name,
156
- path: targetPath,
157
- bytesWritten: Buffer.byteLength(content, "utf-8"),
158
- requiresResourceRefresh: true,
159
- notice: `已沉淀:更新 workspace skill \`${request.name}\` 的支持文件。`,
160
- };
161
- }
162
- const targetPath = request.filePath ? resolveSkillSupportingFile(skillDir, request.filePath) : skillPath;
163
- const original = await readFile(targetPath, "utf-8");
164
- const nextContent = applyUniquePatch(original, request.find ?? "", request.replace ?? "");
165
- if (targetPath === skillPath) {
166
- ensureSkillMarkdownSafe(nextContent, request.name);
167
- }
168
- else {
169
- ensureSupportingFileSafe(nextContent);
170
- }
171
- const tempPath = createAtomicTempPath(targetPath);
172
- await writeFileAtomically(targetPath, nextContent, tempPath);
173
- return {
174
- action: "patch",
175
- name: request.name,
176
- path: targetPath,
177
- bytesWritten: Buffer.byteLength(nextContent, "utf-8"),
178
- requiresResourceRefresh: true,
179
- notice: `已沉淀:更新 workspace skill \`${request.name}\`。`,
180
- };
181
- }
182
- async function viewWorkspaceSkill(options, name, filePath) {
183
- const skillDir = resolveSkillPath(options.workspaceDir, name);
184
- const targetPath = filePath ? resolveSkillSupportingFile(skillDir, filePath) : join(skillDir, "SKILL.md");
185
- const content = await readFile(targetPath, "utf-8");
186
- // Cap with the shared truncation limits so a large supporting file cannot flood context.
187
- const truncation = truncateHead(content);
188
- let body = truncation.content;
189
- if (truncation.truncated) {
190
- body += `\n\n[Truncated at ${formatSize(DEFAULT_MAX_BYTES)}. Use the read tool on ${targetPath} to page through the rest.]`;
191
- }
192
- return {
193
- content: [{ type: "text", text: `Skill: ${name}\nPath: ${targetPath}\n\n${body}` }],
194
- details: { action: "view", name, path: targetPath, truncated: truncation.truncated },
195
- };
196
- }
197
- export function createSkillManageTool(options) {
198
- return {
199
- name: "skill_manage",
200
- label: "skill_manage",
201
- description: "Manage workspace-level Pipiclaw skills (procedural memory): list them, view one's contents, or author them " +
202
- "with create/patch/write_file. No channel-scoped skills.",
203
- parameters: skillManageSchema,
204
- execute: async (_toolCallId, args) => {
205
- if (args.action === "list") {
206
- const skills = await listWorkspaceSkills(options);
207
- return {
208
- content: [{ type: "text", text: JSON.stringify({ skills }) }],
209
- details: { action: "list", count: skills.length },
210
- };
211
- }
212
- if (!args.name) {
213
- throw new RecoverableToolError(`Action "${args.action}" requires a skill name.`);
214
- }
215
- if (args.action === "view") {
216
- return viewWorkspaceSkill(options, args.name, args.filePath);
217
- }
218
- const result = await manageWorkspaceSkill(options, {
219
- action: parseWriteAction(args.action),
220
- name: args.name,
221
- content: args.content,
222
- filePath: args.filePath,
223
- find: args.find,
224
- replace: args.replace,
225
- });
226
- return {
227
- content: [{ type: "text", text: JSON.stringify(result) }],
228
- details: { ...result },
229
- };
230
- },
231
- };
232
- }