refactor(skills): store runtime data in skill-local data/ directory

Move skill config and cached data from ~/.picoclaw/<skill>/ to
skills/<skill>/data/ within the workspace. This keeps each skill's
data co-located with its source and makes the workspace self-contained.

Changes:
- prayer_notify.sh: resolve DATA_DIR to SKILL_DIR/data via SCRIPT_DIR
- prayer-times/SKILL.md: update config path references
- reminder/SKILL.md: update ntfy.conf path references
- .gitignore: add skills/*/data/ pattern
This commit is contained in:
muava12 2026-02-24 11:29:24 +08:00
parent 09fa0a1b88
commit f208f90f6d
4 changed files with 15 additions and 12 deletions

1
.gitignore vendored
View file

@ -16,6 +16,7 @@ cmd/picoclaw/workspace
# PicoClaw
.picoclaw/
skills/*/data/
config.json
sessions/
build/

View file

@ -49,12 +49,12 @@ Saat user **pertama kali** minta reminder sholat:
```bash
bash skills/prayer-times/scripts/prayer_notify.sh setup samarinda
```
Ini akan save config ke `~/.picoclaw/prayer-times/config` dan fetch data bulan ini.
Ini akan save config ke `skills/prayer-times/data/config` dan fetch data bulan ini.
### 3. Setup ntfy (opsional, via exec tool)
Jika user memberikan ntfy URL, tambahkan ke config:
```bash
sed -i 's|NTFY_TOPIC=".*"|NTFY_TOPIC="https://ntfy.sh/USER_TOPIC"|' ~/.picoclaw/prayer-times/config
sed -i 's|NTFY_TOPIC=".*"|NTFY_TOPIC="https://ntfy.sh/USER_TOPIC"|' skills/prayer-times/data/config
```
Simpan juga ke MEMORY.md agar tidak lupa.
@ -75,7 +75,7 @@ Simpan juga ke MEMORY.md agar tidak lupa.
## Config File
Disimpan di `~/.picoclaw/prayer-times/config` — **milik skill ini sendiri, tidak shared**:
Disimpan di `skills/prayer-times/data/config` — **milik skill ini sendiri, tidak shared**:
```
CITY="samarinda"
SAHUR_MINS="30"

View file

@ -8,16 +8,18 @@
# prayer_notify.sh setup <city> — Set city and fetch initial data
# prayer_notify.sh status — Show current config and data status
#
# Config file: ~/.picoclaw/prayer-times/config
# Config file: skills/prayer-times/data/config (co-located with skill)
# Auto-fetch: schedule command auto-fetches if data is missing or stale
set -euo pipefail
DATA_DIR="${PRAYER_DATA_DIR:-$HOME/.picoclaw/prayer-times}"
# Resolve paths relative to this script's location
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SKILL_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
DATA_DIR="${PRAYER_DATA_DIR:-$SKILL_DIR/data}"
CONFIG_FILE="$DATA_DIR/config"
# Locate shared ntfy_send.sh relative to this script
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
NTFY_SEND="${SCRIPT_DIR}/../../shared/scripts/ntfy_send.sh"
mkdir -p "$DATA_DIR"

View file

@ -154,12 +154,12 @@ Execute a shell command instead of sending a message. Output is sent to chat. Se
Saat user pertama kali minta reminder dengan ntfy, pastikan ntfy topic dikonfigurasi.
Config disimpan di `~/.picoclaw/reminder/ntfy.conf` — **milik skill ini sendiri, tidak shared**.
Config disimpan di `skills/reminder/data/ntfy.conf` — **milik skill ini sendiri, tidak shared**.
### 1. Tanya ntfy topic URL ke user
### 2. Simpan ke config (via exec tool)
```bash
mkdir -p ~/.picoclaw/reminder && echo 'NTFY_TOPIC="https://ntfy.sh/USER_TOPIC"' > ~/.picoclaw/reminder/ntfy.conf
mkdir -p skills/reminder/data && echo 'NTFY_TOPIC="https://ntfy.sh/USER_TOPIC"' > skills/reminder/data/ntfy.conf
```
### 3. Simpan juga ke MEMORY.md agar tidak lupa
@ -171,7 +171,7 @@ Gunakan shared helper script. **WAJIB source config sendiri sebelum panggil ntfy
```bash
# Semua perintah ntfy harus diawali source config
source ~/.picoclaw/reminder/ntfy.conf 2>/dev/null; NTFY_TOPIC="$NTFY_TOPIC" bash skills/shared/scripts/ntfy_send.sh "MESSAGE" --title "JUDUL" --tags alarm_clock
source skills/reminder/data/ntfy.conf 2>/dev/null; NTFY_TOPIC="$NTFY_TOPIC" bash skills/shared/scripts/ntfy_send.sh "MESSAGE" --title "JUDUL" --tags alarm_clock
```
> **JANGAN pakai curl langsung** ke ntfy. Selalu gunakan `ntfy_send.sh` agar URL dibaca dari config.
@ -186,7 +186,7 @@ source ~/.picoclaw/reminder/ntfy.conf 2>/dev/null; NTFY_TOPIC="$NTFY_TOPIC" bash
```
**Job 2 — ntfy push:**
```json
{"action": "add", "message": "ntfy: meeting", "command": "source ~/.picoclaw/reminder/ntfy.conf 2>/dev/null; NTFY_TOPIC=\"$NTFY_TOPIC\" bash skills/shared/scripts/ntfy_send.sh 'Meeting dengan tim marketing!' --title Reminder --tags alarm_clock", "at_seconds": 600}
{"action": "add", "message": "ntfy: meeting", "command": "source skills/reminder/data/ntfy.conf 2>/dev/null; NTFY_TOPIC=\"$NTFY_TOPIC\" bash skills/shared/scripts/ntfy_send.sh 'Meeting dengan tim marketing!' --title Reminder --tags alarm_clock", "at_seconds": 600}
```
### Recurring reminder (2 jobs)
@ -197,7 +197,7 @@ source ~/.picoclaw/reminder/ntfy.conf 2>/dev/null; NTFY_TOPIC="$NTFY_TOPIC" bash
```
**Job 2 — ntfy push:**
```json
{"action": "add", "message": "ntfy: minum air", "command": "source ~/.picoclaw/reminder/ntfy.conf 2>/dev/null; NTFY_TOPIC=\"$NTFY_TOPIC\" bash skills/shared/scripts/ntfy_send.sh 'Jangan lupa minum air!' --title Hydration --tags droplet", "every_seconds": 3600}
{"action": "add", "message": "ntfy: minum air", "command": "source skills/reminder/data/ntfy.conf 2>/dev/null; NTFY_TOPIC=\"$NTFY_TOPIC\" bash skills/shared/scripts/ntfy_send.sh 'Jangan lupa minum air!' --title Hydration --tags droplet", "every_seconds": 3600}
```
### Daily cron reminder (2 jobs)
@ -208,7 +208,7 @@ source ~/.picoclaw/reminder/ntfy.conf 2>/dev/null; NTFY_TOPIC="$NTFY_TOPIC" bash
```
**Job 2 — ntfy push:**
```json
{"action": "add", "message": "ntfy: daily review", "command": "source ~/.picoclaw/reminder/ntfy.conf 2>/dev/null; NTFY_TOPIC=\"$NTFY_TOPIC\" bash skills/shared/scripts/ntfy_send.sh 'Saatnya review laporan harian' --title 'Daily Review' --tags memo", "cron_expr": "0 17 * * 1-5"}
{"action": "add", "message": "ntfy: daily review", "command": "source skills/reminder/data/ntfy.conf 2>/dev/null; NTFY_TOPIC=\"$NTFY_TOPIC\" bash skills/shared/scripts/ntfy_send.sh 'Saatnya review laporan harian' --title 'Daily Review' --tags memo", "cron_expr": "0 17 * * 1-5"}
```
### Daily report via agent (1 job only, no ntfy)