@c-d-cc/reap 0.16.3 → 0.16.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,69 @@
1
+ /**
2
+ * REAP OpenCode plugin.
3
+ *
4
+ * Purpose:
5
+ * - On `session.created`, refresh `.reap/.session-state.md` so that
6
+ * OpenCode's `instructions`-based static loading picks up the current
7
+ * REAP state for the next session/tool turn.
8
+ * - On `tool.execute.before`, refresh once if not already done in this
9
+ * plugin instance (handles the "resume" case where `session.created`
10
+ * does not fire).
11
+ *
12
+ * Failure mode: best-effort. If `reap` CLI is missing, not a REAP project,
13
+ * or any other error occurs, the plugin silently swallows it — never blocks
14
+ * the user's session.
15
+ *
16
+ * Plugin API target: OpenCode plugin spec as of 2026-05
17
+ * - signature: `async ({ project, client, $, directory, worktree }) => hooks`
18
+ * - hooks used: `session.created`, `tool.execute.before`
19
+ *
20
+ * For typed development, install `@opencode-ai/plugin` and replace the
21
+ * inline parameter type with `import type { Plugin } from "@opencode-ai/plugin"`.
22
+ */
23
+
24
+ type ShellTagFn = (strings: TemplateStringsArray, ...values: unknown[]) => {
25
+ cwd(dir: string): ShellResult;
26
+ quiet?(): ShellResult;
27
+ };
28
+
29
+ type ShellResult = {
30
+ cwd?(dir: string): ShellResult;
31
+ quiet?(): ShellResult;
32
+ then<T = unknown>(onfulfilled?: ((v: unknown) => T) | null, onrejected?: ((r: unknown) => T) | null): Promise<T>;
33
+ };
34
+
35
+ interface PluginContext {
36
+ $: ShellTagFn;
37
+ directory: string;
38
+ // Other fields (project, client, worktree) are unused by this plugin.
39
+ [k: string]: unknown;
40
+ }
41
+
42
+ export const reapPlugin = async ({ $, directory }: PluginContext) => {
43
+ let dumpedThisSession = false;
44
+
45
+ const dump = async () => {
46
+ try {
47
+ // `reap dump-state --silent` writes .reap/.session-state.md and
48
+ // exits 0 even when the project is not a REAP project (silent mode).
49
+ const cmd = $`reap dump-state --silent`.cwd(directory);
50
+ // Prefer quiet() if available to suppress incidental stdout.
51
+ const runnable = typeof cmd.quiet === "function" ? cmd.quiet() : cmd;
52
+ await runnable;
53
+ dumpedThisSession = true;
54
+ } catch {
55
+ // REAP not installed, not a REAP project, or transient error — ignore.
56
+ }
57
+ };
58
+
59
+ return {
60
+ "session.created": async () => {
61
+ await dump();
62
+ },
63
+ "tool.execute.before": async () => {
64
+ if (!dumpedThisSession) await dump();
65
+ },
66
+ };
67
+ };
68
+
69
+ export default reapPlugin;
@@ -0,0 +1,40 @@
1
+ # REAP Project
2
+
3
+ This project uses REAP (Recursive Evolutionary Autonomous Pipeline). All work must follow genome principles in `.reap/genome/` and respect `.reap/genome/invariants.md` as absolute constraints.
4
+
5
+ ## Knowledge Loading
6
+
7
+ Static knowledge (genome, environment, vision, memory) is auto-loaded via `opencode.json`'s `instructions` field — no manual action required.
8
+
9
+ Dynamic state (current generation, stage, strict mode, language directive) is dumped to `.reap/.session-state.md` by the REAP OpenCode plugin (`.opencode/plugins/reap-plugin.ts`) on `session.created` and `tool.execute.before` hooks. That file is also listed in `instructions`, so it is auto-loaded into every session.
10
+
11
+ If state appears stale (e.g., after long inactivity or external state change), run:
12
+
13
+ - `reap status` — verify current state
14
+ - `reap dump-state` — manually refresh `.reap/.session-state.md`
15
+
16
+ ## REAP Workflow Reference
17
+
18
+ For REAP CLI usage, lifecycle stages, memory model, and behavioral rules, see `~/.reap/reap-guide.md` (installed by `reap install-skills`).
19
+
20
+ When running REAP commands, follow the structured lifecycle (`reap run <stage>`). Do not edit `.reap/life/current.yml` directly — REAP uses signature-based locking and direct edits will produce errors.
21
+
22
+ ## Slash Commands
23
+
24
+ REAP installs `/reap.*` slash commands into `~/.config/opencode/commands/` when `reap install-skills` (or `reap update`) runs with `agentClient: opencode`. Available commands include:
25
+
26
+ - `/reap.evolve` — Run a full generation lifecycle
27
+ - `/reap.start`, `/reap.next`, `/reap.back` — Lifecycle control
28
+ - `/reap.status` — Show current generation state
29
+ - `/reap.early-close`, `/reap.abort` — Termination paths
30
+ - `/reap.knowledge`, `/reap.config` — Knowledge / configuration
31
+ - `/reap.merge`, `/reap.pull`, `/reap.push` — Collaboration
32
+ - `/reap.update`, `/reap.help`, `/reap.report` — Maintenance
33
+
34
+ The `reap.` prefix (with the literal dot) is reserved by REAP — any file matching `reap.*.md` in that directory will be overwritten on the next install. User-defined commands should use a different prefix (e.g., `mytool.md`, `team-review.md`).
35
+
36
+ ## Plugin Compatibility
37
+
38
+ The bundled plugin (`.opencode/plugins/reap-plugin.ts`) targets the OpenCode plugin API as of 2026-05. Plugin signature: `async ({ $, directory }) => hooksObject`. If your OpenCode version changes the plugin API, rerun `reap install-skills` to refresh the plugin file.
39
+
40
+ For typed plugin development, optionally install `@opencode-ai/plugin` and import the `Plugin` type — the bundled plugin uses inline types to avoid forcing this dependency.