@oyasmi/pipiclaw 0.9.5 → 0.9.6-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 (345) hide show
  1. package/README.en.md +300 -142
  2. package/README.md +295 -140
  3. package/dist/agent/builtin-commands.d.ts +1 -1
  4. package/dist/agent/builtin-commands.js +1 -1
  5. package/dist/agent/channel-runner.d.ts +4 -3
  6. package/dist/agent/channel-runner.js +17 -28
  7. package/dist/agent/maintenance-context.js +2 -2
  8. package/dist/agent/prompt/builder.d.ts +1 -1
  9. package/dist/agent/prompt/builder.js +1 -1
  10. package/dist/agent/prompt/extension.d.ts +1 -1
  11. package/dist/agent/prompt/extension.js +1 -1
  12. package/dist/agent/prompt/manifest.d.ts +6 -1
  13. package/dist/agent/prompt/manifest.js +12 -5
  14. package/dist/agent/prompt/resources.d.ts +0 -3
  15. package/dist/agent/prompt/resources.js +0 -6
  16. package/dist/agent/prompt/sections.d.ts +2 -2
  17. package/dist/agent/prompt/sections.js +36 -26
  18. package/dist/agent/prompt/types.d.ts +3 -2
  19. package/dist/agent/runner-factory.js +1 -1
  20. package/dist/agent/session/command-extension.js +3 -1
  21. package/dist/agent/session/compaction-summary.js +3 -6
  22. package/dist/agent/session/compaction.d.ts +2 -0
  23. package/dist/agent/session/compaction.js +22 -14
  24. package/dist/agent/session/event-guards.d.ts +2 -1
  25. package/dist/agent/session/event-guards.js +6 -0
  26. package/dist/agent/session/model-selection.d.ts +2 -1
  27. package/dist/agent/session/model-selection.js +5 -5
  28. package/dist/agent/session/session-events.js +31 -4
  29. package/dist/agent/session/session-host.d.ts +5 -3
  30. package/dist/agent/session/session-host.js +20 -16
  31. package/dist/agent/status-render.js +3 -0
  32. package/dist/agent/stop-watchdog.js +5 -1
  33. package/dist/agent/turn/task-digest.d.ts +2 -5
  34. package/dist/agent/turn/task-digest.js +25 -45
  35. package/dist/agent/turn/turn-context.js +4 -6
  36. package/dist/agent/turn/turn-error.d.ts +1 -1
  37. package/dist/agent/turn/turn-error.js +9 -0
  38. package/dist/agent/turn/turn-pipeline.d.ts +10 -5
  39. package/dist/agent/turn/turn-pipeline.js +36 -7
  40. package/dist/agent/turn/turn-prompt.d.ts +2 -0
  41. package/dist/agent/turn/turn-prompt.js +2 -1
  42. package/dist/agent/turn/turn-recovery.js +4 -1
  43. package/dist/agent/turn/turn-state.d.ts +2 -0
  44. package/dist/agent/turn/turn-state.js +2 -1
  45. package/dist/agent/types.d.ts +23 -3
  46. package/dist/agent/types.js +2 -0
  47. package/dist/app/auth-command.d.ts +25 -0
  48. package/dist/app/auth-command.js +200 -67
  49. package/dist/app/home.d.ts +7 -8
  50. package/dist/app/home.js +143 -56
  51. package/dist/channel/attachments.d.ts +4 -0
  52. package/dist/channel/attachments.js +4 -0
  53. package/dist/channel/channel-context.d.ts +6 -0
  54. package/dist/channel/config.d.ts +3 -0
  55. package/dist/channel/config.js +11 -5
  56. package/dist/channel/store.d.ts +1 -1
  57. package/dist/commands/catalog.js +42 -10
  58. package/dist/commands/router.js +5 -1
  59. package/dist/desk/commands.d.ts +44 -5
  60. package/dist/desk/commands.js +162 -28
  61. package/dist/desk/paths.d.ts +6 -0
  62. package/dist/desk/paths.js +21 -1
  63. package/dist/desk/registry.d.ts +17 -2
  64. package/dist/desk/registry.js +122 -12
  65. package/dist/desk/types.d.ts +83 -1
  66. package/dist/dingtalk/bot.d.ts +1 -1
  67. package/dist/dingtalk/bot.js +4 -3
  68. package/dist/dingtalk/config.js +10 -10
  69. package/dist/dingtalk/delivery.js +15 -8
  70. package/dist/dingtalk/inbound-media.d.ts +36 -14
  71. package/dist/dingtalk/inbound-media.js +71 -12
  72. package/dist/dingtalk/inbound.d.ts +9 -2
  73. package/dist/dingtalk/inbound.js +17 -2
  74. package/dist/dingtalk/media.d.ts +4 -10
  75. package/dist/dingtalk/media.js +58 -32
  76. package/dist/events/commands.d.ts +2 -0
  77. package/dist/events/commands.js +13 -8
  78. package/dist/events/history.d.ts +9 -0
  79. package/dist/events/history.js +66 -0
  80. package/dist/events/parse.js +7 -3
  81. package/dist/events/types.d.ts +3 -0
  82. package/dist/events/watcher.d.ts +4 -8
  83. package/dist/events/watcher.js +53 -58
  84. package/dist/jobs/kill.d.ts +23 -0
  85. package/dist/jobs/kill.js +65 -0
  86. package/dist/jobs/manager.d.ts +19 -18
  87. package/dist/jobs/manager.js +36 -103
  88. package/dist/main.js +15 -3
  89. package/dist/memory/boundary-work.d.ts +2 -1
  90. package/dist/memory/boundary-work.js +1 -1
  91. package/dist/memory/lifecycle.d.ts +2 -1
  92. package/dist/memory/lifecycle.js +2 -2
  93. package/dist/memory/reflect-job.d.ts +2 -1
  94. package/dist/memory/reflect-job.js +1 -1
  95. package/dist/memory/reflect.d.ts +2 -1
  96. package/dist/memory/reflect.js +25 -4
  97. package/dist/memory/scheduler.d.ts +2 -1
  98. package/dist/memory/scheduler.js +1 -1
  99. package/dist/memory/session-corpus.d.ts +1 -1
  100. package/dist/memory/session-corpus.js +76 -1
  101. package/dist/memory/session-search.d.ts +2 -1
  102. package/dist/memory/session-search.js +14 -12
  103. package/dist/memory/sidecar-worker.d.ts +2 -1
  104. package/dist/memory/sidecar-worker.js +2 -4
  105. package/dist/memory/store.d.ts +2 -0
  106. package/dist/memory/store.js +19 -9
  107. package/dist/models/credential-work.d.ts +7 -0
  108. package/dist/models/credential-work.js +36 -0
  109. package/dist/models/login-ui.js +4 -4
  110. package/dist/models/provider-login.js +7 -6
  111. package/dist/models/requests.d.ts +8 -0
  112. package/dist/models/requests.js +69 -0
  113. package/dist/models/runtime.d.ts +3 -1
  114. package/dist/models/runtime.js +9 -2
  115. package/dist/playbooks/agent-delegation.md +20 -45
  116. package/dist/playbooks/background-jobs.md +1 -1
  117. package/dist/playbooks/catalog.js +1 -1
  118. package/dist/playbooks/delegation-inline.md +25 -0
  119. package/dist/playbooks/delegation-recovery.md +28 -0
  120. package/dist/playbooks/event-scheduling.md +18 -37
  121. package/dist/playbooks/event-sensors.md +26 -0
  122. package/dist/playbooks/event-task-template.md +22 -0
  123. package/dist/playbooks/learning-and-skills.md +26 -0
  124. package/dist/playbooks/memory-operations.md +36 -0
  125. package/dist/playbooks/outbound-media.md +2 -2
  126. package/dist/playbooks/runtime-files.md +29 -0
  127. package/dist/playbooks/runtime-operations.md +25 -0
  128. package/dist/playbooks/runtime-orientation.md +18 -53
  129. package/dist/playbooks/task-lead.md +22 -68
  130. package/dist/playbooks/task-manage.md +38 -0
  131. package/dist/playbooks/task-recovery.md +24 -0
  132. package/dist/playbooks/task-verify.md +22 -0
  133. package/dist/runtime/bootstrap.d.ts +10 -0
  134. package/dist/runtime/bootstrap.js +93 -29
  135. package/dist/runtime/daemon-lock.js +3 -3
  136. package/dist/runtime/desk-runtime.d.ts +40 -7
  137. package/dist/runtime/desk-runtime.js +330 -44
  138. package/dist/runtime/durable-dispatch.d.ts +14 -2
  139. package/dist/runtime/durable-dispatch.js +207 -65
  140. package/dist/runtime/ingress-busy.js +17 -8
  141. package/dist/runtime/ingress-commands.js +24 -4
  142. package/dist/runtime/ingress-deps.d.ts +4 -1
  143. package/dist/runtime/ingress.js +6 -1
  144. package/dist/runtime/request-execution.js +7 -6
  145. package/dist/runtime/shutdown.d.ts +4 -1
  146. package/dist/runtime/shutdown.js +88 -35
  147. package/dist/runtime/task-close.d.ts +1 -1
  148. package/dist/runtime/task-close.js +6 -3
  149. package/dist/runtime/task-control.d.ts +2 -3
  150. package/dist/runtime/task-control.js +38 -11
  151. package/dist/runtime/task-input.js +1 -1
  152. package/dist/runtime/task-lane-types.d.ts +12 -2
  153. package/dist/runtime/task-lane-types.js +9 -0
  154. package/dist/runtime/task-lane.d.ts +2 -0
  155. package/dist/runtime/task-lane.js +38 -20
  156. package/dist/runtime/task-step.d.ts +3 -3
  157. package/dist/runtime/task-step.js +34 -16
  158. package/dist/runtime/transports.js +6 -5
  159. package/dist/runtime/turn-run.js +103 -66
  160. package/dist/security/command-guard.d.ts +1 -1
  161. package/dist/security/command-guard.js +259 -314
  162. package/dist/security/path-guard.js +48 -7
  163. package/dist/security/shell-parse.d.ts +10 -0
  164. package/dist/security/shell-parse.js +224 -0
  165. package/dist/security/types.d.ts +2 -0
  166. package/dist/subagents/commands.d.ts +1 -1
  167. package/dist/subagents/commands.js +14 -5
  168. package/dist/subagents/completion-wake.js +6 -0
  169. package/dist/subagents/detached-discovery.d.ts +1 -1
  170. package/dist/subagents/discovery.d.ts +18 -199
  171. package/dist/subagents/discovery.js +35 -289
  172. package/dist/subagents/dispatch.d.ts +1 -2
  173. package/dist/subagents/dispatch.js +50 -29
  174. package/dist/subagents/external/antigravity-cli.d.ts +2 -0
  175. package/dist/subagents/external/antigravity-cli.js +517 -0
  176. package/dist/subagents/external/claude-code.js +8 -17
  177. package/dist/subagents/external/codex-cli.js +8 -18
  178. package/dist/subagents/external/cursor-cli.js +34 -31
  179. package/dist/subagents/external/dispatch.d.ts +21 -7
  180. package/dist/subagents/external/dispatch.js +146 -12
  181. package/dist/subagents/external/exec.js +3 -0
  182. package/dist/subagents/external/harness.d.ts +57 -33
  183. package/dist/subagents/external/harness.js +69 -40
  184. package/dist/subagents/external/reconciliation.js +1 -0
  185. package/dist/subagents/external/registry.js +4 -1
  186. package/dist/subagents/external/role-warnings.d.ts +4 -13
  187. package/dist/subagents/external/role-warnings.js +4 -28
  188. package/dist/subagents/external/run.d.ts +1 -2
  189. package/dist/subagents/external/run.js +16 -26
  190. package/dist/subagents/external/settlement.d.ts +2 -0
  191. package/dist/subagents/external/settlement.js +13 -3
  192. package/dist/subagents/format.d.ts +1 -1
  193. package/dist/subagents/format.js +1 -1
  194. package/dist/subagents/internal/outcome.d.ts +1 -2
  195. package/dist/subagents/internal/outcome.js +19 -12
  196. package/dist/subagents/internal/provider-retry.d.ts +1 -2
  197. package/dist/subagents/internal/provider-retry.js +2 -4
  198. package/dist/subagents/internal/run.d.ts +2 -3
  199. package/dist/subagents/internal/run.js +27 -4
  200. package/dist/subagents/internal/state.d.ts +2 -5
  201. package/dist/subagents/internal/state.js +1 -2
  202. package/dist/subagents/internal/worker.d.ts +1 -2
  203. package/dist/subagents/internal/worker.js +20 -10
  204. package/dist/subagents/resolve.d.ts +56 -0
  205. package/dist/subagents/resolve.js +202 -0
  206. package/dist/subagents/result.d.ts +6 -4
  207. package/dist/subagents/result.js +39 -6
  208. package/dist/subagents/run-record.d.ts +54 -2
  209. package/dist/subagents/run-record.js +7 -0
  210. package/dist/subagents/runs.d.ts +6 -31
  211. package/dist/subagents/runs.js +26 -31
  212. package/dist/subagents/task-envelope.d.ts +1 -2
  213. package/dist/subagents/task-envelope.js +13 -4
  214. package/dist/subagents/task-settlement.js +1 -0
  215. package/dist/subagents/types.d.ts +105 -6
  216. package/dist/subagents/types.js +16 -1
  217. package/dist/subagents/workspace-lease.d.ts +41 -24
  218. package/dist/subagents/workspace-lease.js +159 -24
  219. package/dist/subagents/worktree.d.ts +52 -0
  220. package/dist/subagents/worktree.js +363 -0
  221. package/dist/tasks/archive.js +4 -0
  222. package/dist/tasks/brief.d.ts +5 -1
  223. package/dist/tasks/brief.js +19 -5
  224. package/dist/tasks/commands.d.ts +6 -1
  225. package/dist/tasks/commands.js +32 -7
  226. package/dist/tasks/control.d.ts +11 -0
  227. package/dist/tasks/delivery.d.ts +2 -0
  228. package/dist/tasks/delivery.js +141 -21
  229. package/dist/tasks/loop-log.d.ts +12 -0
  230. package/dist/tasks/loop-log.js +10 -1
  231. package/dist/tasks/receipts.d.ts +7 -3
  232. package/dist/tasks/receipts.js +34 -5
  233. package/dist/tools/bash.d.ts +3 -0
  234. package/dist/tools/bash.js +29 -15
  235. package/dist/tools/contract/presentation.js +7 -5
  236. package/dist/tools/edit-diff.d.ts +11 -0
  237. package/dist/tools/edit-diff.js +148 -0
  238. package/dist/tools/edit-match.d.ts +18 -0
  239. package/dist/tools/edit-match.js +242 -0
  240. package/dist/tools/edit.d.ts +10 -2
  241. package/dist/tools/edit.js +91 -361
  242. package/dist/tools/event-manage.d.ts +2 -1
  243. package/dist/tools/event-manage.js +46 -39
  244. package/dist/tools/file-observations.d.ts +9 -0
  245. package/dist/tools/file-observations.js +50 -0
  246. package/dist/tools/glob-match.d.ts +3 -1
  247. package/dist/tools/glob-match.js +40 -17
  248. package/dist/tools/glob.d.ts +1 -0
  249. package/dist/tools/glob.js +39 -19
  250. package/dist/tools/grep-command.d.ts +13 -0
  251. package/dist/tools/grep-command.js +77 -0
  252. package/dist/tools/grep.js +96 -201
  253. package/dist/tools/index.d.ts +6 -2
  254. package/dist/tools/index.js +9 -4
  255. package/dist/tools/job.js +12 -11
  256. package/dist/tools/read.d.ts +2 -0
  257. package/dist/tools/read.js +10 -2
  258. package/dist/tools/registry.d.ts +16 -11
  259. package/dist/tools/registry.js +32 -12
  260. package/dist/tools/send-media.js +9 -5
  261. package/dist/tools/session-search.d.ts +2 -1
  262. package/dist/tools/session-search.js +15 -5
  263. package/dist/tools/skill.js +13 -12
  264. package/dist/tools/subagent-manage.d.ts +1 -1
  265. package/dist/tools/subagent-manage.js +25 -152
  266. package/dist/tools/subagent.d.ts +24 -2
  267. package/dist/tools/subagent.js +24 -18
  268. package/dist/tools/task-manage/control-tools.js +1 -1
  269. package/dist/tools/task-manage/factory.d.ts +2 -2
  270. package/dist/tools/task-manage/factory.js +40 -4
  271. package/dist/tools/task-manage/lifecycle.d.ts +3 -3
  272. package/dist/tools/task-manage/lifecycle.js +56 -13
  273. package/dist/tools/task-manage/schema.d.ts +4 -1
  274. package/dist/tools/task-manage/schema.js +4 -1
  275. package/dist/tools/task-manage/shared.d.ts +1 -1
  276. package/dist/tools/task-manage/types.d.ts +5 -1
  277. package/dist/tools/write-content.d.ts +7 -1
  278. package/dist/tools/write-content.js +18 -6
  279. package/dist/tools/write.d.ts +3 -0
  280. package/dist/tools/write.js +6 -2
  281. package/dist/tui/cli.d.ts +6 -6
  282. package/dist/tui/cli.js +120 -28
  283. package/dist/tui/client.d.ts +7 -0
  284. package/dist/tui/client.js +67 -16
  285. package/dist/tui/frontend.d.ts +2 -0
  286. package/dist/tui/pitui-frontend.d.ts +4 -0
  287. package/dist/tui/pitui-frontend.js +27 -0
  288. package/dist/tui/render.d.ts +1 -0
  289. package/dist/tui/render.js +5 -0
  290. package/dist/tui/session.js +6 -0
  291. package/dist/usage/ledger.d.ts +1 -1
  292. package/dist/usage/render.js +1 -1
  293. package/dist/web/client.d.ts +1 -0
  294. package/dist/web/client.js +11 -0
  295. package/dist/web/fetch.js +6 -3
  296. package/dist/webapi/auth.d.ts +0 -3
  297. package/dist/webapi/auth.js +3 -7
  298. package/dist/webapi/config.js +17 -14
  299. package/dist/webapi/key-command.js +41 -41
  300. package/dist/webapi/response-state.d.ts +7 -1
  301. package/dist/webapi/response-state.js +166 -3
  302. package/dist/webapi/routes/websocket.js +24 -1
  303. package/dist/webapi/server.d.ts +3 -1
  304. package/dist/webapi/server.js +32 -1
  305. package/dist/webapi/service.js +8 -0
  306. package/dist/webapi/transport.d.ts +2 -0
  307. package/dist/webapi/transport.js +11 -1
  308. package/examples/sub-agents/README.md +43 -75
  309. package/examples/sub-agents/agy-main.md +21 -0
  310. package/examples/sub-agents/claude-high.md +21 -0
  311. package/examples/sub-agents/claude-main.md +21 -0
  312. package/examples/sub-agents/codex-flash.md +21 -0
  313. package/examples/sub-agents/codex-high.md +21 -0
  314. package/examples/sub-agents/codex-main.md +21 -0
  315. package/examples/sub-agents/codex-review.md +20 -0
  316. package/examples/sub-agents/cursor-high.md +20 -0
  317. package/examples/sub-agents/cursor-main.md +20 -0
  318. package/examples/sub-agents/glm-flash.md +21 -0
  319. package/examples/sub-agents/glm-high.md +21 -0
  320. package/examples/sub-agents/pi-scout.md +20 -0
  321. package/package.json +11 -12
  322. package/dist/agent/session/request-tools.d.ts +0 -3
  323. package/dist/agent/session/request-tools.js +0 -20
  324. package/dist/models/api-keys.d.ts +0 -11
  325. package/dist/models/api-keys.js +0 -22
  326. package/dist/playbooks/memory-and-learning.md +0 -55
  327. package/examples/sub-agents/agents/claude-high.md +0 -23
  328. package/examples/sub-agents/agents/claude-main.md +0 -23
  329. package/examples/sub-agents/agents/codex-flash.md +0 -23
  330. package/examples/sub-agents/agents/codex-high.md +0 -23
  331. package/examples/sub-agents/agents/codex-main.md +0 -23
  332. package/examples/sub-agents/agents/codex-review.md +0 -23
  333. package/examples/sub-agents/agents/cursor-high.md +0 -22
  334. package/examples/sub-agents/agents/cursor-main.md +0 -22
  335. package/examples/sub-agents/agents/glm-flash.md +0 -23
  336. package/examples/sub-agents/agents/glm-high.md +0 -23
  337. package/examples/sub-agents/agents/scout.md +0 -30
  338. package/examples/sub-agents/roles/builder-hard.md +0 -34
  339. package/examples/sub-agents/roles/builder.md +0 -34
  340. package/examples/sub-agents/roles/explorer.md +0 -39
  341. package/examples/sub-agents/roles/git-committer.md +0 -43
  342. package/examples/sub-agents/roles/planner.md +0 -33
  343. package/examples/sub-agents/roles/reviewer.md +0 -33
  344. package/examples/sub-agents/roles/verifier.md +0 -35
  345. package/examples/sub-agents/roles/worker.md +0 -34
