# pi-schedule-status

A lightweight status bar extension for Pi durable schedules.

## Features

- Shows schedules owned by the current Pi session and project-shared schedules.
- Hides session-only schedules owned by other sessions.
- Uses `schedule.json` as the source of truth and does not create or depend on `owner.json`.
- Displays scheduled, running, paused, and overdue states.
- Shows seconds for schedules within one hour and reports overdue duration.
- Automatically applies Pi theme colors to scope icons and state labels.
- Uses Chinese labels `已启用` and `已暂停` in Chinese locales instead of ambiguous `ON` and `OFF`.
- Supports automatic locale detection with an explicit locale override.
- Has no network, database, or third-party runtime dependency.

## Install

After publication:

```bash
pi install npm:pi-schedule-status
```

From a local checkout:

```bash
pi install ./path/to/pi-schedule-status
```

Reload Pi after installation:

```text
/reload
```

## Status bar examples

Single current-session schedule:

```text
⏱ ◉ Schedule watcher · ON · every 30m · next 10:18:58
```

Running schedule:

```text
⠋ ◉ Schedule watcher · running 00:12 · planned 10:18:58
```

Project-shared schedule:

```text
⏱ ◇ Daily report · ON · every 1h · next 10:22:03
```

Overdue schedule:

```text
⚠ ◉ Schedule watcher · overdue 00:18:25 · planned 10:18:58
```

Multiple schedules:

```text
⏱ 3 tasks · ◉ 1 · ◇ 2 · next 10:22:03
```

## Icons

The state label and scope icon use the active Pi theme: enabled uses the success color, running uses the accent color, and paused or overdue uses the warning color.

| Icon | Meaning |
| --- | --- |
| `◉` | Session-only schedule owned by the current Pi session |
| `◇` | Project-shared schedule |
| `⏱` | Scheduled or active schedule summary |
| `⠋⠙⠹...` | Running spinner frames |
| `⏸` | Paused schedule |
| `⚠` | Schedule is past its planned time |

Session-only schedules owned by another Pi session are hidden rather than shown as an “other session” entry.

## Locale

The extension detects the system locale through `Intl.DateTimeFormat`. Chinese locales use Chinese labels; other locales use English labels. Task names are user data and are always displayed unchanged.

Override the locale before starting or reloading Pi:

```text
PI_SCHEDULE_STATUS_LOCALE=auto
PI_SCHEDULE_STATUS_LOCALE=zh-CN
PI_SCHEDULE_STATUS_LOCALE=en-US
```

## Schedule compatibility

The extension reads durable schedules from the Pi project configuration directory:

```text
<project>/<Pi config directory>/subagents/schedules/<id>/schedule.json
```

For `pi-subagents >= 0.62.0`:

- `sessionOnly: true` plus a matching `ownerSessionFile` is shown with `◉`.
- `sessionOnly: true` plus a different owner is hidden.
- Omitted or `false` `sessionOnly` is shown with `◇` as a project-shared schedule.

Legacy schedules without `sessionOnly` remain visible as project-shared schedules. The extension never changes schedule files and never writes `owner.json`.

## Design notes

The status bar is read-only. Schedule execution remains the responsibility of `pi-subagents`.

File watchers refresh schedule data after changes. A small in-memory clock tick updates second-level time displays, and a separate short spinner tick runs only while a schedule is active. Completed one-shot schedules disappear after their `nextRunAt` is removed, while overdue schedules remain visible as overdue until the scheduler updates them.

## License

MIT

---

# 中文说明

这是一个用于 Pi 持久化 Schedule 的轻量状态栏扩展。

## 功能

- 显示当前 Pi 会话拥有的 session-only 任务和项目共享任务。
- 隐藏其他会话拥有的 session-only 任务。
- 以 `schedule.json` 为唯一数据来源, 不创建也不依赖 `owner.json`。
- 显示待执行、执行中、已暂停和已到期状态。
- 距离执行时间小于 1 小时时显示到秒, 并展示过期时长。
- 执行中使用轻量动态 spinner。
- 中文环境使用“已启用”和“已暂停”等直观状态文字, 不使用 `ON` 和 `OFF`。
- 状态标签和作用域图标使用当前 Pi 主题颜色。
- 自动识别语言, 支持手动覆盖语言。
- 不需要网络、数据库或第三方运行时依赖。

## 状态栏图标

| 图标 | 含义 |
| --- | --- |
| `◉` | 当前 Pi 会话拥有的 session-only 任务 |
| `◇` | 项目共享任务 |
| `⏱` | 等待执行或多任务汇总 |
| `⠋⠙⠹...` | 执行中的动态 spinner |
| `⏸` | 已暂停 |
| `⚠` | 已超过计划执行时间 |

任务名称由创建者决定, 插件不会翻译或修改任务名称。

中文状态文字:

- `已启用`: 任务已启用并等待下一次执行。
- `执行中`: 任务正在执行。
- `已暂停`: 任务已暂停。
- `已到期`: 已超过计划执行时间。

状态标签和作用域图标使用当前 Pi 主题颜色: 已启用使用成功色, 执行中使用强调色, 已暂停和已到期使用警告色。

## 说明

状态栏只负责读取和展示, Schedule 的实际执行仍由 `pi-subagents` 负责。

插件不会修改 Schedule 文件, 不维护 `owner.json`, 也不会执行外部业务操作。
