Skip to main content
ClaudeWave
Skill1.3k estrellas del repoactualizado today

ha-data-stores

Map of Hope Agent's local data stores and safe read-only query workflow. Use when the user asks where Hope Agent stores data, wants to inspect sessions/messages/memory/logs/background jobs/knowledge indexes/settings, asks the model to query local app data, or debugging requires checking persisted state. Trigger phrases: data stores, database path, sessions.db, memory.db, logs.db, background_jobs.db, knowledge index, where is data stored, query app data, 查数据库, 数据存储, 会话记录在哪, 记忆库在哪.

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/shiwenwen/hope-agent /tmp/ha-data-stores && cp -r /tmp/ha-data-stores/skills/ha-data-stores ~/.claude/skills/ha-data-stores
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

SKILL.md

# Hope Agent Data Stores

Use this skill when you need to locate or inspect Hope Agent's persisted local
data. Prefer product tools first; use direct SQLite only for diagnostics or
ad-hoc analysis that existing tools do not cover.

## Priority order

1. Use dedicated model tools when they answer the question:
   - `sessions_search` for finding exact details in current or historical chat
     messages.
   - `sessions_history` for paginated transcript reading once a session is
     known.
   - `recall_memory` / `memory_get` for user/project/agent memory.
   - `note_*` / `knowledge_recall` for attached knowledge spaces.
   - `get_settings` for AppConfig settings.
   - `job_status` for background job state visible to the current session.
2. Use read-only SQLite queries only when a dedicated tool is missing, too
   coarse, or the task is diagnostic/audit work.
3. Never mutate app databases directly. Do not run `UPDATE`, `DELETE`,
   `INSERT`, `DROP`, `CREATE`, `ALTER`, `VACUUM`, `REINDEX`, or `ATTACH`.

## Data root

All app-managed data lives under the Hope Agent data root:

- If `HA_DATA_DIR` is set: use it exactly.
- Otherwise: `~/.hope-agent`.

Shell helper:

```bash
ROOT="${HA_DATA_DIR:-$HOME/.hope-agent}"
```

Use this helper instead of hard-coding `~/.hope-agent` when running queries.

## SQLite read-only patterns

Use the sqlite CLI with `-readonly`:

```bash
ROOT="${HA_DATA_DIR:-$HOME/.hope-agent}"
sqlite3 -readonly -cmd ".headers on" -cmd ".mode column" "$ROOT/sessions.db" \
  "SELECT id, title, agent_id, updated_at FROM sessions ORDER BY updated_at DESC LIMIT 10;"
```

Python fallback:

```bash
python3 - <<'PY'
import os, sqlite3
root = os.environ.get("HA_DATA_DIR") or os.path.expanduser("~/.hope-agent")
path = os.path.join(root, "sessions.db")
con = sqlite3.connect(f"file:{path}?mode=ro", uri=True)
for row in con.execute("SELECT id, title, updated_at FROM sessions ORDER BY updated_at DESC LIMIT 10"):
    print(row)
PY
```

## Main stores

| Store | Path | Purpose |
|---|---|---|
| Sessions | `$ROOT/sessions.db` | Sessions, messages, chat context snapshots, projects, knowledge registry/bindings, channel mappings, subagent runs, tasks, learning events |
| Memory | `$ROOT/memory.db` | Long-term memories, memory FTS/vector data, Dreaming claims/evidence/profile data |
| Logs | `$ROOT/logs.db` | Structured app logs emitted by `app_info!` / `app_warn!` / `app_error!` / `app_debug!` |
| Background jobs | `$ROOT/background_jobs.db` | Unified background job cache for async tools and subagent/group projections |
| Cron | `$ROOT/cron.db` | Scheduled tasks managed by `manage_cron` |
| Wakeups | `$ROOT/wakeups.db` | Agent self-scheduled wakeups from `schedule_wakeup` |
| Recap | `$ROOT/recap/recap.db` | Cached recap/report facets and summaries |
| Knowledge index | `$ROOT/knowledge/index.db` | Rebuildable note/chunk/link/tag search cache; real notes are Markdown files |
| Canvas | `$ROOT/canvas/canvas.db` | Canvas projects and versions |
| Local model jobs | `$ROOT/local_model_jobs.db` | Ollama/local-model install, pull, preload jobs |
| Local LLM cache | `$ROOT/local_llm_library_cache.db` | Cached Ollama Library search/tag metadata |

`async_jobs.db` is legacy. Current code uses `background_jobs.db`; an old
`async_jobs.db` file may be leftover cache and should not be treated as current
truth.

## Important non-DB paths

| Path | Purpose |
|---|---|
| `$ROOT/config.json` | AppConfig: settings, providers metadata, feature toggles |
| `$ROOT/user.json` | User profile and UI preferences |
| `$ROOT/agents/` | Agent definitions and agent prompt files |
| `$ROOT/{agent_id}-home/` | Per-agent scratch/home directory |
| `$ROOT/home/` | Shared directory across agents |
| `$ROOT/attachments/{session_id}/` | Persisted chat attachments |
| `$ROOT/sessions/{session_id}/transcript.jsonl` | Hook transcript mirror |
| `$ROOT/tool_results/{session_id}/` | Large tool-result spill files |
| `$ROOT/background_jobs/` | Background job result spool |
| `$ROOT/knowledge/{kb_id}/notes/` | Internal knowledge-base Markdown files |
| `$ROOT/credentials/` | OAuth/API credentials. Do not read unless the user explicitly asks and it is necessary. Never print secrets. |

## Query guide

### Session messages

Prefer `sessions_search` first. For raw SQL:

```sql
SELECT id, session_id, role, timestamp, substr(content, 1, 500) AS content
  FROM messages
 WHERE session_id = ?
 ORDER BY id ASC
 LIMIT 100;
```

