> [中文](README.md) ｜ [English](README.en.md)

# dsh-clock — The Money-Saving Clock ⏰

> My owner made me write this clock to **save money**: it reminds him not to
> burn tokens during **peak hours** (when API usage costs the most). When the
> red lamp starts **blinking**, it means: stop now, you are paying premium 💸

A floating clock plugin for the [DeepSeek Harness](https://github.com/deepseek-ai/dsh)
Web GUI. **Draggable, resizable**, remembers its position; during peak hours
(**Beijing time 9:00–12:00 & 14:00–18:00**) it shows a blinking red warning
lamp. Color and blinking are fully configurable.

> [中文说明 (Chinese)](README.zh.md)

## ✨ Features

- 🕐 Floating live clock (HH:MM:SS + date + weekday), updates every second
- 🖱️ Drag the clock body to move; drag the bottom-right corner handle to scale (0.5×–3×)
- 💾 Position & scale are remembered (browser localStorage)
- 🔴 Red lamp during peak hours (Beijing 9:00-12:00 & 14:00-18:00), blinking by default
- 🎨 Settings: `enabled` master switch / `color` (any CSS color token) / `blinkPeak` blink toggle

## 📦 Install

### Option 1: npm quick install (recommended)

```sh
dsh plugin --profile web add dsh-clock
```

Then **restart `dsh web`** and refresh the page — the clock appears.

### Option 2: manual install

1. Clone this repo (or unpack the npm tarball);
2. Edit the web profile `package.json` (`~/.dsh/profiles/web/package.json`):

```jsonc
// add to dependencies
"dsh-clock": "^0.1.0"
// append to dsh.profile.bundles
"dsh-clock"
```

3. Run `pnpm install` in the profile directory, then restart `dsh web`.

### Option 3: install from a local directory (development)

```sh
dsh plugin --profile web add /path/to/dsh-clock
```

> ⚠️ When installing from a local directory outside the profile, create
> `node_modules` links to the host packages (`@deepseek-ai` and `schemastery`)
> inside the plugin directory. The npm release does not need this.

## ⚙️ Settings

GUI Settings → Plugin config → dsh-clock:

- **Show clock**: master switch
- **Time color**: any CSS color token (`#9aa0a6` / `red` / `rgb(255,0,0)`)
- **Blink red lamp during peak hours**: off = steady lamp, on = blinking

## ⏰ Peak-hour rules

Judged in **Beijing time (UTC+8)**, independent of the browser timezone:

- Morning 9:00 – 12:00 (12:00 exclusive)
- Afternoon 14:00 – 18:00 (18:00 exclusive)

A red dot appears next to the time during peak hours; with `blinkPeak` on it
blinks with a 1s cycle.

## 🗂️ Structure

| File | Purpose |
|---|---|
| `cordis.patch.yml` | bundle patch: inserts the plugin row into the web profile roster |
| `lib/index.js` | host side: registers the `dsh-clock` settings namespace |
| `lib/client.js` | browser side: floating clock + drag/scale + persistence + settings card |

## 🔧 Development

The client bundle is hand-written in the `window.__ModuleLoader__.load(...)`
format (same as the dsh-web-ui plugin family) — no build step required; edit
`lib/client.js` and refresh the page (dev) or restart `dsh web` (prod).

## 📤 Publishing

```sh
npm publish            # npm
git push origin main   # GitHub
```

## 📄 License

MIT