@@ -9,38 +9,26 @@ import { writeFileAtomically } from "../shared/atomic-file.js";
9
9
  import { RecoverableToolError } from "../shared/recoverable-error.js";
10
10
  import { clipText, errorMessage } from "../shared/text-utils.js";
11
11
  const eventDefinitionSchema = Type.Object({
12
- type: Type.Union([Type.Literal("one-shot"), Type.Literal("periodic"), Type.Literal("immediate")], {
13
- description: '"one-shot" (needs `at`), "periodic" (needs cron `schedule`). "immediate" is always rejected.',
14
- }),
15
- text: Type.Optional(Type.String({
16
- description: "Chat message delivered to the channel when the event fires. Give either `text` or `task`, never both.",
17
- })),
12
+ type: Type.Union([Type.Literal("one-shot"), Type.Literal("periodic")]),
13
+ text: Type.Optional(Type.String({ description: "Reminder message." })),
18
14
  task: Type.Optional(Type.Object({
19
- title: Type.String({ description: "Task title." }),
20
- goal: Type.String({
21
- description: "Goal of each spawned task: result, scope, allowed external actions, key constraints.",
22
- }),
23
- dod: Type.String({ description: 'Checklist items, e.g. "- [ ] <criterion>"; plain prose is rejected.' }),
24
- items: Type.Optional(Type.Array(Type.Object({ text: Type.String({ description: "Work item text." }) }), {
25
- description: "Initial Work Items, numbered W1…Wn in order.",
26
- })),
15
+ title: Type.String(),
16
+ goal: Type.String(),
17
+ dod: Type.String({ description: "Markdown checklist." }),
18
+ items: Type.Optional(Type.Array(Type.Object({ text: Type.String() }))),
27
19
  budget: Type.Optional(Type.Object({
28
20
  steps: Type.Optional(Type.Integer({ minimum: 1 })),
29
- usd: Type.Optional(Type.Number({ description: "Max cost for one spawned task." })),
21
+ usd: Type.Optional(Type.Number()),
30
22
  })),
31
- }, {
32
- description: "Template for a task instance. Each time the event fires, a fresh task is created from it and the runtime drives it in its own session — use it for recurring or scheduled work that needs state, delegation or checking. If the previous instance is still running, the occurrence is skipped and the user is told.",
33
- })),
34
- at: Type.Optional(Type.String({ description: "one-shot local time, e.g. 2026-07-27T07:30:00+08:00 (2 min to ~24.8 days out)." })),
35
- schedule: Type.Optional(Type.String({ description: "periodic 5-field cron, in the host timezone." })),
23
+ }, { description: "Task template. Provide text or task." })),
24
+ at: Type.Optional(Type.String({ description: "Required for one-shot: time with offset, 2 min to ~24.8 days ahead." })),
25
+ schedule: Type.Optional(Type.String({ description: "Required for periodic: five-field cron in host timezone." })),
36
26
  preAction: Type.Optional(Type.Object({
37
27
  type: Type.Literal("bash"),
38
- command: Type.String({
39
- description: "Command run just before delivery; exit 0 = fire, non-zero = skip.",
40
- }),
41
- timeoutMs: Type.Optional(Type.Integer({ minimum: 1, description: "Timeout in milliseconds (not s)." })),
42
- }, { description: "Optional gate/sensor command." })),
43
- }, { description: "The event to create/update. Channel is bound automatically — do not pass channelId." });
28
+ command: Type.String({ description: "Exit 0 fires; nonzero skips." }),
29
+ timeoutMs: Type.Optional(Type.Integer({ minimum: 1 })),
30
+ })),
31
+ });
44
32
  const eventManageSchema = Type.Object({
45
33
  action: Type.Union([
46
34
  Type.Literal("list"),
@@ -48,12 +36,8 @@ const eventManageSchema = Type.Object({
48
36
  Type.Literal("create"),
49
37
  Type.Literal("update"),
50
38
  Type.Literal("delete"),
51
- ], {
52
- description: '"list" this desk\'s events, "show" one event\'s full definition (for a safe update), or "create" / "update" / "delete" one by name. Any channel of the desk may manage any of its events.',
53
- }),
54
- name: Type.Optional(Type.String({
55
- description: "Event name (filename without .json); required for show/create/update/delete, ignored for list.",
56
- })),
39
+ ]),
40
+ name: Type.Optional(Type.String({ description: "Filename stem, required except for list." })),
57
41
  definition: Type.Optional(eventDefinitionSchema),
58
42
  });
