Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/respire/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions external_plugins/respire/.zcode-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "respire",
"version": "0.1.0",
"description": "respire memory for ZCode: every-round title-tier recall, one-prefix store, model-optional degradation. Register on rsrs.rs for sync; the sidecar model is an optional boost.",
"description_i18n": {
"en": "respire local encrypted memory: every-round title-tier recall, one-prefix store, Stop storage check. Fully usable without the sidecar model.",
"zh-CN": "respire 本地加密记忆:每轮标题档自动召回、一句「记:」落库、Stop 存储检查,不装模型也完全可用。"
},
"author": {
"name": "risense-ai",
"url": "https://github.com/risense-ai"
},
"homepage": "https://github.com/risense-ai/respire-zcode",
"repository": "https://github.com/risense-ai/respire-zcode",
"license": "MIT",
"keywords": [
"memory",
"respire",
"rsrs",
"recall",
"hooks",
"local-first"
],
"skills": "./skills",
"hooks": "./hooks/hooks.json"
}
15 changes: 15 additions & 0 deletions external_plugins/respire/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).

## [0.1.0] - 2026-10-23

### Added

- 首版:respire(rsrs)记忆层接入 ZCode——SessionStart 简则注入、UserPromptSubmit 每轮标题档召回、「记:」一前缀落库回执、Stop 存储检查(block 续跑一轮)。
- ZCode 协议适配(对照 respire-qoder 0.6.3 骨架):
- 输出走严格 JSON:文本 → `{"additionalContext":…}`(ZCode 忽略纯文本 stdout,已核 runtime 源码);
- Stop 阻塞用 `{"decision":"block","reason":…}`(ZCode 枚举 approve|block,不收 `deny`);
- 数据目录探测 `RESPITE_DATA` → `ZCODE_PLUGIN_DATA` → 脚本目录;hooks.json 仅 ZCode schema 收录字段,不带 `commandWindows`。
- `scripts/validate_plugin.py`(结构/清单/hooks/输出契约/敏感扫描)、`scripts/package.sh`+`release.yml`(tag→release,与 dimcode 同口径)、`tests/test_hooks.sh`(stdin 模拟断言+`--store` 写探针自清理)。
21 changes: 21 additions & 0 deletions external_plugins/respire/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 fslong

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
76 changes: 76 additions & 0 deletions external_plugins/respire/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# respire

> Store on inhale, recall on exhale — local encrypted memory for ZCode.

`respire` (CLI: `rsrs`) is a standard ZCode plugin that wires the respire memory engine into the agent loop with command hooks: title-tier recall injected every turn, one-prefix storing, and a Stop storage check. Local-first, end-side encrypted, cloud LWW sync.

