# Reward Engine

> >

- **Type:** Skill
- **Install:** `agentstack add skill-nanorhino-weight-loss-skill-reward-engine`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [NanoRhino](https://agentstack.voostack.com/s/nanorhino)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [NanoRhino](https://github.com/NanoRhino)
- **Source:** https://github.com/NanoRhino/weight-loss-skill/tree/main/reward-engine
- **Website:** https://nanorhino.com/

## Install

```sh
agentstack add skill-nanorhino-weight-loss-skill-reward-engine
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Reward Engine — Calorie Target Badge

> ⚠️ **SILENT OPERATION:** Never narrate internal actions or tool calls.

## Philosophy

1. **Celebrate accumulation, never punish gaps.** Count goes up only — never down.
2. **Reward the behavior (eating on target), not the outcome (weight loss).**
3. **One celebration per level-up, then move on.** Don't revisit past badges.
4. **Personalize the image.** User name + their data on the badge.

## Qualification Rules

A day counts as "qualified" when ALL THREE conditions are met:

1. **Complete meals logged:** Number of main meals (breakfast/lunch/dinner) logged today ≥ expected meal count
   - Default: 3 meals
   - Intermittent fasting (16:8 or explicit "两餐" in PLAN.md): 2 meals
   - `snack` does NOT count as a main meal
2. **Calories in target range:** Total daily calories within the `Daily Calorie Range` from PLAN.md (e.g., 1,430 - 1,630)
   - Falls back to target ± 10% if only a single target value exists
3. **Above safety floor:** Total daily calories ≥ BMR × 0.8
   - Prevents rewarding dangerous under-eating

## Script

```bash
python3 {baseDir}/scripts/badge-calc.py check \
  --workspace-dir {workspaceDir} \
  --tz-offset {tz_offset}
```

### Output

```json
{
  "qualified_today": true,
  "already_counted": false,
  "current_count": 14,
  "current_level": 3,
  "level_up": true,
  "new_badge": {
    "level": 3,
    "name": "⭐⭐⭐ 自由支配者",
    "message": "两周的精准分配。你不是在\"控制饮食\"，你是真的会吃了。",
    "milk_tea_cups": 28,
    "progress_bar": "━━━━━━━━━━░░░░ 14/21 → 下一级：稳定输出选手"
  },
  "badge_image": "{workspaceDir}/data/badges/badge_level_3.png"
}
```

- `qualified_today`: whether today meets all 3 conditions
- `already_counted`: true if today was already counted (prevents double-counting)
- `level_up`: true only when a NEW level is reached this check
- `new_badge`: null if no level-up
- `badge_image`: path to generated badge image (null if no level-up)

## Level Definitions

| Level | Days | Name | Message |
|-------|------|------|---------|
| 1 | 3 | ⭐ 稳稳吃饭的人 | 有3天热量刚好落在目标区间。这不是运气——是你对"一顿饭多少热量"有感觉了。 |
| 2 | 7 | ⭐⭐ 热量掌控达人 | 7天达标。你已经知道什么时候该多吃、什么时候该收着。这种判断力比任何食谱都管用。 |
| 3 | 14 | ⭐⭐⭐ 自由支配者 | 两周的精准分配。你不是在"控制饮食"，你是真的会吃了。 |
| 4 | 21 | ⭐⭐⭐⭐ 稳定输出选手 | 三周的节奏，已经不是"在坚持"了，是你的正常状态。 |
| 5 | 30 | ⭐⭐⭐⭐⭐ 精准生活家 | 一个月。你对热量的直觉已经内化了——不看数字也不会差太远。 |
| 6 | 45 | ⭐×6 持续进化者 | 45天。一个半月的稳定输出，这不是阶段性的表现，是你的新常态。 |
| 7 | 60 | ⭐×7 长期主义玩家 | 60天。不需要鸡汤，数据说明一切。 |
| 8 | 90 | ⭐×8 不可撼动 | 90天。多数人的计划活不过两周，你走完了全程。这不是关于减肥了，这是你证明了自己能长期做好一件事。 |

## Badge Image Generation

When `level_up == true`, generate a personalized badge image:

- **Template:** from `{baseDir}/assets/` (operator provides base template)
- **Dynamic text overlay:**
  - User's name (from USER.md)
  - Badge level + name
  - Cumulative days count
  - Milk tea cups equivalent
  - Progress bar to next level
- **Output:** saved to `{workspaceDir}/data/badges/badge_level_{N}.png`
- **Format:** PNG, dimensions TBD (pending operator's style reference)

> ⚠️ Image template assets pending — operator will provide reference design.
> Until then, badge_image will be null and celebration is text-only.

## Data Storage

File: `{workspaceDir}/data/badges.json`

```json
{
  "calorie_target": {
    "current_level": 3,
    "current_count": 14,
    "next_level_target": 21,
    "qualified_dates": ["2026-05-01", "2026-05-03", "2026-05-04"],
    "unlocked_at": {
      "1": "2026-04-15",
      "2": "2026-04-28",
      "3": "2026-05-10"
    },
    "daily_deficit": 385,
    "last_calculated": "2026-05-19"
  }
}
```

## Integration Point

Called by `diet-tracking-analysis` after `meal_checkin` returns with `action: "create"` or `action: "append"`:

```
# After composing the normal meal reply (①②③):
1. Run badge-calc.py check
2. If level_up == true AND badge_image exists:
   → Append badge celebration text after normal reply
   → Send badge image via MEDIA: directive
3. If level_up == true AND badge_image is null/empty:
   → Say nothing (silent skip — do NOT fall back to text)
4. If qualified_today == true but no level_up:
   → Say nothing (silent accumulation)
5. If qualified_today == false:
   → Say nothing about badges
```

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [NanoRhino](https://github.com/NanoRhino)
- **Source:** [NanoRhino/weight-loss-skill](https://github.com/NanoRhino/weight-loss-skill)
- **License:** MIT
- **Homepage:** https://nanorhino.com/

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-nanorhino-weight-loss-skill-reward-engine
- Seller: https://agentstack.voostack.com/s/nanorhino
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