59
43
  function parseAction(action) {
@@ -114,6 +98,12 @@ function validateDefinition(definition, name, options, deliveryChannelId) {
114
98
  if (definition.type === "periodic" && !definition.schedule?.trim()) {
115
99
  throw new RecoverableToolError('A periodic event needs "schedule" (a 5-field cron expression).');
116
100
  }
101
+ if (definition.preAction?.timeoutMs !== undefined &&
102
+ definition.preAction.timeout !== undefined &&
103
+ definition.preAction.timeoutMs !== definition.preAction.timeout) {
104
+ throw new RecoverableToolError("Conflicting preAction.timeoutMs and preAction.timeout; pass only preAction.timeoutMs (in milliseconds).");
105
+ }
106
+ const preActionTimeoutMs = definition.preAction?.timeoutMs ?? definition.preAction?.timeout;
117
107
  // Assemble the on-disk shape. `channelId` is bound here, never taken from the model; the
118
108
  // preAction timeout field is `timeout` (ms) on disk but `timeoutMs` in the schema so the unit
119
109
  // is unambiguous (fix plan §3.6).
@@ -130,7 +120,7 @@ function validateDefinition(definition, name, options, deliveryChannelId) {
130
120
  preAction: {
131
121
  type: "bash",
132
122
  command: definition.preAction.command,
133
- ...(definition.preAction.timeoutMs !== undefined ? { timeout: definition.preAction.timeoutMs } : {}),
123
+ ...(preActionTimeoutMs !== undefined ? { timeout: preActionTimeoutMs } : {}),
134
124
  },
135
125
  }
136
126
  : {}),
@@ -195,16 +185,27 @@ export async function manageEvent(options, request) {
195
185
  throw new RecoverableToolError(`Event "${eventName}" does not exist. Use action "list" to see what's here.`);
196
186
  }
197
187
  const existing = await readEvent(eventPath, eventName);
188
+ const shown = existing.preAction?.timeout !== undefined
189
+ ? {
190
+ ...existing,
191
+ preAction: {
192
+ type: existing.preAction.type,
193
+ command: existing.preAction.command,
194
+ timeoutMs: existing.preAction.timeout,
195
+ },
196
+ }
197
+ : existing;
198
198
  return {
199
199
  action: "show",
200
200
  name: eventName,
201
201
  path: eventPath,
202
202
  eventType: existing.type,
203
203
  channelId: existing.channelId,
204
- notice: JSON.stringify(existing, null, 2),
204
+ notice: JSON.stringify(shown, null, 2),
205
205
  };
206
206
  }
