@zhoubiao188/pi-scheduled-tasks 0.0.0-stage → 0.2.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zhoubiao188
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,234 @@
1
- # Temporary Holding Version
1
+ # pi-scheduled-tasks
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Scheduled tasks for [pi](https://github.com/earendil-works/pi) and
4
+ [Pi Web](https://github.com/agegr/pi-web): cron expressions, intervals and
5
+ one-off prompts, managed from a dialog-driven interface inside the session.
6
+
7
+ Every run is a normal `pi` session in the task's working directory, so it shows
8
+ up in Pi Web's sidebar with its own transcript, tools and cost — and the same
9
+ tasks work in the terminal.
10
+
11
+ ```
12
+ /tasks
13
+ ```
14
+
15
+ ```
16
+ Scheduled tasks · 2 active · 2 total
17
+ a1b2 ● Morning inbox — cron 0 9 * * * · next in 3h
18
+ c3d4 ● Deploy check — every 30m · next in 12m
19
+ + New task
20
+ Close
21
+ ```
22
+
23
+ ## Why an extension
24
+
25
+ Pi Web keeps its scope deliberately small. Its contribution guide lists
26
+ schedulers and "scheduled messages" as out of scope, and points at an extension
27
+ for exactly this use case:
28
+
29
+ - [CONTRIBUTING.md — Out of scope](https://github.com/agegr/pi-web/blob/main/CONTRIBUTING.md#out-of-scope)
30
+ - [Issue #666](https://github.com/agegr/pi-web/issues/666) — closed with a
31
+ `/schedule` extension as the answer
32
+ - [PR #1409](https://github.com/agegr/pi-web/pull/1409) — a scheduler in the
33
+ core was declined: "a scheduler is outside what pi-web is meant to be […] A pi
34
+ extension gives the same thing to the CLI as well."
35
+
36
+ So this is a pi package, not a Pi Web change. It uses only the documented
37
+ extension API and Pi Web's documented
38
+ [liveness registry](https://github.com/agegr/pi-web/blob/main/docs/integrations.md#extension-session-liveness),
39
+ and it behaves the same in the CLI and in Pi Web.
40
+
41
+ ## Related work
42
+
43
+ `pi-scheduled-tasks` on npm (by errfld) also schedules prompts: it runs them
44
+ inside the current session and adds model-callable tools. This package does one
45
+ thing differently: every run is a separate session in the task's directory, and
46
+ the manager, status bar and run history are built for the browser. If you only
47
+ need reminders in the session you already have open, that package may be enough.
48
+
49
+ ## Install
50
+
51
+ ```bash
52
+ pi install git:github.com/zhoubiao188/pi-scheduled-tasks
53
+ ```
54
+
55
+ Or try it without installing:
56
+
57
+ ```bash
58
+ pi -e git:github.com/zhoubiao188/pi-scheduled-tasks
59
+ ```
60
+
61
+ Restart Pi Web after installing, or run `/reload` in a session. In Pi Web the
62
+ composer completes `/tasks` like any other slash command.
63
+
64
+ Requirements: pi 0.84 or newer; Pi Web 0.9.0 or newer for the status-bar button and
65
+ the liveness registry. Older Pi Web versions still work, but an idle session may
66
+ be evicted, so runs wait until a session is open again. No runtime dependencies.
67
+
68
+ ## Use
69
+
70
+ `/tasks` opens the manager. Select a task to run it now, edit it, pause or
71
+ resume it, see its runs, or delete it.
72
+
73
+ | Command | What it does |
74
+ | --- | --- |
75
+ | `/tasks` | Open the manager |
76
+ | `/tasks add` | Create a task (name, prompt, schedule, directory) |
77
+ | `/tasks list` | Print every task and its next run |
78
+ | `/tasks runs` | Every task's runs on one timeline; open one |
79
+ | `/tasks run <id>` | Run a task now, without changing its schedule |
80
+ | `/tasks edit <id>` | Change name, prompt, schedule or directory |
81
+ | `/tasks pause <id>` / `resume <id>` | Stop or restart the schedule |
82
+ | `/tasks runs <id>` | Last runs; pick one to open its session |
83
+ | `/tasks rm <id>` | Delete the task and its history |
84
+ | `/tasks show <id>` | Print one task in full |
85
+ | `/at 09:00 <prompt>` | Quick one-off task in the current directory |
86
+
87
+ ### Creating a task
88
+
89
+ `/tasks add` asks for a starting point first (blank, or one of four templates: a
90
+ daily briefing, a weekly report, an inbox cleanup, a CI check), then:
91
+
92
+ 1. **Name** and **prompt**.
93
+ 2. **Repeat**: every day, every week (several weekdays), every month (several
94
+ days), every year, every N minutes or hours, once, or a custom cron.
95
+ 3. **Time** for the rule, e.g. `09:00`.
96
+ 4. **Working directory**, **end date** (optional), **model** (optional), and
97
+ what to do about a missed run.
98
+
99
+ A template skips straight to the schedule question with its own default.
100
+
101
+ The agent can create a task from a sentence too — "every weekday at 9, summarize
102
+ CI" — through the `scheduled_task` tool (create and list only).
103
+
104
+ ### Schedules
105
+
106
+ | Form | Example | Meaning |
107
+ | --- | --- | --- |
108
+ | Cron | `0 9 * * *` | 09:00 every day, local time |
109
+ | Cron | `*/15 * * * *` | Every 15 minutes |
110
+ | Cron | `0 9 * * mon-fri` | Weekdays at 09:00 |
111
+ | Cron | `@daily`, `@hourly`, `@weekly`, `@monthly` | Macros |
112
+ | Interval | `every 30m`, `1h30m`, `every 2d` | At least one minute |
113
+ | Once | `at 09:00`, `at 2026-11-26T09:00` | One run, then the task pauses |
114
+
115
+ Cron follows the usual rules: five fields, lists, ranges, steps, month and
116
+ weekday names, and day-of-month/day-of-week as either/or when both are
117
+ restricted.
118
+
119
+ ### What a run looks like
120
+
121
+ A run starts a headless `pi` in the task's directory:
122
+
123
+ ```
124
+ pi --mode json -p --name "⏰ Morning inbox" "<prompt>"
125
+ ```
126
+
127
+ The session is saved like any other, so it appears in Pi Web under that
128
+ project, and **Runs** opens it directly. The task's history keeps the exit
129
+ status, duration, a short summary and the session file (last 20 runs).
130
+
131
+ ### In the Pi Web UI
132
+
133
+ - A status-bar button shows `⏰ 2 active · next in 12m`; clicking it opens
134
+ `/tasks`.
135
+ - A widget above the composer lists the next runs.
136
+ - Create and edit use Pi Web's own dialogs, so they work on a phone too.
137
+
138
+ ## Automation-guide parity
139
+
140
+ WorkBuddy publishes an automation guide; this is how the parts that make sense
141
+ for a local pi client map onto it.
142
+
143
+ | WorkBuddy | Here |
144
+ | --- | --- |
145
+ | Name, prompt, workspace | Same: name, prompt, working directory |
146
+ | Repeat: interval, once, daily, weekly, monthly, yearly | Same, plus custom cron |
147
+ | Multiple weekdays or month days in one rule | Same (`mon,wed,fri`, `1,15`) |
148
+ | Time and validity period | Time, plus an optional end date |
149
+ | Model per task | Yes (`--model`) |
150
+ | Run now, edit, pause, delete | Same |
151
+ | Run records across every task | `/tasks runs` |
152
+ | A task page with a run timeline; open a run | The manager's **Runs**, then open the run's session |
153
+ | Create from a sentence | `scheduled_task` tool |
154
+ | Create from a template | Four built-in templates |
155
+ | Cloud tasks that run with the computer off | No; runs happen on this machine |
156
+ | Push results to WeCom | No; each run is a session, so Pi Web's own notifications apply |
157
+ | Full-access vs default permissions | No; a run uses pi's own configuration and trust rules |
158
+
159
+ Two weeks is the one repeat rule missing: a five-field cron cannot express it.
160
+
161
+ ## Missed runs
162
+
163
+ Timers live in a pi session. While Pi Web is running, the session that owns the
164
+ scheduler is kept loaded for as long as it has active tasks (the documented
165
+ liveness registry), even with no browser tab open.
166
+
167
+ After a restart nothing fires until a session is open again. Each task then
168
+ follows its **catch-up** choice:
169
+
170
+ - **Skip** (default): the missed occurrence is recorded as `missed`, never sent
171
+ late, and the schedule moves on.
172
+ - **Run once**: the task runs once when the session opens, then continues on
173
+ schedule. There is never a burst of catch-up runs.
174
+
175
+ Only one session runs tasks at a time (a lock file), so two open sessions or two
176
+ Pi Web tabs cannot double-fire. A per-occurrence claim makes a duplicate across
177
+ processes a no-op as well.
178
+
179
+ ## Safety and resource limits
180
+
181
+ - **No shell.** The prompt is one argv element with `shell: false`; nothing in a
182
+ task is ever interpreted by a shell, and no command line is built from it.
183
+ - **No new privileges.** A run is an ordinary pi session: same auth, same
184
+ extensions, same tool permissions, same project trust rules.
185
+ - **Bounded.** 50 tasks, 20,000 characters per prompt, 120 per name, 20 history
186
+ entries, one run at a time, 30 minutes per run (SIGTERM, then SIGKILL).
187
+ - **Private state.** `~/.pi/agent/scheduled-tasks.json` is written atomically
188
+ with mode `0600` in a `0700` directory. An unreadable file is moved aside,
189
+ never deleted.
190
+ - **No recursion.** A task's own pi process gets `PI_SCHEDULED_TASK_CHILD=1` and
191
+ the extension disables itself there.
192
+ - **Offline.** The extension makes no network calls and sends no telemetry.
193
+ - **No hidden writes.** It only touches its own store, lock, claim files, and
194
+ the session files pi writes for each run.
195
+
196
+ Tasks are stored in the clear so you can read and back them up. Do not put
197
+ secrets in a prompt; use the provider configuration pi already has.
198
+
199
+ ## Configuration
200
+
201
+ | Variable | Default | Purpose |
202
+ | --- | --- | --- |
203
+ | `PI_SCHEDULED_TASKS_PI_BIN` | `pi` next to the running Node | The executable used for a run |
204
+ | `PI_SCHEDULED_TASKS_TIMEOUT_MS` | `1800000` | Per-run timeout |
205
+ | `PI_SCHEDULED_TASKS_DIR` | `~/.pi/agent` | Store location (tests, isolated setups) |
206
+
207
+ If no `pi` executable can be found, `/tasks run` still works: the prompt is
208
+ delivered into the current session instead of a separate run.
209
+
210
+ ## Known limits
211
+
212
+ - Times are the local time of the machine running pi. Cron uses the JavaScript
213
+ `Date` rules, so a run at 02:30 on a DST transition can be skipped or repeat.
214
+ - A task runs in a fresh session each time; it does not continue the previous
215
+ run's context. Put the context in the prompt, or keep state in files in the
216
+ task's directory.
217
+ - Nothing fires while no pi process has the session loaded. Use the catch-up
218
+ option if that matters, or keep a small session open.
219
+
220
+ ## Development
221
+
222
+ ```bash
223
+ npm install
224
+ npm test # 43 tests: schedule math, repeat rules, store, runner, extension wiring
225
+ npm run typecheck
226
+ ```
227
+
228
+ `test/extension.test.mjs` drives the real command handlers with a fake pi API
229
+ and fake dialogs; `test/runner.test.mjs` runs a stand-in `pi` that speaks the
230
+ JSON event protocol.
231
+
232
+ ## License
233
+
234
+ MIT. Not affiliated with the pi or Pi Web maintainers.
@@ -0,0 +1,206 @@
1
+ # pi-scheduled-tasks
2
+
3
+ 为 [pi](https://github.com/earendil-works/pi) 和 [Pi Web](https://github.com/agegr/pi-web)
4
+ 提供定时任务:cron 表达式、固定间隔、一次性提醒,都在会话里用对话框管理。
5
+
6
+ 每次执行都是任务目录下一个普通的 `pi` 会话,所以在 Pi Web 侧栏里能看到它自己的
7
+ 对话、工具调用和花费;同一套任务在终端里也一样能用。
8
+
9
+ ```
10
+ /tasks
11
+ ```
12
+
13
+ ```
14
+ Scheduled tasks · 2 active · 2 total
15
+ a1b2 ● Morning inbox — cron 0 9 * * * · next in 3h
16
+ c3d4 ● Deploy check — every 30m · next in 12m
17
+ + New task
18
+ Close
19
+ ```
20
+
21
+ ## 为什么是扩展,而不是 Pi Web 新页面
22
+
23
+ Pi Web 刻意保持轻量。它的贡献指南把「定时调度」和「定时消息」明确列为不合并的
24
+ 范围,并指出这类需求应当用 pi 扩展解决:
25
+
26
+ - [CONTRIBUTING.md — 不合并的范围](https://github.com/agegr/pi-web/blob/main/CONTRIBUTING.md#out-of-scope)
27
+ - [Issue #666](https://github.com/agegr/pi-web/issues/666) — 维护者用 `/schedule`
28
+ 扩展作为答复关闭
29
+ - [PR #1409](https://github.com/agegr/pi-web/pull/1409) — 把调度器做进核心的 PR
30
+ 被拒绝:「a scheduler is outside what pi-web is meant to be […] A pi extension
31
+ gives the same thing to the CLI as well.」
32
+
33
+ 所以这是一个 pi 包,不修改 Pi Web。它只使用公开的扩展 API,以及 Pi Web 文档里的
34
+ [会话存活登记](https://github.com/agegr/pi-web/blob/main/docs/integrations.md#extension-session-liveness),
35
+ 在 CLI 和 Pi Web 中行为一致。
36
+
37
+ ## 相关项目
38
+
39
+ npm 上的 `pi-scheduled-tasks`(作者 errfld)也提供定时提示词:它在当前会话里执行,
40
+ 并额外提供模型可调用的工具。本项目的区别只有一点:每次执行都在任务目录下开一个独立
41
+ 会话,并且为浏览器做了管理器、状态栏和运行历史。如果你只是想在当前会话里加提醒,
42
+ 那个包可能就够了。
43
+
44
+ ## 安装
45
+
46
+ ```bash
47
+ pi install git:github.com/zhoubiao188/pi-scheduled-tasks
48
+ ```
49
+
50
+ 不安装、先试用:
51
+
52
+ ```bash
53
+ pi -e git:github.com/zhoubiao188/pi-scheduled-tasks
54
+ ```
55
+
56
+ 安装后重启 Pi Web,或在会话里执行 `/reload`。在 Pi Web 输入框里输入 `/` 就能补全
57
+ `/tasks`。
58
+
59
+ 要求 pi 0.84 及以上;状态栏按钮和 liveness 登记需要 Pi Web 0.9.0 及以上。更早的
60
+ Pi Web 也能用,但空闲会话可能被回收,要等重新打开会话才会继续调度。没有运行时依赖。
61
+
62
+ ## 使用
63
+
64
+ `/tasks` 打开管理器。选中任务后可以立即运行、编辑、暂停/恢复、查看历史、删除。
65
+
66
+ | 命令 | 作用 |
67
+ | --- | --- |
68
+ | `/tasks` | 打开管理器 |
69
+ | `/tasks add` | 新建任务(名称、提示词、计划、目录) |
70
+ | `/tasks list` | 打印所有任务和下次运行时间 |
71
+ | `/tasks runs` | 所有任务的运行记录时间线,选中可直接打开 |
72
+ | `/tasks run <id>` | 立即运行一次,不影响原计划 |
73
+ | `/tasks edit <id>` | 修改名称、提示词、计划或目录 |
74
+ | `/tasks pause <id>` / `resume <id>` | 暂停或恢复 |
75
+ | `/tasks runs <id>` | 最近运行记录,选中可直接打开对应会话 |
76
+ | `/tasks rm <id>` | 删除任务及其历史 |
77
+ | `/tasks show <id>` | 打印单个任务详情 |
78
+ | `/at 09:00 <提示词>` | 在当前目录快速建一个一次性任务 |
79
+
80
+ 创建/编辑时的对话框就是 Pi Web 自带的输入框、多行编辑器和选择框,手机上也能用。
81
+ Pi Web 顶部状态栏会出现 `⏰ 2 active · next in 12m` 按钮,点开就是 `/tasks`;输入框
82
+ 上方的小组件会列出最近的运行时间。
83
+
84
+ ### 创建任务
85
+
86
+ `/tasks add` 先选起点(空白,或四个模板:每日简报、每周周报、收件箱清理、CI 巡检),然后:
87
+
88
+ 1. **名称**和**提示词**;
89
+ 2. **重复**:每天、每周(可多选星期)、每月(可多选日期)、每年、每 N 分钟/小时、单次、自定义 cron;
90
+ 3. 规则的**时间**,例如 `09:00`;
91
+ 4. **工作目录**、**有效期**(可选)、**模型**(可选),以及错过运行时的处理方式。
92
+
93
+ 选模板会直接跳到计划那一步,并带上模板的默认时间。
94
+
95
+ 也可以直接对 agent 说「每个工作日 9 点总结一下 CI」——`scheduled_task` 工具会创建或列出任务。
96
+
97
+ ### 计划格式
98
+
99
+ | 形式 | 例子 | 含义 |
100
+ | --- | --- | --- |
101
+ | cron | `0 9 * * *` | 每天 09:00(本机时区) |
102
+ | cron | `*/15 * * * *` | 每 15 分钟 |
103
+ | cron | `0 9 * * mon-fri` | 工作日 09:00 |
104
+ | cron | `@daily`、`@hourly`、`@weekly`、`@monthly` | 宏 |
105
+ | 固定间隔 | `every 30m`、`1h30m`、`every 2d` | 最短 1 分钟 |
106
+ | 一次性 | `at 09:00`、`at 2026-11-26T09:00` | 运行一次后自动暂停 |
107
+
108
+ cron 支持列表、区间、步长、月份和星期名称;当「日」和「星期」都有限制时,按
109
+ 标准 cron 的「满足其一即可」处理。
110
+
111
+ ### 一次执行做了什么
112
+
113
+ 在任务目录下启动一个无界面的 pi:
114
+
115
+ ```
116
+ pi --mode json -p --name "⏰ Morning inbox" "<提示词>"
117
+ ```
118
+
119
+ 会话正常落盘,所以在 Pi Web 对应项目下能看到这次运行,**Runs** 里选中记录会直接
120
+ 打开它。历史里保留退出状态、耗时、结果摘要和会话文件路径(最多 20 条)。
121
+
122
+ ## 与 WorkBuddy 定时任务文档的对应关系
123
+
124
+ WorkBuddy 有一份定时任务文档;下面是本地 pi 客户端能对上的部分。
125
+
126
+ | WorkBuddy | 这里 |
127
+ | --- | --- |
128
+ | 名称、提示词、工作空间 | 一致:名称、提示词、工作目录 |
129
+ | 重复:间隔、单次、每天、每周、每月、每年 | 一致,另支持自定义 cron |
130
+ | 一条规则里多个星期或日期 | 一致(`mon,wed,fri`、`1,15`) |
131
+ | 时间与有效期 | 时间 + 可选结束日期 |
132
+ | 每个任务指定模型 | 支持(`--model`) |
133
+ | 立即运行、编辑、暂停、删除 | 一致 |
134
+ | 全部任务的运行记录 | `/tasks runs` |
135
+ | 任务运行页面(时间线、产物、进入会话) | 管理器里的 **Runs**,选中后打开那次运行的会话 |
136
+ | 一句话创建 | `scheduled_task` 工具 |
137
+ | 从模板创建 | 内置四个模板 |
138
+ | 云端任务(关机也执行) | 不支持,执行发生在本机 |
139
+ | 结果推送企业微信 | 不支持;每次运行都是一个会话,可用 Pi Web 自己的通知 |
140
+ | 完全访问/默认权限 | 不支持;运行沿用 pi 自身的配置与信任规则 |
141
+
142
+ 唯一缺的重复规则是「每双周」:五段 cron 表达不了。
143
+
144
+ ## 错过运行怎么办
145
+
146
+ 计时器依附在 pi 会话上。Pi Web 运行期间,负责调度的那个会话只要有启用中的任务,
147
+ 就不会被空闲回收(使用官方文档中的 liveness 登记),即使没有浏览器标签页打开。
148
+
149
+ Pi Web 重启后,直到重新打开某个会话才会继续调度。每个任务按自己的「补跑」设置处理:
150
+
151
+ - **跳过**(默认):这次记为 `missed`,绝不迟到发送,计划继续往后走。
152
+ - **补跑一次**:打开会话时补跑一次,然后回到正常计划,不会补跑多次。
153
+
154
+ 同一时间只有一个会话真正执行任务(锁文件),所以多个会话或多个 Pi Web 标签页不会
155
+ 重复触发;每个时间点的执行还有原子认领标记,跨进程重复也算空操作。
156
+
157
+ ## 安全与资源限制
158
+
159
+ - **不经过 shell**:提示词作为单个 argv 元素传入,`shell: false`,任务内容不会被
160
+ 任何 shell 解释。
161
+ - **不提权**:一次运行就是普通的 pi 会话,认证、扩展、工具权限、项目信任规则与手动
162
+ 运行一致。
163
+ - **有上限**:最多 50 个任务,提示词 20,000 字符,名称 120 字符,历史 20 条,同时只跑
164
+ 一个,单次超时 30 分钟(先 SIGTERM,再 SIGKILL)。
165
+ - **状态文件私有**:`~/.pi/agent/scheduled-tasks.json` 以 `0600` 原子写入,目录
166
+ `0700`。文件损坏时改名保留,绝不删除。
167
+ - **不递归**:任务启动的 pi 进程带有 `PI_SCHEDULED_TASK_CHILD=1`,扩展在其中自行
168
+ 禁用。
169
+ - **离线**:扩展本身不发起任何网络请求,不上报遥测。
170
+ - **不隐藏写入**:只写自己的状态、锁和认领文件,以及 pi 为每次运行写下的会话文件。
171
+
172
+ 任务以明文保存,方便阅读和备份。不要把密钥写进提示词,使用 pi 已有的 provider 配置。
173
+
174
+ ## 配置
175
+
176
+ | 变量 | 默认值 | 用途 |
177
+ | --- | --- | --- |
178
+ | `PI_SCHEDULED_TASKS_PI_BIN` | 与当前 Node 同目录的 `pi` | 执行任务用的可执行文件 |
179
+ | `PI_SCHEDULED_TASKS_TIMEOUT_MS` | `1800000` | 单次运行超时 |
180
+ | `PI_SCHEDULED_TASKS_DIR` | `~/.pi/agent` | 状态文件位置(测试或隔离环境) |
181
+
182
+ 找不到 `pi` 可执行文件时,`/tasks run` 仍然可用:提示词会投递到当前会话,而不是
183
+ 单独开一次运行。
184
+
185
+ ## 已知限制
186
+
187
+ - 时间按运行 pi 的机器本地时区计算;cron 使用 JavaScript `Date` 规则,夏令时切换
188
+ 当天 02:30 这类时间可能被跳过或重复。
189
+ - 每次执行都是全新会话,不延续上一次的上下文。需要上下文就写进提示词,或把状态放在
190
+ 任务目录的文件里。
191
+ - 没有任何 pi 进程加载会话时不会触发。介意的话打开「补跑」,或保持一个小会话常开。
192
+
193
+ ## 开发
194
+
195
+ ```bash
196
+ npm install
197
+ npm test # 43 个测试:计划计算、重复规则、状态存储、执行器、扩展接线
198
+ npm run typecheck
199
+ ```
200
+
201
+ `test/extension.test.mjs` 用假的 pi API 和假对话框直接驱动真实命令处理函数;
202
+ `test/runner.test.mjs` 用一个会讲 JSON 事件协议的假 `pi` 验证执行路径。
203
+
204
+ ## 许可
205
+
206
+ MIT。与 pi、Pi Web 维护者无隶属关系。