paseo-recap 0.2.2 → 0.2.4
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 +1 -1
- package/README.md +9 -10
- package/client/pills.tsx +105 -102
- package/index.client.tsx +2 -2
- package/package.json +5 -4
- package/server/cli.ts +12 -4
- package/server/generators.ts +23 -5
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.
|
|
@@ -125,17 +127,14 @@ paseo plugin logs paseo-recap
|
|
|
125
127
|
## Releasing
|
|
126
128
|
|
|
127
129
|
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.
|
|
129
|
-
|
|
130
|
-
then tag the merged commit:
|
|
130
|
+
(OIDC), so no npm token is stored anywhere. Bump `version` in `package.json` in a PR, merge it,
|
|
131
|
+
then tag the merged commit with `recap-v<version>`:
|
|
131
132
|
|
|
132
133
|
```bash
|
|
133
|
-
git tag v0.2.
|
|
134
|
+
git tag recap-v0.2.4 && git push origin recap-v0.2.4
|
|
134
135
|
```
|
|
135
136
|
|
|
136
|
-
[
|
|
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.
|
|
137
|
+
See the [repository README](../../README.md#releasing) for how the publish workflow works.
|
|
139
138
|
|
|
140
139
|
## License
|
|
141
140
|
|
package/client/pills.tsx
CHANGED
|
@@ -29,133 +29,136 @@ function pillButton({
|
|
|
29
29
|
return { visible, label, icon: busy ? SpinnerIcon : icon };
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
export interface RecapPills {
|
|
33
|
+
start(): void;
|
|
34
|
+
stop(): void;
|
|
35
|
+
refresh(): Promise<void>;
|
|
36
|
+
/** Shows progress on an agent's pill while a manual recap request runs, then its result. */
|
|
37
|
+
track<T>(agentId: string, request: Promise<T>): Promise<T>;
|
|
38
|
+
}
|
|
39
|
+
|
|
32
40
|
/**
|
|
33
41
|
* Keeps one composer pill per agent in sync with daemon recaps. Recaps finish after an idle delay
|
|
34
42
|
* without any agent update, so the list is also polled, faster right after agent activity.
|
|
43
|
+
*
|
|
44
|
+
* A factory rather than a class: plugin client bundles reach Hermes (iOS, Android) without Metro's
|
|
45
|
+
* transforms, and Hermes rejects class syntax (getpaseo/paseo#5783).
|
|
35
46
|
*/
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
#activeUntil = 0;
|
|
46
|
-
readonly #popover = makeRecapPopover({
|
|
47
|
-
cachedView: (agentId) => this.#views.get(agentId),
|
|
48
|
-
track: (agentId, request) => this.track(agentId, request),
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
constructor(client: PluginClientContext) {
|
|
52
|
-
this.#client = client;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
start(): void {
|
|
56
|
-
this.#client.paseo.agents
|
|
57
|
-
.list({ subscribe: {}, signal: this.#lifetime.signal })
|
|
58
|
-
.then(({ subscription }) => {
|
|
59
|
-
subscription.subscribe({
|
|
60
|
-
snapshot: ({ entries }) => {
|
|
61
|
-
this.#removeAll();
|
|
62
|
-
for (const { agent } of entries) this.#register(agent);
|
|
63
|
-
this.#scheduleRefresh();
|
|
64
|
-
},
|
|
65
|
-
update: (message) => {
|
|
66
|
-
if (message.type !== "agent_update") return;
|
|
67
|
-
const update = message.payload;
|
|
68
|
-
if (update.kind === "remove") this.#remove(update.agentId);
|
|
69
|
-
else if (!this.#pills.has(update.agent.id)) this.#register(update.agent);
|
|
70
|
-
this.#activeUntil = Date.now() + ACTIVE_WINDOW_MS;
|
|
71
|
-
this.#scheduleRefresh();
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
})
|
|
75
|
-
.catch((error: unknown) => {
|
|
76
|
-
if (!this.#lifetime.signal.aborted) console.error("[paseo-recap] agent observation failed", error);
|
|
77
|
-
});
|
|
78
|
-
this.#poll = setInterval(() => {
|
|
79
|
-
const now = Date.now();
|
|
80
|
-
const pending = [...this.#views.values()].some(isPending);
|
|
81
|
-
if (pending || now < this.#activeUntil || now - this.#lastRefreshAt >= IDLE_POLL_MS) {
|
|
82
|
-
void this.refresh();
|
|
83
|
-
}
|
|
84
|
-
}, TICK_MS);
|
|
85
|
-
}
|
|
47
|
+
export function createRecapPills(client: PluginClientContext): RecapPills {
|
|
48
|
+
const pills = new Map<string, PluginButtonRegistration>();
|
|
49
|
+
const lifetime = new AbortController();
|
|
50
|
+
let views = new Map<string, RecapView>();
|
|
51
|
+
let debounce: ReturnType<typeof setTimeout> | null = null;
|
|
52
|
+
let poll: ReturnType<typeof setInterval> | null = null;
|
|
53
|
+
let refreshing = false;
|
|
54
|
+
let lastRefreshAt = 0;
|
|
55
|
+
let activeUntil = 0;
|
|
86
56
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
57
|
+
const render = (): void => {
|
|
58
|
+
const now = Date.now();
|
|
59
|
+
for (const [agentId, pill] of pills) {
|
|
60
|
+
pill.update(pillButton(pillPresentation(views.get(agentId), now)));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const refresh = async (): Promise<void> => {
|
|
65
|
+
if (refreshing || lifetime.signal.aborted) return;
|
|
66
|
+
refreshing = true;
|
|
67
|
+
lastRefreshAt = Date.now();
|
|
91
68
|
try {
|
|
92
|
-
const { recaps } = await
|
|
93
|
-
|
|
94
|
-
|
|
69
|
+
const { recaps } = await client.rpc(recapListRpc, {});
|
|
70
|
+
views = new Map(recaps.map((view) => [view.agentId, view]));
|
|
71
|
+
render();
|
|
95
72
|
} catch (error) {
|
|
96
73
|
console.error("[paseo-recap] failed to load recaps", error);
|
|
97
74
|
} finally {
|
|
98
|
-
|
|
75
|
+
refreshing = false;
|
|
99
76
|
}
|
|
100
|
-
}
|
|
77
|
+
};
|
|
101
78
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.#render();
|
|
79
|
+
const track = async <T,>(agentId: string, request: Promise<T>): Promise<T> => {
|
|
80
|
+
const view = views.get(agentId) ?? { agentId, recap: null, previous: [], error: null, state: "idle" };
|
|
81
|
+
views.set(agentId, { ...view, state: "generating", error: null });
|
|
82
|
+
render();
|
|
107
83
|
try {
|
|
108
84
|
return await request;
|
|
109
85
|
} finally {
|
|
110
|
-
void
|
|
86
|
+
void refresh();
|
|
111
87
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
#register(agent: { id: string; workspaceId?: string | null }): void {
|
|
122
|
-
if (this.#lifetime.signal.aborted || !agent.workspaceId) return;
|
|
123
|
-
this.#pills.get(agent.id)?.remove();
|
|
124
|
-
const registration = this.#client.addComposerPill({
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const popover = makeRecapPopover({ cachedView: (agentId) => views.get(agentId), track });
|
|
91
|
+
|
|
92
|
+
const register = (agent: { id: string; workspaceId?: string | null }): void => {
|
|
93
|
+
if (lifetime.signal.aborted || !agent.workspaceId) return;
|
|
94
|
+
pills.get(agent.id)?.remove();
|
|
95
|
+
const registration = client.addComposerPill({
|
|
125
96
|
id: "recap",
|
|
126
97
|
workspaceId: agent.workspaceId,
|
|
127
98
|
agentId: agent.id,
|
|
128
99
|
button: {
|
|
129
100
|
title: "Session recap",
|
|
130
|
-
...pillButton(pillPresentation(
|
|
131
|
-
behavior: { kind: "popover", Content:
|
|
101
|
+
...pillButton(pillPresentation(views.get(agent.id), Date.now())),
|
|
102
|
+
behavior: { kind: "popover", Content: popover },
|
|
132
103
|
},
|
|
133
104
|
});
|
|
134
|
-
|
|
135
|
-
}
|
|
105
|
+
pills.set(agent.id, registration);
|
|
106
|
+
};
|
|
136
107
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
108
|
+
const remove = (agentId: string): void => {
|
|
109
|
+
pills.get(agentId)?.remove();
|
|
110
|
+
pills.delete(agentId);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const removeAll = (): void => {
|
|
114
|
+
for (const pill of pills.values()) pill.remove();
|
|
115
|
+
pills.clear();
|
|
116
|
+
};
|
|
143
117
|
|
|
144
|
-
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
void
|
|
118
|
+
const scheduleRefresh = (): void => {
|
|
119
|
+
if (debounce) clearTimeout(debounce);
|
|
120
|
+
debounce = setTimeout(() => {
|
|
121
|
+
debounce = null;
|
|
122
|
+
void refresh();
|
|
149
123
|
}, UPDATE_DEBOUNCE_MS);
|
|
150
|
-
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const start = (): void => {
|
|
127
|
+
client.paseo.agents
|
|
128
|
+
.list({ subscribe: {}, signal: lifetime.signal })
|
|
129
|
+
.then(({ subscription }) => {
|
|
130
|
+
subscription.subscribe({
|
|
131
|
+
snapshot: ({ entries }) => {
|
|
132
|
+
removeAll();
|
|
133
|
+
for (const { agent } of entries) register(agent);
|
|
134
|
+
scheduleRefresh();
|
|
135
|
+
},
|
|
136
|
+
update: (message) => {
|
|
137
|
+
if (message.type !== "agent_update") return;
|
|
138
|
+
const update = message.payload;
|
|
139
|
+
if (update.kind === "remove") remove(update.agentId);
|
|
140
|
+
else if (!pills.has(update.agent.id)) register(update.agent);
|
|
141
|
+
activeUntil = Date.now() + ACTIVE_WINDOW_MS;
|
|
142
|
+
scheduleRefresh();
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
})
|
|
146
|
+
.catch((error: unknown) => {
|
|
147
|
+
if (!lifetime.signal.aborted) console.error("[paseo-recap] agent observation failed", error);
|
|
148
|
+
});
|
|
149
|
+
poll = setInterval(() => {
|
|
150
|
+
const now = Date.now();
|
|
151
|
+
const pending = [...views.values()].some(isPending);
|
|
152
|
+
if (pending || now < activeUntil || now - lastRefreshAt >= IDLE_POLL_MS) void refresh();
|
|
153
|
+
}, TICK_MS);
|
|
154
|
+
};
|
|
151
155
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
const stop = (): void => {
|
|
157
|
+
lifetime.abort();
|
|
158
|
+
if (debounce) clearTimeout(debounce);
|
|
159
|
+
if (poll) clearInterval(poll);
|
|
160
|
+
removeAll();
|
|
161
|
+
};
|
|
156
162
|
|
|
157
|
-
|
|
158
|
-
for (const pill of this.#pills.values()) pill.remove();
|
|
159
|
-
this.#pills.clear();
|
|
160
|
-
}
|
|
163
|
+
return { start, stop, refresh, track };
|
|
161
164
|
}
|
package/index.client.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { PluginClientContext } from "@getpaseo/plugin/client";
|
|
2
2
|
import { RecapLine } from "./client/recap-line";
|
|
3
|
-
import {
|
|
3
|
+
import { createRecapPills } from "./client/pills";
|
|
4
4
|
import { RecapSettingsScreen } from "./client/settings-screen";
|
|
5
5
|
import { RECAP_TIMELINE_KIND, RecapTimelineDataSchema, recapRegenerateRpc } from "./shared/recap";
|
|
6
6
|
|
|
7
7
|
export default function contribute(client: PluginClientContext) {
|
|
8
|
-
const pills =
|
|
8
|
+
const pills = createRecapPills(client);
|
|
9
9
|
pills.start();
|
|
10
10
|
|
|
11
11
|
const removeTimelineRenderer = client.addTimelineRenderer({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "paseo-recap",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
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-
|
|
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-
|
|
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;
|
package/server/generators.ts
CHANGED
|
@@ -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
|
|
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);
|