207
207
  if (request.action === "delete") {
208
+ await unlink(`${eventPath}.error.txt`).catch(() => undefined);
208
209
  if (!existsSync(eventPath)) {
209
210
  return {
210
211
  action: "delete",
@@ -261,10 +262,7 @@ export function createEventManageTool(options) {
261
262
  return {
262
263
  name: "event_manage",
263
264
  label: "event_manage",
264
- description: "List, show, create, update, or delete this desk's scheduled events (one-shot check-ins and periodic " +
265
- "cadences). A created event wakes this channel; an update keeps the event's original delivery channel. Use list " +
266
- "to recover event names, and show to read an event's full definition before an update. immediate events are " +
267
- "rejected.",
265
+ description: "For a standalone text reminder with known time and offset, use event_manage as the first tool call: action=create, definition with type=one-shot, text and at (e.g. 2026-12-01T10:00:00+08:00). Confirm after success. Read event-sensors.md for preAction, event-task-template.md for task, or event-scheduling.md for other periodic or update calls. Show before replacing a definition; preserve delivery.",
268
266
  parameters: eventManageSchema,
269
267
  execute: async (_toolCallId, args) => {
270
268
  const result = await manageEvent(options, {
@@ -272,7 +270,16 @@ export function createEventManageTool(options) {
272
270
  name: args.name,
273
271
  definition: args.definition,
274
272
  });
275
- const text = result.action === "list" || result.action === "show" ? result.notice : JSON.stringify(result, null, 2);
273
+ let text = result.notice;
274
+ if (result.action !== "list" && result.action !== "show") {
275
+ const fields = [
276
+ `name=${result.name}`,
277
+ result.eventType && `type=${result.eventType}`,
278
+ result.channelId && `channel=${result.channelId}`,
279
+ result.deleted !== undefined && `deleted=${result.deleted}`,
280
+ ].filter(Boolean);
281
+ text += ` (${fields.join(", ")})`;
282
+ }
276
283
  return {
277
284
  content: [{ type: "text", text }],
278
285
  details: { ...result },
@@ -0,0 +1,9 @@
1
+ import { type FileStat, type FileStore } from "../file-store.js";
2
+ export declare function createFileObservations(capacity?: number): {
3
+ record(target: string, stat: FileStat): void;
4
+ describeWriteNote(target: string, path: string, before?: FileStat): string | undefined;
5
+ describeEditNote(target: string, path: string, before: FileStat): string | undefined;
6
+ };
7
+ export type FileObservations = ReturnType<typeof createFileObservations>;
8
+ /** A metadata error after a successful write must not turn it into a failed tool call. */
9
+ export declare function observeCurrentFile(observations: FileObservations | undefined, store: FileStore, target: string): Promise<void>;
@@ -0,0 +1,50 @@
1
+ import { fingerprintOf, fingerprintsEqual, } from "../file-store.js";
2
+ export function createFileObservations(capacity = 256) {
3
+ const observed = new Map();
4
+ const previous = (target) => {
5
+ const value = observed.get(target);
6
+ if (value) {
7
+ observed.delete(target);
8
+ observed.set(target, value);
9
+ }
10
+ return value;
11
+ };
12
+ return {
13
+ record(target, stat) {
14
+ if (!stat.isFile)
15
+ return;
16
+ observed.delete(target);
17
+ observed.set(target, fingerprintOf(stat));
18
+ if (observed.size > capacity) {
19
+ const oldest = observed.keys().next().value;
20
+ if (oldest !== undefined)
21
+ observed.delete(oldest);
22
+ }
23
+ },
24
+ describeWriteNote(target, path, before) {
25
+ if (!before?.isFile || before.size === 0)
26
+ return undefined;
27
+ const last = previous(target);
28
+ if (!last) {
29
+ return `Note: Overwrote existing file ${path} (${before.size} bytes) without reading it first in this session; inspect git diff if unintended.`;
30
+ }
31
+ if (!fingerprintsEqual(last, fingerprintOf(before))) {
32
+ return `Note: ${path} had been modified externally since you last read or wrote it; verify no concurrent changes were lost.`;
33
+ }
34
+ },
35
+ describeEditNote(target, path, before) {
36
+ const last = previous(target);
37
+ if (last && !fingerprintsEqual(last, fingerprintOf(before))) {
38
+ return `Note: ${path} was modified since your last read; review surrounding context if needed.`;
39
+ }
40
+ },
41
+ };
42
+ }
43
+ /** A metadata error after a successful write must not turn it into a failed tool call. */
44
+ export async function observeCurrentFile(observations, store, target) {
45
+ if (!observations)
46
+ return;
47
+ const stat = await store.stat(target).catch(() => undefined);
48
+ if (stat)
49
+ observations.record(target, stat);
50
+ }
@@ -29,4 +29,6 @@ export interface GlobMatcher {
29
29
  /** True when `path` — a `/`-joined path relative to the walk root — matches the pattern. */
30
30
  test(path: string): boolean;
31
31
  }
32
- export declare function compileGlobPattern(pattern: string): GlobMatcher;
32
+ export declare function compileGlobPattern(pattern: string, options?: {
33
+ characterClasses?: boolean;
34
+ }): GlobMatcher;
@@ -35,14 +35,15 @@ const GLOBSTAR = Symbol("globstar");
35
35
  const STAR = Symbol("star");
36
36
  /** `?` inside a segment: exactly one character. */
37
37
  const ANY = Symbol("any");
38
- export function compileGlobPattern(pattern) {
38
+ export function compileGlobPattern(pattern, options = {}) {
39
39
  if (pattern.length > MAX_PATTERN_LENGTH) {
40
40
  throw new Error(`pattern is longer than ${MAX_PATTERN_LENGTH} characters`);
41
41
  }
42
42
  // The anchoring decision is made on the pattern as written, before expansion: `{src/a,b}`
43
43
  // carries a separator and is therefore path-anchored for *both* of its alternatives.
44
44
  const matchBasenameOnly = !pattern.includes("/");
45
- const variants = expandBraces(pattern).map(compileVariant);
45
+ const characterClasses = options.characterClasses === true;
46
+ const variants = expandBraces(pattern, characterClasses).map((variant) => compileVariant(variant, characterClasses));
46
47
  return {
47
48
  test(path) {
48
49
  const segments = matchBasenameOnly ? [path.slice(path.lastIndexOf("/") + 1)] : path.split("/");
@@ -57,13 +58,13 @@ export function compileGlobPattern(pattern) {
57
58
  * and a comma inside a nested group are read the way the writer meant. An unmatched `{` stays a
58
59
  * literal character, as it did before.
59
60
  */
60
- function expandBraces(pattern) {
61
- const open = findBraceGroup(pattern);
61
+ function expandBraces(pattern, characterClasses) {
62
+ const open = findBraceGroup(pattern, characterClasses);
62
63
  if (!open)
63
64
  return [pattern];
64
65
  const results = [];
65
66
  for (const alternative of open.alternatives) {
66
- for (const expanded of expandBraces(`${open.prefix}${alternative}${open.suffix}`)) {
67
+ for (const expanded of expandBraces(`${open.prefix}${alternative}${open.suffix}`, characterClasses)) {
67
68
  results.push(expanded);
68
69
  if (results.length > MAX_BRACE_VARIANTS) {
69
70
  throw new Error(`brace expansion produces more than ${MAX_BRACE_VARIANTS} patterns`);
@@ -72,19 +73,32 @@ function expandBraces(pattern) {
72
73
  }
73
74
  return results;
74
75
  }
75
- function findBraceGroup(pattern) {
76
- const start = pattern.indexOf("{");
77
- if (start === -1)
78
- return undefined;
76
+ function classEnd(pattern, start, characterClasses) {
77
+ return characterClasses && pattern[start] === "[" ? pattern.indexOf("]", start + 1) : -1;
78
+ }
79
+ function findBraceGroup(pattern, characterClasses) {
80
+ let start = -1;
79
81
  let depth = 0;
80
82
  const alternatives = [];
81
83
  let current = "";
82
- for (let i = start; i < pattern.length; i++) {
84
+ for (let i = 0; i < pattern.length; i++) {
85
+ const end = classEnd(pattern, i, characterClasses);
86
+ if (end > i) {
87
+ if (depth > 0)
88
+ current += pattern.slice(i, end + 1);
89
+ i = end;
90
+ continue;
91
+ }
83
92
  const char = pattern[i];
84
93
  if (char === "{") {
85
94
  depth++;
86
- if (depth === 1)
87
- continue; // the group's own opening brace is not content
95
+ if (depth === 1) {
96
+ start = i;
97
+ continue;
98
+ }
99
+ }
100
+ else if (depth === 0) {
101
+ continue;
88
102
  }
89
103
  else if (char === "}") {
90
104
  depth--;
@@ -102,15 +116,24 @@ function findBraceGroup(pattern) {
102
116
  }
103
117
  return undefined; // unbalanced `{` — leave it as a literal
104
118
  }
105
- function compileVariant(pattern) {
119
+ function compileVariant(pattern, characterClasses) {
106
120
  const rawSegments = pattern.split("/");
107
- const segments = rawSegments.map((segment) => segment === "**" ? GLOBSTAR : compileSegment(segment));
121
+ const segments = rawSegments.map((segment) => segment === "**" ? GLOBSTAR : compileSegment(segment, characterClasses));
108
122
  const trailingGlobstar = segments.length > 1 && segments[segments.length - 1] === GLOBSTAR;
109
123
  return { segments, trailingGlobstar };
110
124
  }
111
- function compileSegment(segment) {
125
+ function compileSegment(segment, characterClasses) {
112
126
  const tokens = [];
113
- for (const char of segment) {
127
+ for (let i = 0; i < segment.length; i++) {
128
+ const char = segment[i];
129
+ const end = classEnd(segment, i, characterClasses);
130
+ if (end >= 0) {
131
+ const body = segment.slice(i + 1, end).replace(/^!/, "^");
132
+ // Compile only one character class. The wildcard matcher handles the surrounding stars.
133
+ tokens.push(new RegExp(`[${body}]`));
134
+ i = end;
135
+ continue;
136
+ }
114
137
  if (char === "*") {
115
138
  // Adjacent stars are the same star. A `**` that is not a whole segment (`a**b`) has
116
139
  // always meant single-segment `*`, and collapsing keeps that without a second token.
@@ -180,7 +203,7 @@ function matchSegment(tokens, text) {
180
203
  tokenIndex++;
181
204
  continue;
182
205
  }
183
- if (token === ANY || (typeof token === "string" && token === text[textIndex])) {
206
+ if (token === ANY || token === text[textIndex] || (token instanceof RegExp && token.test(text[textIndex]))) {
184
207
  tokenIndex++;
185
208
  textIndex++;
186
209
  continue;
@@ -5,6 +5,7 @@ import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.j
5
5
  declare const globSchema: Type.TObject<{
6
6
  pattern: Type.TString;
7
7
  path: Type.TOptional<Type.TString>;
8
+ skip: Type.TOptional<Type.TInteger>;
8
9
  }>;
9
10
  export interface GlobToolOptions {
10
11
  securityConfig?: SecurityConfig;
@@ -18,6 +18,7 @@ import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
18
18
  const MAX_SCAN_ENTRIES = 50_000;
19
19
  /** Matched files are only `stat`-ed (for mtime ordering) up to this many; beyond it, scan order stands. */
20
20
  const MAX_STAT_FOR_SORT = 2_000;
21
+ const STAT_CONCURRENCY = 32;
21
22
  /** Paths shown inline; matching `grep`'s FILE_PAGE_LIMIT order of magnitude for a discovery tool. */
22
23
  const GLOB_MAX_RESULTS = 100;
23
24
  const globSchema = Type.Object({
@@ -26,6 +27,7 @@ const globSchema = Type.Object({
26
27
  'matches the basename at any depth, so "*" and "*.ts" both search the whole tree; include a "/" to anchor the depth.',
27
28
  }),
28
29
  path: Type.Optional(Type.String({ description: "Directory to search in. Defaults to the current working directory." })),
30
+ skip: Type.Optional(Type.Integer({ minimum: 0, description: "Result offset for paging." })),
29
31
  });
30
32
  /** Turn a path relative to the search root into an address `read` accepts unchanged. */
31
33
  function toReadableAddress(target, rel, securityContext) {
@@ -48,12 +50,9 @@ export function createGlobTool(fileStore, options = {}) {
48
50
  return {
49
51
  name: "glob",
50
52
  label: "glob",
51
- description: "Find files whose paths match a glob pattern. Returns matching file paths only (never directories), " +
52
- "including hidden files; VCS/build directories (node_modules, .git, dist, ...) are excluded. Prefer this " +
53
- "over `bash find`/`ls -R` for path discovery — it is bounded and sorted by modification time (newest first) " +
54
- `when few enough files match; up to ${GLOB_MAX_RESULTS} paths come back inline.`,
53
+ description: `Find paths, including hidden files. Skips common VCS/build directories. Returns up to ${GLOB_MAX_RESULTS} files, newest first when possible. Use skip to page.`,
55
54
  parameters: globSchema,
56
- execute: async (_toolCallId, { pattern, path }, signal) => {
55
+ execute: async (_toolCallId, { pattern, path, skip }, signal) => {
57
56
  if (!pattern.trim()) {
58
57
  throw new RecoverableToolError("Pattern must not be empty.");
59
58
  }
@@ -117,11 +116,16 @@ export function createGlobTool(fileStore, options = {}) {
117
116
  let ordered;
118
117
  if (sortableByMtime) {
119
118
  const withMtime = [];
120
- for (const relativePath of matched) {
121
- const stat = await fileStore.stat(join(target, ...relativePath.split("/")));
122
- withMtime.push({ relativePath, mtimeMs: stat?.mtimeMs ?? 0 });
119
+ for (let start = 0; start < matched.length; start += STAT_CONCURRENCY) {
120
+ signal?.throwIfAborted();
121
+ const batch = await Promise.all(matched.slice(start, start + STAT_CONCURRENCY).map(async (relativePath) => {
122
+ const stat = await fileStore.stat(join(target, ...relativePath.split("/")));
123
+ return { relativePath, mtimeMs: stat?.mtimeMs ?? 0 };
124
+ }));
125
+ withMtime.push(...batch);
123
126
  }
124
- withMtime.sort((a, b) => b.mtimeMs - a.mtimeMs);
127
+ signal?.throwIfAborted();
128
+ withMtime.sort((a, b) => b.mtimeMs - a.mtimeMs || a.relativePath.localeCompare(b.relativePath));
125
129
  ordered = withMtime.map((entry) => entry.relativePath);
126
130
  }
127
131
  else {
@@ -131,14 +135,32 @@ export function createGlobTool(fileStore, options = {}) {
131
135
  // `target` alone is ambiguous (read resolves relative paths against the cwd, not
132
136
  // the search root), so emit a cwd-relative path when the hit is inside it and
133
137
  // an absolute path otherwise.
134
- const page = ordered.slice(0, GLOB_MAX_RESULTS).map((rel) => toReadableAddress(target, rel, securityContext));
138
+ const startOffset = Math.max(0, skip ?? 0);
139
+ const page = ordered
140
+ .slice(startOffset, startOffset + GLOB_MAX_RESULTS)
141
+ .map((rel) => toReadableAddress(target, rel, securityContext));
135
142
  const footerParts = [];
136
- if (ordered.length > page.length) {
137
- footerParts.push(`Showing ${page.length} of ${ordered.length} matches${sortableByMtime ? ", newest first" : ""}. ` +
138
- "Narrow the pattern, or pass path=<subdir>, to see the rest.");
143
+ const truncation = truncateHead(page.join("\n"));
144
+ let shownCount = page.length;
145
+ if (truncation.truncated) {
146
+ let chars = 0;
147
+ for (const [index, path] of page.entries()) {
148
+ chars += path.length + 1;
149
+ if (chars - 1 > truncation.content.length) {
150
+ shownCount = index;
151
+ break;
152
+ }
153
+ }
154
+ }
155
+ const end = startOffset + shownCount;
156
+ if (page.length === 0) {
157
+ footerParts.push(`skip=${startOffset} is past the ${ordered.length} matches. Use skip=0 to start again.`);
158
+ }
159
+ else if (end < ordered.length) {
160
+ footerParts.push(`Showing ${startOffset + 1}-${end} of ${ordered.length} matches. Use skip=${end} for the next page, or narrow the pattern or path.`);
139
161
  }
140
- else if (!sortableByMtime) {
141
- footerParts.push(`${ordered.length} matches, in scan order (too many to sort by modification time).`);
162
+ if (!sortableByMtime) {
163
+ footerParts.push("Results are in scan order (too many to sort by modification time).");
142
164
  }
143
165
  if (walk.truncated) {
144
166
  footerParts.push(`Scan stopped after ${MAX_SCAN_ENTRIES.toLocaleString()} files; results may be incomplete. Narrow path to search a smaller subtree.`);
@@ -146,9 +168,7 @@ export function createGlobTool(fileStore, options = {}) {
146
168
  if (readDenyExcluded > 0) {
147
169
  footerParts.push(`${readDenyExcluded} matching path(s) excluded by the read policy.`);
148
170
  }
149
- const body = page.join("\n");
150
- const truncation = truncateHead(body);
151
- let outputText = truncation.content;
171
+ let outputText = page.slice(0, shownCount).join("\n");
152
172
  if (footerParts.length > 0) {
153
173
  outputText += `\n\n[${footerParts.join(" ")}]`;
154
174
  }
@@ -159,7 +179,7 @@ export function createGlobTool(fileStore, options = {}) {
159
179
  content: [{ type: "text", text: outputText }],
160
180
  details: {
161
181
  matchCount: ordered.length,
162
- shownCount: page.length,
182
+ shownCount,
163
183
  scanTruncated: walk.truncated,
164
184
  ...(readDenyExcluded > 0 ? { readDenyExcluded } : {}),
165
185
  },
@@ -0,0 +1,13 @@
1
+ import type { Executor } from "../executor.js";
2
+ export declare function isRgAvailable(executor: Executor): Promise<boolean>;
3
+ interface SearchCommandOptions {
4
+ mode: "content" | "files" | "count";
5
+ pattern: string;
6
+ target: string;
7
+ glob?: string;
8
+ literal?: boolean;
9
+ caseSensitive?: boolean;
10
+ readDeny: string[];
11
+ }
12
+ export declare function buildSearchCommand(useRg: boolean, options: SearchCommandOptions): string;
13
+ export {};
@@ -0,0 +1,77 @@
1
+ import { basename } from "node:path";
2
+ import { shellEscape } from "../shared/os.js";
3
+ import { IGNORED_DIR_SEGMENTS } from "./ignore-dirs.js";
4
+ const rgAvailability = new WeakMap();
5
+ export function isRgAvailable(executor) {
6
+ let available = rgAvailability.get(executor);
7
+ if (!available) {
8
+ available = Promise.resolve()
9
+ .then(() => executor.exec("command -v rg", { timeout: 2 }))
10
+ .then((result) => result.code === 0, () => false);
11
+ rgAvailability.set(executor, available);
12
+ }
13
+ return available;
14
+ }
15
+ function denyBasenames(entries) {
16
+ const basenames = new Set();
17
+ for (const entry of entries) {
18
+ // A literal basename pushdown can overexclude, so the complete policy still runs on returned paths.
19
+ if (/[*?[\]{}]/.test(entry))
20
+ continue;
21
+ const name = basename(entry.replace(/\/+$/, ""));
22
+ if (name && name !== "." && name !== "..")
23
+ basenames.add(name);
24
+ }
25
+ return basenames;
26
+ }
27
+ function rgFlags(options, denied) {
28
+ const flags = ["--no-config", "--null", "--no-messages", "--hidden", "--color=never"];
29
+ if (options.mode === "files")
30
+ flags.push("--files-with-matches");
31
+ else if (options.mode === "count")
32
+ flags.push("--count", "--with-filename");
33
+ else
34
+ flags.push("--line-number", "--with-filename", "--no-heading", "-B1", "-A3");
35
+ flags.push(options.caseSensitive === false ? "-i" : "-s");
36
+ if (options.literal)
37
+ flags.push("-F");
38
+ for (const segment of new Set([...IGNORED_DIR_SEGMENTS, ...denied])) {
39
+ // Escape a literal backslash before using it in a ripgrep glob.
40
+ const name = segment.replaceAll("\\", "\\\\");
41
+ flags.push("--glob", shellEscape(`!**/${name}/**`));
42
+ if (denied.has(segment))
43
+ flags.push("--glob", shellEscape(`!**/${name}`));
44
+ }
45
+ if (options.glob && !/[:/\\[\]{}]/.test(options.glob)) {
46
+ // An include --glob overrides .gitignore. A file type filter keeps the ignore rules in effect.
47
+ // Complex basename patterns are checked by the common output filter.
48
+ flags.push("--type-add", shellEscape(`pipiclawbasename:${options.glob}`), "--type", "pipiclawbasename");
49
+ }
50
+ return flags;
51
+ }
52
+ function grepFlags(options, denied) {
53
+ const flags = ["--null", "-I", options.literal ? "-F" : "-E"];
54
+ if (options.mode === "files")
55
+ flags.push("-rlH");
56
+ else
57
+ flags.push("-rnH");
58
+ if (options.mode === "content")
59
+ flags.push("-B1", "-A3");
60
+ // BSD grep's -c does not NUL-terminate its filenames. Count numbered matching lines instead.
61
+ if (options.caseSensitive === false)
62
+ flags.push("-i");
63
+ for (const segment of IGNORED_DIR_SEGMENTS)
64
+ flags.push(`--exclude-dir=${segment}`);
65
+ for (const base of denied) {
66
+ flags.push(`--exclude-dir=${shellEscape(base)}`, `--exclude=${shellEscape(base)}`);
67
+ }
68
+ // grep --include does not expand braces. The common basename filter handles those patterns.
69
+ if (options.glob && !/[{}]/.test(options.glob))
70
+ flags.push(`--include=${shellEscape(options.glob)}`);
71
+ return flags;
72
+ }
73
+ export function buildSearchCommand(useRg, options) {
74
+ const denied = denyBasenames(options.readDeny);
75
+ const flags = useRg ? rgFlags(options, denied) : grepFlags(options, denied);
76
+ return `${useRg ? "rg" : "grep"} ${flags.join(" ")} -- ${shellEscape(options.pattern)} ${shellEscape(options.target)}`;
77
+ }