paseo-recap 0.2.3 → 0.2.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.
package/OVERVIEW.md CHANGED
@@ -30,7 +30,7 @@ A recap reads only the text of recent user and assistant messages, short error m
30
30
 
31
31
  With **Same as agent** or **Metadata model**, a model that is unavailable or fails is followed by the next one: the agent's own provider first (for Same as agent, when it has a small model), then the models in Paseo's metadata generation settings, then Paseo's small models that are installed (Claude Haiku, GPT-5.4 mini, MiniMax M3, Nemotron 3 Super). Any of those providers can therefore receive the conversation text. Unlike Paseo's own metadata generation, a recap never falls back to the agent's large model. Choosing Claude, Codex, or OpenCode sends recaps only to that provider, with no fallback.
32
32
 
33
- Claude runs with no tools, MCP servers, or user settings. Codex runs in a read-only sandbox with your own Codex configuration, which includes any MCP servers you have set up there. OpenCode runs its read-only plan agent. Each run uses a temporary folder. Claude and Codex runs are not saved as sessions. OpenCode always saves one, and the plugin deletes it right after the run; if that deletion fails, the session stays in OpenCode.
33
+ Claude runs with no tools, MCP servers, or user settings. Codex runs in a read-only sandbox with your own Codex configuration, which includes any MCP servers you have set up there. OpenCode runs its read-only plan agent. OpenCode 1.x uses `--pure`; 2.x has no equivalent, so OpenCode plugins load. Each run uses a temporary folder. Claude and Codex runs are not saved as sessions. OpenCode always saves one, and the plugin deletes it right after the run; if that deletion fails, the session stays in OpenCode. On OpenCode 2.x, both the run and session deletion use `--standalone` to avoid a persistent background service.
34
34
 
35
35
  Recaps are saved with owner-only permissions in the Paseo data folder, kept for 30 days, and deleted when the agent is archived.
36
36
 