Sibling builds for other hosts: [respire-dimcode](https://github.com/risense-ai/respire-dimcode) (Dim) · [respire-qoder](https://github.com/risense-ai/respire-qoder) (Qoder) · [respire-workbuddy](https://github.com/risense-ai/respire-workbuddy) (WorkBuddy) · [respire-zcode](https://github.com/risense-ai/respire-zcode) (this plugin's standalone repo).

## Fully usable without the model (degradation is a first-class citizen)

- **Registration, login, sync and recall never depend on a local model** — the plugin works right after install; without the model the engine automatically falls back to the lexical tier.
- BGE-M3 is a **pure optional boost**: for better semantic recall run `rsrs model install && rsrs model activate m3`. The plugin notices it is missing and mentions it once in-session; installing or not never blocks anything.

## What happens after install

| When | Behavior |
| --- | --- |
| `SessionStart` | Injects a short memory playbook (when to recall, how to store, red lines); **one probe, three states** — signed-out gets registration guidance, an empty store (<10 records) gets first-day seeding/import guidance, a missing semantic model gets the **optional** install hint; zero interruption otherwise |
| `UserPromptSubmit` | Automatic `rsrs recall --titles`: **title-tier injection** — score + 8-char short id + title only; the agent fetches bodies on demand with `rsrs show <id>`. Default is **direct output without threshold filtering**; noise is bounded by the engine's own skip gate + limit 5 + title tier |
| Prompt starts with `记:` / `存:` / `remember:` | Stores directly via `rsrs remember … --importance important` and returns a receipt; when the dedup judge finds a similar record nothing is written — candidates are relayed for the model to decide (`--parent` attach or `--force` write); the receipt requires the model to extract a "subject + action + result" fact sentence and `retitle` |
| `Stop` (agent finished) | **Storage check**: `{"decision":"block","reason":…}` continues one round, nudging the model to store new facts/decisions/agreements/lessons/pitfalls; pure Q&A or chat ends directly. Loop-safe: the continuation round carries `stop_hook_active=true` and passes through (the host caps continuations at three; this layer nudges at most once per turn); throttle `store_nudge_every` (1 = every turn, N = every N turns, 0 = off); if the store saw a write in the last 10 minutes (engine `list`), it stays silent |
| Prompt starts with `/nomem` | Skips recall for that turn |
| `skills/respire` | On-demand playbook (recall/remember/show/forget/sync and envelope parsing notes); **the skill is documentation — actions are hook-driven** |

## Install

Install directly from the official plugin market (**Settings → Plugins**, search respire). Alternatively add the standalone repo as a custom market: clone [risense-ai/respire-zcode](https://github.com/risense-ai/respire-zcode), then **Plugin Marketplace → Add → Add Plugin Marketplace** with the repo directory, and install from "Personal → risense-zcode".

## First use · three things

1. **Register & sign in** (works out of the box, no model needed): register at [rsrs.rs](https://rsrs.rs) → run `rsrs register` locally; day-to-day `rsrs login` via browser; autosync is always on, `rsrs sync` for manual sync, `rsrs status` for state.
2. **Import existing rules and memory** (one-shot store, LLM extracts): paste this into a new ZCode task —

> Please import my existing rules and memory into respire: read one by one — `~/.zcode/AGENTS.md` (home rules, if present), workspace-root and per-project `AGENTS.md`, `~/.agents/skills/*/SKILL.md`; extract reusable facts, agreements, lessons and red lines (never passwords, ID numbers, card numbers, private keys — record only where they are stored), dedupe, and store them one by one with `rsrs remember` (`--importance important`, fact-sentence titles; on dedup candidates decide to attach or merge), then give me a list.

3. **Local model (optional boost)**: `rsrs model install && rsrs model activate m3` — fully usable without it; install for better semantic recall.

## Tuning (optional)

`hooks/respire.config.json` inside the installed plugin directory (missing = all defaults; new sessions pick it up; **never touches login or account**; template: `hooks/respire.config.example.json`):

| Field | Default | Meaning |
| --- | --- | --- |
| `rsrs` | `""` | Engine path; empty = auto-detect (PATH → `~/.local/bin` → `~/.rsrs/bin`) |
| `recall_threshold` | `0.0` | Recall floor; **0 = off by default (engine direct output)** |
| `recall_limit` | `5` | Top N per turn |
| `min_prompt_chars` | `2` | Skip 1-char prompts |
| `session_rules` | `true` | Inject the SessionStart playbook |
| `budget_chars` | `1500` | Per-turn injection budget |
| `enabled` | `true` | **Master switch**: false = fully silent |
| `store_nudge_every` | `1` | Stop-check throttle: 1 = every turn, N = every N turns, 0 = off |
| `skip_prefixes` | `[]` | Host-internal prompts matching these prefixes are neither recalled nor stored |
| `log` | `true` | `hook.log` trace in the data dir (rotated at 256KB) |

## Dependencies, network and side effects

- **Required dependency**: the respire engine (`rsrs` CLI, npm package [`@rsrsai/cli`](https://www.npmjs.com/package/@rsrsai/cli), MIT, by risense-ai — the same vendor as this plugin). When missing, the plugin injects the install command (`npm i -g @rsrsai/cli@latest`) for the agent to run in-session; auto-detected at PATH, `~/.local/bin`, `~/.rsrs/bin`.
- **Network**: installing the engine uses npm; `rsrs sync` talks to the respire cloud (end-side encrypted; account optional — local-only mode works). No other network access.
- **Model/API**: optional BGE-M3 sidecar model downloaded via `rsrs model install`; no external LLM API is called by this plugin.
- **Command execution**: hooks invoke `rsrs` (`recall`/`remember`/`list`/`status`) as subprocesses.
- **File writes**: `hook.log` and `.nudge_counter` in the plugin data dir (or the hooks directory as fallback); nothing else.
- **Hooks**: `SessionStart`, `UserPromptSubmit`, `Stop` — all fail-open (empty output + exit 0 on any error, never blocks a session).
- **No MCP server**, no telemetry.
- **Assets**: `assets/respire/icon.png` is the project logo of risense-ai's respire (MIT). Third-party services referenced: rsrs.rs (account/sync, optional), npm registry (engine install).

## Self-test

```bash
python3 ../../scripts/validate.py # marketplace structure (repo root)
bash tests/test_hooks.sh # read-only behavior assertions against a real engine
bash tests/test_hooks.sh --store # adds a write probe (writes the real store, then rsrs forget cleanup)
```

## License

MIT
76 changes: 76 additions & 0 deletions external_plugins/respire/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# respire

> 吸即存,呼即取——给 ZCode 装上本地加密记忆。

`respire`(CLI 名 `rsrs`)是 ZCode 标准插件:以命令钩子把 respire 记忆引擎挂进 agent 循环——每轮标题档自动召回、「记:」一前缀即落库、Stop 存储检查。本地优先、端侧加密、云端 LWW 同步。

其他宿主的姊妹版本:[respire-dimcode](https://github.com/risense-ai/respire-dimcode)(Dim)· [respire-qoder](https://github.com/risense-ai/respire-qoder)(Qoder)· [respire-workbuddy](https://github.com/risense-ai/respire-workbuddy)(WorkBuddy)· [respire-zcode](https://github.com/risense-ai/respire-zcode)(本插件的独立源仓)。

## 不装模型完全可用(降级是一等公民)

- **注册、登录、同步、召回全不依赖端侧模型**——装完插件即可用,未装模型时引擎自动走词面档。
- BGE-M3 是**纯可选增强**:想要更好的语义召回再 `rsrs model install && rsrs model activate m3`,插件检测到未装会在会话内提示一句,装与不装都不报错、不拦路。

## 装上后发生什么

| 时机 | 行为 |
| --- | --- |
| `SessionStart` | 注入记忆层简则(何时翻忆、如何落库、红线);**一次探测三态**——未登录附注册引导、库空(<10 条)附首日存料与导入引导、缺语义模型附**可选**装法;常态零打扰 |
| `UserPromptSubmit` | 自动 `rsrs recall --titles`:**标题档注入**——只给分数+8 位短 id+标题,正文由 agent `rsrs show <id>` 按需取;默认**直出不过滤**,噪音边界=rsrs skip 门+limit 5+标题档 |
| `prompt` 以「记:」「存:」「remember:」开头 | 直接 `rsrs remember … --importance important` 落库并回执;判后即存判为相似时**不写入**、回执转述候选(`--parent` 挂靠或 `--force` 直写),由模型决断;回执硬约束 AI 抽「主语+动作+结果」事实句 `retitle` 替换暂拟题 |
| `Stop`(AI 干完活) | **存储检查**:`{"decision":"block","reason":…}` 续跑一轮,提示模型把本轮新的**事实/决定/约定/教训/踩坑**分条 `rsrs remember`;闲聊无新事实则直接结束。防循环:续跑轮 stdin 带 `stop_hook_active=true` 即放行(宿主限续跑至多三次,本层每轮至多催一次);节流 `store_nudge_every`(默认 1=每轮,N=每 N 轮,0=关);近 10 分钟本库有过落库(问引擎 `list`)则不再催 |
| `prompt` 以 `/nomem` 开头 | 本轮跳过召回 |
| `skills/respire` | 按需加载的操作法(recall/remember/show/forget/sync 与信封解析要点);**注意技能只是说明书,动作全由钩子驱动** |

## 安装

官方插件市场直接安装(**设置 → 插件** 搜索 respire)。也可自建市场源安装:克隆 [risense-ai/respire-zcode](https://github.com/risense-ai/respire-zcode) 后,在 **插件市场 → 添加 → 添加插件市场** 粘贴仓目录,再在「个人 → risense-zcode」安装。

## 首次使用 · 三件事

1. **注册登录**(开箱即用,不依赖模型):[rsrs.rs](https://rsrs.rs) 注册 → 本机 `rsrs register`;日常 `rsrs login` 浏览器授权;autosync 常开,`rsrs sync` 手动同步,`rsrs status` 查态。
2. **导入既有记忆与规则(一次成库,LLM 代抽)**:开个 ZCode 新任务粘贴下面整段——

> 请把本机的既有规则与记忆导入 respire:逐个读取——`~/.zcode/AGENTS.md`(家目录规则,若在)、工作区根与各项目的 `AGENTS.md`、`~/.agents/skills/*/SKILL.md`;抽出可复用的事实、约定、教训与红线(口令、证件号、卡号、私钥一律排除、只记位置),去重后用 `rsrs remember` 分条存入(`--importance important`、标题按事实句;判重给候选先决断挂靠或合并),存完给我一份清单。

3. **端侧模型(可选增强)**:`rsrs model install && rsrs model activate m3`——不装完全可用,想要更好语义召回再装。

## 调优(可选)

插件安装目录下 `hooks/respire.config.json`(缺失即全默认,改完新会话生效;**不涉及登录与账号**;模板见 `hooks/respire.config.example.json`):

| 字段 | 默认 | 含义 |
| --- | --- | --- |
| `rsrs` | `""` | 引擎路径;空 = 自动探测(PATH → `~/.local/bin` → `~/.rsrs/bin`) |
| `recall_threshold` | `0.0` | 召回下限;**0=默认关(rsrs 直出)**,设正数才启用过滤 |
| `recall_limit` | `5` | 取前 N 条 |
| `min_prompt_chars` | `2` | 1 字才跳,2 字起即查 |
| `session_rules` | `true` | 是否注入 SessionStart 简则 |
| `budget_chars` | `1500` | 单轮注入总预算 |
| `enabled` | `true` | **总开关**:false=全线静默 |
| `store_nudge_every` | `1` | Stop 存储检查节流:1=每轮、N=每 N 轮、0=关 |
| `skip_prefixes` | `[]` | 宿主内部提示白名单:命中前缀的 prompt 不召回不落库 |
| `log` | `true` | 数据目录 `hook.log` 留痕(超 256KB 清轮) |

## 依赖、网络与副作用

- **必需依赖**:respire 引擎(`rsrs` CLI,npm 包 [`@rsrsai/cli`](https://www.npmjs.com/package/@rsrsai/cli),MIT,与本插件同属 risense-ai)。缺失时插件会在会话内注入装法(`npm i -g @rsrsai/cli@latest`)由 agent 代装;探测顺序 PATH → `~/.local/bin` → `~/.rsrs/bin`。
- **网络**:装引擎走 npm;`rsrs sync` 连 respire 云端(端侧加密;账号可选,纯本机模式可用)。除此之外无网络访问。
- **模型/API**:可选 BGE-M3 端侧模型经 `rsrs model install` 下载;本插件不调用任何外部 LLM API。
- **命令执行**:钩子以子进程调用 `rsrs`(`recall`/`remember`/`list`/`status`)。
- **文件写入**:插件数据目录(回退 hooks 目录)的 `hook.log` 与 `.nudge_counter`;无其他写入。
- **钩子**:`SessionStart`、`UserPromptSubmit`、`Stop`——全部 fail-open(任何异常空输出+exit 0,绝不拦会话)。
- **无 MCP server**、无遥测。
- **素材**:`assets/respire/icon.png` 为 risense-ai respire 项目 logo(MIT)。引用的第三方服务:rsrs.rs(账号/同步,可选)、npm registry(引擎安装)。

## 自测

```bash
python3 ../../scripts/validate.py # 市场结构(仓根)
bash tests/test_hooks.sh # 行为只读断言(需真机 rsrs 引擎)
bash tests/test_hooks.sh --store # 加写探针(写真库→回执→rsrs forget 自清理)
```

## License

MIT
41 changes: 41 additions & 0 deletions external_plugins/respire/hooks/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"hooks": {
"SessionStart": [
{
"matcher": "startup|resume|clear|compact",
"hooks": [
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/respire.py\" SessionStart || python \"${CLAUDE_PLUGIN_ROOT}/hooks/respire.py\" SessionStart",
"timeout": 20,
"statusMessage": "respire: injecting memory playbook"
}
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/respire.py\" UserPromptSubmit || python \"${CLAUDE_PLUGIN_ROOT}/hooks/respire.py\" UserPromptSubmit",
"timeout": 20,
"statusMessage": "respire: recalling memory"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/respire.py\" Stop || python \"${CLAUDE_PLUGIN_ROOT}/hooks/respire.py\" Stop",
"timeout": 20,
"statusMessage": "respire: checking storage"
}
]
}
]
}
}
10 changes: 10 additions & 0 deletions external_plugins/respire/hooks/respire.config.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"rsrs": "",
"recall_threshold": 0.0,
"recall_limit": 5,
"min_prompt_chars": 2,
"session_rules": true,
"budget_chars": 1500,
"enabled": true,
"skip_prefixes": []
}
Loading