Use `messages_fts` for keyword search over user/assistant content:

```sql
SELECT m.id, m.session_id, m.role, m.timestamp,
       snippet(messages_fts, 0, '[', ']', '...', 16) AS snippet
  FROM messages_fts
  JOIN messages m ON m.id = messages_fts.rowid
 WHERE messages_fts MATCH ?
 ORDER BY rank
 LIMIT 20;
```

Global searches must exclude private/non-user surfaces unless the task
explicitly targets them:

```sql
... JOIN sessions s ON s.id = m.session_id
WHERE s.incognito = 0 AND s.kind != 'knowledge'
```

### Logs

```sql
SELECT timestamp, level, category, source, message
  FROM logs
 WHERE level IN ('ERROR', 'WARN')
 ORDER BY timestamp DESC
 LIMIT 50;
```

### Background jobs

```sql
SELECT job_id, kind, session_id, status, tool_name, created_at, completed_at, error
  FROM background_jobs
 ORDER BY created_at DESC
 LIMIT 50;
```

### Memory

Prefer `recall_memory` and `memory_get`. Use SQL only for diagnostics:

```sql
SELECT id, memory_type, scope, scope_agent_id, scope_project_id,
       pinned, created_at, substr(content, 1, 500) AS content
  FROM memories
 ORDER BY updated_at DESC
 LIMIT 50;
```

### Knowledge spaces

Registry and access bindings live in `sessions.db`; the index cache lives in
`knowledge/index.db`. Internal note bodies are Markdown files and are the source
of truth. Do not edit `index.db`; rebuild it through product flows.

Useful registry tables include `knowledge_bases`, `session_knowledge_bases`,
`project_knowledge_bases`, `knowledge_chat_threads`, and
`kb_maintenance_proposals`.

## Safety notes
code-reviewSkill

>

email-draftSkill

Use when the user asks to draft, polish, translate, or reply to an email. Produces a clean draft with subject line, greeting, body, and sign-off, plus a pre-send self-check.

feishuSkill

Use when the user mentions 飞书 / Feishu / Lark workspace operations: docx (云文档) read/write, bitable (多维表格) records / views / dashboards, drive (云盘) upload/download, wiki (知识库) link resolution, approval (审批) instance create/cancel/query, calendar (日历) event create/list/update + attendees, contact (联系人) user/department lookup, hire (招聘) job/talent/application listing. Trigger on phrases like 'OKR 周报', '把这份文档发到飞书云盘', '给团队拉个评审会议', '查 [姓名] 的联系方式', '撤销那条审批', '/wiki 链接', or any request that mentions a feishu / lark URL / token (doxcn.../bascn.../wikcn.../boxcn.../om_...).

ha-browserSkill

Hope Agent browser automation — the standard `status → tabs → snapshot → act` loop, stale-ref recovery rules, and what to do when login / 2FA / captcha / camera-prompt / dialog blocks progress. Load this skill whenever you reach for the `browser` tool. Trigger on: user asks the agent to open / control / click / scrape / log into / verify something in a web app ('open X and click Y', '打开 X 然后点击 Y', 'log into my Gmail', 'scrape this page', 'fill out the form on X'); user reports a flow that requires real browser context (cookies, JS-rendered content, OAuth).

ha-find-skillsSkill

Discover and install third-party skills from external registries when the user needs a capability that no currently-active skill covers. Trigger when: (1) the user explicitly asks 'find a skill for X', 'is there a skill that does X', 'install a skill to X', (2) the user requests a well-known integration (Slack, Notion, Trello, GitHub, Hue, Sonos, iMessage, weather, TTS, transcription …) that isn't in the active skill catalog, (3) you are about to hand-write ad-hoc shell / API code for a domain that almost certainly has a published skill. Do NOT trigger if an active skill already covers the need — scan the visible skill catalog first.

ha-logsSkill

Self-service diagnostics — query Hope Agent's local SQLite databases (logs / sessions / background jobs) directly via the `exec` tool to investigate problems, analyze usage, and locate root causes. Trigger on: user reports something broken / failing / slow / stuck / not responding ('X 不工作', 'X 报错', 'X 卡住', '为什么 X 失败', 'why did X fail', 'show me the logs', 'check what happened'); ad-hoc data analysis ('this week's token usage', '最近调用最多的工具', 'how many subagent runs failed', 'tool error rate', 'find sessions where X happened'); verifying a fix ('did the error stop after I changed Y'). Use BEFORE asking the user to paste log snippets — the data is on disk, query it directly. Read-only — SELECT only, never UPDATE/DELETE/INSERT/DROP.

ha-mac-controlSkill

Hope Agent native macOS desktop control — the standard `mac_control` status / diagnostics / apps / dock / spaces / snapshot / visual / windows / menu / clipboard / dialog loop, target-first action rules, no-blind-coordinate policy, and recovery for stale AX/window/menu/dialog state. Load whenever using `mac_control`, or when the user asks to control local Mac apps, Dock, Spaces, click/type/menu/window/dialog/clipboard, automate Finder/TextEdit/System Settings, visually locate UI, or says 控制 Mac, macOS 自动化, 点按钮, 打开应用, Dock, Space, 关闭窗口, 菜单点击, 视觉定位.

ha-self-diagnosisSkill

Self-understanding and issue reporting for Hope Agent itself. Use when the user asks how Hope Agent works internally, asks about its own source code/docs/runtime behavior, reports a bug/failure/slowness/crash, asks to diagnose logs, or asks to create/submit a GitHub issue for a bug, feature request, or improvement (including when there is no bug). Chinese triggers: 自查, 了解自己, 自我诊断, 排查 Hope Agent, 提交 issue, 需求 issue, 功能改进.