package/README.md CHANGED
@@ -41,7 +41,7 @@ paseo plugin install npm:paseo-recap
41
41
  ```
42
42
 
43
43
  You can also paste `npm:paseo-recap` into **Settings → Plugins → Plugin source**, or install the
44
- latest source with `paseo plugin install github:kingsleydon/paseo-recap`.
44
+ latest source with `paseo plugin install github:kingsleydon/paseo-plugins:plugins/recap`.
45
45
 
46
46
  Recaps start with the next completed turn of each agent. For an agent that is already idle, tap its
47
47
  **Recap** pill and choose **Generate**.
@@ -80,7 +80,7 @@ you type.
80
80
  |---|---|
81
81
  | `claude` | `claude -p --json-schema … --tools "" --strict-mcp-config --setting-sources "" --no-session-persistence`, thinking off |
82
82
  | `codex` | `codex exec --ephemeral --sandbox read-only --output-schema … --disable hooks`, low reasoning effort, with your Codex configuration |
83
- | `opencode` | `opencode run --pure --agent plan --format json`; the session is deleted afterwards |
83
+ | `opencode` | 1.x: `opencode run --pure --agent plan --format json`; 2.x: `opencode run --standalone --agent plan --format json`; the session is deleted afterwards, also with `--standalone` on 2.x |
84
84
 
85
85
  See [docs/design.md](docs/design.md) for the full design, edge cases, and a comparison with Claude
86
86
  Code, Codex, and OMP.
@@ -94,7 +94,9 @@ Code, Codex, and OMP.
94
94
  gets recaps only for itself.
95
95
  - Claude runs with no tools, MCP servers, or settings. Codex runs in a read-only sandbox with your
96
96
  own Codex configuration, including any MCP servers you set up there. OpenCode uses its read-only
97
- `plan` agent, which rejects permission requests.
97
+ `plan` agent, which rejects permission requests. OpenCode 1.x uses `--pure`; 2.x has no equivalent,
98
+ so OpenCode plugins load. On 2.x, both the run and session deletion use `--standalone` to avoid a
99
+ persistent background service.
98
100
  - Recaps are stored with owner-only permissions, kept for 30 days, and deleted when the agent is
99
101
  archived. Recap rows in the conversation live in daemon memory and are gone after a restart.
100
102
  - Like every Paseo plugin, this is trusted code that runs unsandboxed on the daemon host.
@@ -124,18 +126,10 @@ paseo plugin logs paseo-recap
124
126
 
125
127
  ## Releasing
126
128
 
127
- Releases publish to npm from GitHub Actions with [trusted publishing](https://docs.npmjs.com/trusted-publishers)
128
- (OIDC), so no npm token is stored anywhere. The publish job runs in the `npm` GitHub environment,
129
- which only `v*` tags can deploy to, and npm trusts only that environment. Bump `version` in `package.json` in a PR, merge it,
130
- then tag the merged commit:
131
-
132
- ```bash
133
- git tag v0.2.0 && git push origin v0.2.0
134
- ```
135
-
136
- [`.github/workflows/publish.yml`](.github/workflows/publish.yml) checks that the tag matches the
137
- version, runs the type check and tests, and publishes with provenance. Once the paseo.sh listing
138
- uses the npm package as its source, the registry proposes each new version automatically.
129
+ Title PRs `fix(recap): ...` or `feat(recap): ...`, then merge the release PR that release-please
130
+ opens. It bumps the version, updates [`CHANGELOG.md`](CHANGELOG.md), tags `recap-v<version>`,
131
+ creates the GitHub Release, and publishes to npm with [trusted publishing](https://docs.npmjs.com/trusted-publishers).
132
+ See the [repository README](../../README.md#releasing) for details.
139
133
 
140
134
  ## License
141
135
 
package/index.server.ts CHANGED
@@ -119,10 +119,10 @@ export default function contribute(server: PluginServerContext) {
119
119
  await ready;
120
120
  scheduler.turnStarted(agent);
121
121
  }),
122
- server.on("agent.turn_ended", async ({ agent, outcome, timeline }, context) => {
122
+ server.on("agent.turn_ended", async ({ agent, outcome }, context) => {
123
123
  paseo = context.paseo;
124
124
  await ready;
125
- await scheduler.turnEnded(agent, outcome, timeline);
125
+ await scheduler.turnEnded(agent, outcome);
126
126
  }),
127
127
  server.on("agent.permission_requested", ({ agent, request }) => {
128
128
  scheduler.permissionRequested(agent, request.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-recap",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Writes a short recap of each agent's goal, progress, and next step after every turn, like Claude Code's session recap.",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -33,11 +33,12 @@
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",
36
- "url": "git+https://github.com/kingsleydon/paseo-recap.git"
36
+ "url": "git+https://github.com/kingsleydon/paseo-plugins.git",
37
+ "directory": "plugins/recap"
37
38
  },
38
- "homepage": "https://github.com/kingsleydon/paseo-recap#readme",
39
+ "homepage": "https://github.com/kingsleydon/paseo-plugins/tree/main/plugins/recap#readme",
39
40
  "bugs": {
40
- "url": "https://github.com/kingsleydon/paseo-recap/issues"
41
+ "url": "https://github.com/kingsleydon/paseo-plugins/issues"
41
42
  },
42
43
  "keywords": [
43
44
  "paseo",
package/server/cli.ts CHANGED
@@ -54,21 +54,29 @@ export function codexArgs(model: string | null, schemaPath: string, outputPath:
54
54
  ];
55
55
  }
56
56
 
57
- export function opencodeArgs(model: string | null, workdir: string): string[] {
57
+ export function opencodeArgs(model: string | null, workdir: string, major: number | null): string[] {
58
+ // The 2.x CLI (@opencode/cli) dropped `run --pure` and `--dir`; 1.x (opencode-ai) still needs
59
+ // them. On 2.x, --standalone avoids a persistent background service. Unknown versions use 1.x flags.
60
+ const legacy = major === null || major < 2;
58
61
  return [
59
62
  "run",
60
- "--pure",
63
+ ...(legacy ? ["--pure"] : ["--standalone"]),
61
64
  "--format",
62
65
  "json",
63
66
  // Read-only agent; without --auto, any permission request is rejected.
64
67
  "--agent",
65
68
  "plan",
66
- "--dir",
67
- workdir,
69
+ ...(legacy ? ["--dir", workdir] : []),
68
70
  ...(model ? ["--model", model] : []),
69
71
  ];
70
72
  }
71
73
 
74
+ /** Parses `opencode --version` output into the CLI generation, or null when it cannot be read. */
75
+ export function parseOpencodeMajor(stdout: string, code: number | null): number | null {
76
+ const major = code === 0 ? Number(/v?(\d+)\./.exec(stdout.trim())?.[1] ?? NaN) : NaN;
77
+ return Number.isFinite(major) ? major : null;
78
+ }
79
+
72
80
  export interface OpencodeOutcome {
73
81
  sessionId: string | null;
74
82
  recap: ParsedRecap;
@@ -1,9 +1,9 @@
1
1
  import { mkdtemp, rm, writeFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- import { claudeArgs, codexArgs, opencodeArgs, parseClaudeResult, parseCodexResult, parseOpencodeEvents } from "./cli";
3
+ import { claudeArgs, codexArgs, opencodeArgs, parseClaudeResult, parseCodexResult, parseOpencodeEvents, parseOpencodeMajor } from "./cli";
4
4
  import { abortError, errorMessage, GeneratorUnavailableError, NoGeneratorError } from "./errors";
5
5
  import type { GeneratorCandidate } from "./models";
6
- import { sanitizeEnv, type RunProcess } from "./process";
6
+ import { sanitizeEnv, type ProcessResult, type RunProcess } from "./process";
7
7
  import { RECAP_JSON_SCHEMA, type ParsedRecap } from "./prompt";
8
8
 
9
9
  const GENERATE_TIMEOUT_MS = 60_000;
@@ -34,6 +34,8 @@ export class RecapGenerator {
34
34
  readonly #unavailableUntil = new Map<string, number>();
35
35
  readonly #waiting: Array<() => void> = [];
36
36
  #active = 0;
37
+ /** Successfully detected opencode CLI generations, keyed by executable and leading arguments. */
38
+ readonly #opencodeMajors = new Map<string, number>();
37
39
 
38
40
  constructor(deps: GeneratorDeps) {
39
41
  this.#deps = deps;
@@ -140,9 +142,10 @@ export class RecapGenerator {
140
142
  return await parseCodexResult(result, outputPath);
141
143
  }
142
144
  case "opencode": {
143
- const parsed = parseOpencodeEvents(await run(opencodeArgs(candidate.model, workdir)));
145
+ const major = await this.#opencodeGeneration(candidate.command, run);
146
+ const parsed = parseOpencodeEvents(await run(opencodeArgs(candidate.model, workdir, major)));
144
147
  // `opencode run` always persists a session; remove it so recaps leave no trace.
145
- if (parsed.sessionId) await this.#deleteOpencodeSession(candidate, parsed.sessionId, workdir, env);
148
+ if (parsed.sessionId) await this.#deleteOpencodeSession(candidate, parsed.sessionId, major, workdir, env);
146
149
  if (parsed.error) throw parsed.error;
147
150
  return parsed.recap;
148
151
  }
@@ -152,9 +155,24 @@ export class RecapGenerator {
152
155
  }
153
156
  }
154
157
 
158
+ /** Caches successful version probes per command; spawn failures propagate as a failed candidate. */
159
+ async #opencodeGeneration(
160
+ command: readonly string[],
161
+ run: (args: readonly string[]) => Promise<ProcessResult>,
162
+ ): Promise<number | null> {
163
+ const key = command.join("\0");
164
+ const cached = this.#opencodeMajors.get(key);
165
+ if (cached !== undefined) return cached;
166
+ const result = await run(["--version"]);
167
+ const major = parseOpencodeMajor(result.stdout, result.code);
168
+ if (major !== null) this.#opencodeMajors.set(key, major);
169
+ return major;
170
+ }
171
+
155
172
  async #deleteOpencodeSession(
156
173
  candidate: GeneratorCandidate,
157
174
  sessionId: string,
175
+ major: number | null,
158
176
  workdir: string,
159
177
  env: NodeJS.ProcessEnv,
160
178
  ): Promise<void> {
@@ -162,7 +180,7 @@ export class RecapGenerator {
162
180
  try {
163
181
  const result = await this.#deps.runProcess(
164
182
  executable,
165
- [...leading, "session", "delete", sessionId],
183
+ [...leading, "session", "delete", ...(major !== null && major >= 2 ? ["--standalone"] : []), sessionId],
166
184
  { stdin: "", cwd: workdir, env, signal: new AbortController().signal, timeoutMs: CLEANUP_TIMEOUT_MS },
167
185
  );
168
186
  if (result.code !== 0) this.#deps.log("could not delete opencode recap session", sessionId);
package/server/history.ts CHANGED
@@ -1,17 +1,5 @@
1
- import { SETTING_RANGES } from "../shared/recap";
2
1
  import type { AgentTimelineItem } from "./paseo-types";
3
2
 
4
- /** Most exchanges a recap can read; the `historyExchanges` setting picks how many, up to this. */
5
- export const HISTORY_EXCHANGES_LIMIT = SETTING_RANGES.historyExchanges.max;
6
- /** Timeline items a recap reads; everything else is dropped before holding a timeline in memory. */
7
- const RECAP_ITEM_TYPES: ReadonlySet<AgentTimelineItem["type"]> = new Set([
8
- "user_message",
9
- "assistant_message",
10
- "error",
11
- "compaction",
12
- "todo",
13
- ]);
14
-
15
3
  const OMITTED_HISTORY = "[Earlier exchanges omitted]\n\n";
16
4
  const EXCERPT_MARKER = "\n[... excerpted ...]\n";
17
5
  const ERROR_MAX_CHARS = 300;
@@ -31,27 +19,6 @@ export function buildRecapHistory(
31
19
  return formatHistory(collectExchanges(timeline).slice(-maxExchanges), maxHistoryBytes);
32
20
  }
33
21
 
34
- /**
35
- * Keeps only what a recap can read: the text items of the last `HISTORY_EXCHANGES_LIMIT` exchanges
36
- * plus the latest todo list. Turn-ended events carry the whole conversation, including tool output,
37
- * which is too much to hold for every agent.
38
- */
39
- export function trimForRecap(timeline: readonly AgentTimelineItem[]): AgentTimelineItem[] {
40
- let seen = 0;
41
- let start = 0;
42
- for (let index = timeline.length - 1; index >= 0; index--) {
43
- const item = timeline[index];
44
- if (item?.type === "user_message" && item.text.trim() !== "" && ++seen === HISTORY_EXCHANGES_LIMIT) {
45
- start = index;
46
- break;
47
- }
48
- }
49
- const kept = timeline.slice(start).filter((item) => RECAP_ITEM_TYPES.has(item.type));
50
- if (kept.some((item) => item.type === "todo")) return kept;
51
- const latestTodo = timeline.findLast((item) => item.type === "todo");
52
- return latestTodo ? [latestTodo, ...kept] : kept;
53
- }
54
-
55
22
  /** True while the provider is compacting context; a recap would describe a moving target. */
56
23
  export function isCompacting(timeline: readonly AgentTimelineItem[]): boolean {
57
24
  const last = timeline.findLast((item) => item.type === "compaction");
@@ -2,7 +2,7 @@ import type { PluginHookAgent, PluginTurnOutcome } from "@getpaseo/plugin/server
2
2
  import type { RecapSettings, RecapState, RecapView, StoredRecap } from "../shared/recap";
3
3
  import { errorMessage, NoGeneratorError, RecapSkippedError } from "./errors";
4
4
  import type { GeneratedRecap } from "./generators";
5
- import { buildRecapHistory, countUserTurns, isCompacting, latestActiveTask, trimForRecap } from "./history";
5
+ import { buildRecapHistory, countUserTurns, isCompacting, latestActiveTask } from "./history";
6
6
  import type { AgentTimelineItem } from "./paseo-types";
7
7
  import { historyBudget, renderPrompt } from "./prompt";
8
8
 
@@ -47,7 +47,7 @@ export interface SchedulerDeps {
47
47
  store: RecapStoreLike;
48
48
  readSettings(): Promise<RecapSettings>;
49
49
  generate(prompt: string, signal: AbortSignal, options: GenerateOptions): Promise<GeneratedRecap>;
50
- /** Fresh timeline for manual recaps of agents this plugin has not observed yet. */
50
+ /** The conversation and live status, read right before each recap. */
51
51
  fetchAgentContext(agentId: string): Promise<AgentContext>;
52
52
  /** Shows a newly stored recap in the agent's conversation. */
53
53
  publish(recap: StoredRecap): Promise<void>;
@@ -70,10 +70,6 @@ interface AgentEntry {
70
70
  lastTurnCompleted: boolean;
71
71
  /** Completed turns since the last stored recap; null until known (no recap observed yet). */
72
72
  turnsSinceRecap: number | null;
73
- /** User messages in the whole conversation (the kept timeline is trimmed). */
74
- userTurns: number;
75
- /** Trimmed to what a recap reads; see `trimForRecap`. */
76
- timeline: readonly AgentTimelineItem[] | null;
77
73
  pendingPermissions: Set<string>;
78
74
  runningChildren: Set<string>;
79
75
  timer: ReturnType<typeof setTimeout> | null;
@@ -114,16 +110,10 @@ export class RecapScheduler {
114
110
  if (entry.parentAgentId) this.#entryById(entry.parentAgentId).runningChildren.add(entry.id);
115
111
  }
116
112
 
117
- async turnEnded(
118
- agent: PluginHookAgent,
119
- outcome: PluginTurnOutcome,
120
- timeline: readonly AgentTimelineItem[],
121
- ): Promise<void> {
113
+ async turnEnded(agent: PluginHookAgent, outcome: PluginTurnOutcome): Promise<void> {
122
114
  const entry = this.#entry(agent);
123
115
  entry.running = false;
124
116
  entry.runningSince = null;
125
- entry.timeline = trimForRecap(timeline);
126
- entry.userTurns = countUserTurns(timeline);
127
117
  entry.lastTurnCompleted = outcome.kind === "completed";
128
118
  if (entry.lastTurnCompleted && entry.turnsSinceRecap !== null) entry.turnsSinceRecap++;
129
119
  if (entry.parentAgentId) {
@@ -178,30 +168,6 @@ export class RecapScheduler {
178
168
  this.#clearTimer(entry);
179
169
  entry.error = null;
180
170
  entry.state = "generating";
181
- let context: AgentContext;
182
- try {
183
- context = await this.#deps.fetchAgentContext(agentId);
184
- } catch (error) {
185
- entry.state = "error";
186
- entry.error = "Could not read the conversation.";
187
- this.#deps.log(`could not fetch timeline for agent ${agentId}`, errorMessage(error));
188
- return this.view(agentId);
189
- }
190
- entry.timeline = trimForRecap(context.timeline);
191
- entry.userTurns = countUserTurns(context.timeline);
192
- entry.title = context.title ?? entry.title;
193
- entry.workspaceId = context.workspaceId ?? entry.workspaceId;
194
- entry.provider = context.provider ?? entry.provider;
195
- // Trust the daemon's live status over hook bookkeeping, which can miss a turn's end.
196
- if (context.running) {
197
- entry.state = "idle";
198
- entry.error = "The agent is running. Try again when it is idle.";
199
- return this.view(agentId);
200
- }
201
- if (entry.running) {
202
- entry.running = false;
203
- entry.runningSince = null;
204
- }
205
171
  await this.#run(entry, "manual");
206
172
  return this.view(agentId);
207
173
  }
@@ -284,9 +250,7 @@ export class RecapScheduler {
284
250
  if (entry.running || !entry.lastTurnCompleted || entry.inFlight) return false;
285
251
  if (entry.pendingPermissions.size > 0) return false;
286
252
  if (settings.waitForSubagents && this.#hasBlockingChild(entry)) return false;
287
- if (entry.failures >= MAX_CONSECUTIVE_FAILURES || !entry.timeline) return false;
288
- if (isCompacting(entry.timeline)) return false;
289
- if (entry.userTurns < settings.minTurns) return false;
253
+ if (entry.failures >= MAX_CONSECUTIVE_FAILURES) return false;
290
254
  // Without an observed recap (fresh agent or daemon restart), recap the next completed turn.
291
255
  return entry.turnsSinceRecap === null || entry.turnsSinceRecap >= settings.turnsBetweenRecaps;
292
256
  }
@@ -302,20 +266,32 @@ export class RecapScheduler {
302
266
 
303
267
  async #generate(entry: AgentEntry, trigger: Trigger, abort: AbortController): Promise<void> {
304
268
  const revision = entry.revision;
305
- const { historyExchanges } = await this.#deps.readSettings();
306
- // A turn may have started while settings loaded; it has already reset this entry.
307
- if (abort.signal.aborted || entry.revision !== revision || this.#disposed) return;
308
- const timeline = entry.timeline ?? [];
309
- const context = { goal: entry.title, activeTask: latestActiveTask(timeline) };
310
- const history = buildRecapHistory(timeline, historyBudget(context), historyExchanges);
311
- if (history === "") {
269
+ const manual = trigger === "manual";
270
+ const skip = (error: string | null) => {
312
271
  entry.state = "idle";
313
- entry.error = trigger === "manual" ? "There is no conversation to recap yet." : null;
314
- return;
315
- }
316
- entry.state = "generating";
317
- entry.error = null;
272
+ entry.error = manual ? error : null;
273
+ };
318
274
  try {
275
+ const [settings, agent] = await Promise.all([
276
+ this.#deps.readSettings(),
277
+ this.#deps.fetchAgentContext(entry.id),
278
+ ]);
279
+ // A turn may have started meanwhile; it has already reset this entry.
280
+ if (abort.signal.aborted || entry.revision !== revision || this.#disposed) return;
281
+ entry.title = agent.title ?? entry.title;
282
+ entry.workspaceId = agent.workspaceId ?? entry.workspaceId;
283
+ entry.provider = agent.provider ?? entry.provider;
284
+ // Trust the daemon's live status over hook bookkeeping, which can miss a turn's end.
285
+ if (agent.running) return skip("The agent is running. Try again when it is idle.");
286
+ entry.running = false;
287
+ entry.runningSince = null;
288
+ const userTurns = countUserTurns(agent.timeline);
289
+ if (!manual && (isCompacting(agent.timeline) || userTurns < settings.minTurns)) return skip(null);
290
+ const context = { goal: entry.title, activeTask: latestActiveTask(agent.timeline) };
291
+ const history = buildRecapHistory(agent.timeline, historyBudget(context), settings.historyExchanges);
292
+ if (history === "") return skip("There is no conversation to recap yet.");
293
+ entry.state = "generating";
294
+ entry.error = null;
319
295
  const generated = await this.#deps.generate(renderPrompt(history, context), abort.signal, {
320
296
  agentProvider: entry.provider,
321
297
  trigger,
@@ -328,7 +304,7 @@ export class RecapScheduler {
328
304
  nextAction: generated.nextAction,
329
305
  generatedAt: new Date().toISOString(),
330
306
  revision,
331
- turnCount: entry.userTurns,
307
+ turnCount: userTurns,
332
308
  stale: false,
333
309
  trigger,
334
310
  generator: { provider: generated.provider, model: generated.model },
@@ -413,8 +389,6 @@ export class RecapScheduler {
413
389
  runningSince: null,
414
390
  lastTurnCompleted: false,
415
391
  turnsSinceRecap: null,
416
- userTurns: 0,
417
- timeline: null,
418
392
  pendingPermissions: new Set(),
419
393
  runningChildren: new Set(),
420
394
  timer: null,