@mtayfur/opencode-session-recap 1.0.2 → 1.0.3
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/README.md +11 -32
- package/dist/index.js +3 -49
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
- Generates a readable recap of up to 1,000 characters after 10 minutes of inactivity.
|
|
8
8
|
- Shows the recap in a large dialog without adding it to the transcript or future model context.
|
|
9
|
-
- Regenerates the recap on demand with `/recap`.
|
|
10
9
|
- Re-evaluates the session title every 20 user messages and after recap generation.
|
|
11
10
|
- Keeps the current title when the dominant topic has not changed.
|
|
12
11
|
- Stops automatic title changes after a manual rename is detected.
|
|
@@ -15,37 +14,28 @@
|
|
|
15
14
|
## Requirements
|
|
16
15
|
|
|
17
16
|
- OpenCode `1.18.16` or a compatible newer 1.x release
|
|
18
|
-
- Bun `1.3.14` or newer for local development
|
|
19
17
|
|
|
20
18
|
## Installation
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```json
|
|
25
|
-
{
|
|
26
|
-
"plugin": ["@mtayfur/opencode-session-recap"]
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Restart OpenCode after changing the configuration.
|
|
31
|
-
|
|
32
|
-
### Local checkout
|
|
33
|
-
|
|
34
|
-
Install and register the local build:
|
|
20
|
+
Install the plugin globally with OpenCode:
|
|
35
21
|
|
|
36
22
|
```sh
|
|
37
|
-
|
|
23
|
+
opencode plugin @mtayfur/opencode-session-recap --global
|
|
38
24
|
```
|
|
39
25
|
|
|
40
|
-
|
|
26
|
+
Restart OpenCode after installation.
|
|
41
27
|
|
|
42
|
-
|
|
28
|
+
### Manual configuration
|
|
43
29
|
|
|
44
|
-
|
|
45
|
-
|
|
30
|
+
Alternatively, add the package to `~/.config/opencode/tui.json`:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"plugin": ["@mtayfur/opencode-session-recap"]
|
|
35
|
+
}
|
|
46
36
|
```
|
|
47
37
|
|
|
48
|
-
Restart OpenCode after
|
|
38
|
+
Restart OpenCode after changing the configuration.
|
|
49
39
|
|
|
50
40
|
## Configuration
|
|
51
41
|
|
|
@@ -77,14 +67,3 @@ Restart OpenCode after rebuilding or changing the plugin configuration.
|
|
|
77
67
|
```
|
|
78
68
|
|
|
79
69
|
When a model is not set, title and recap generation use OpenCode's `small_model`.
|
|
80
|
-
|
|
81
|
-
## Development
|
|
82
|
-
|
|
83
|
-
From the repository root:
|
|
84
|
-
|
|
85
|
-
```sh
|
|
86
|
-
bun install --frozen-lockfile
|
|
87
|
-
bun run --filter @mtayfur/opencode-session-recap typecheck
|
|
88
|
-
bun run --filter @mtayfur/opencode-session-recap build
|
|
89
|
-
npm pack ./packages/session-recap --dry-run
|
|
90
|
-
```
|
package/dist/index.js
CHANGED
|
@@ -521,7 +521,7 @@ ${fullConversation.slice(-MAX_CONVERSATION_CHARS)}` : fullConversation;
|
|
|
521
521
|
showRecapDialog(state.recap);
|
|
522
522
|
return true;
|
|
523
523
|
}
|
|
524
|
-
async function generateRecap(sessionID
|
|
524
|
+
async function generateRecap(sessionID) {
|
|
525
525
|
if (!configuration.recap.enabled)
|
|
526
526
|
return "unavailable";
|
|
527
527
|
const loaded = await loadTranscript(sessionID);
|
|
@@ -529,7 +529,7 @@ ${fullConversation.slice(-MAX_CONVERSATION_CHARS)}` : fullConversation;
|
|
|
529
529
|
if (!transcript)
|
|
530
530
|
return "empty";
|
|
531
531
|
const state = readRecapState(loaded.session);
|
|
532
|
-
if (
|
|
532
|
+
if (state.recapSourceKey === transcript.sourceKey)
|
|
533
533
|
return "unchanged";
|
|
534
534
|
const model = resolveModel("recap");
|
|
535
535
|
if (!model)
|
|
@@ -562,7 +562,7 @@ ${fullConversation.slice(-MAX_CONVERSATION_CHARS)}` : fullConversation;
|
|
|
562
562
|
const timer = setTimeout(() => {
|
|
563
563
|
idleTimers.delete(sessionID);
|
|
564
564
|
enqueue(sessionID, async () => {
|
|
565
|
-
const result = await generateRecap(sessionID
|
|
565
|
+
const result = await generateRecap(sessionID);
|
|
566
566
|
if (result === "generated" && currentSessionID(api) === sessionID) {
|
|
567
567
|
await showStoredRecap(sessionID);
|
|
568
568
|
}
|
|
@@ -583,51 +583,6 @@ ${fullConversation.slice(-MAX_CONVERSATION_CHARS)}` : fullConversation;
|
|
|
583
583
|
manualTitle: true
|
|
584
584
|
});
|
|
585
585
|
}
|
|
586
|
-
const disposeCommand = api.keymap.registerLayer({
|
|
587
|
-
commands: [{
|
|
588
|
-
namespace: "palette",
|
|
589
|
-
name: "opencode-session-recap.generate",
|
|
590
|
-
title: "Generate Session Recap",
|
|
591
|
-
desc: "Generate or refresh a context-free recap of the current session",
|
|
592
|
-
category: "OpenCode Session Recap",
|
|
593
|
-
slashName: "recap",
|
|
594
|
-
suggested: () => currentSessionID(api) !== undefined,
|
|
595
|
-
enabled: () => currentSessionID(api) !== undefined,
|
|
596
|
-
run: () => {
|
|
597
|
-
const sessionID = currentSessionID(api);
|
|
598
|
-
if (!sessionID)
|
|
599
|
-
return;
|
|
600
|
-
clearIdleTimer(sessionID);
|
|
601
|
-
enqueue(sessionID, async () => {
|
|
602
|
-
let result;
|
|
603
|
-
try {
|
|
604
|
-
result = await generateRecap(sessionID, true);
|
|
605
|
-
} catch (error) {
|
|
606
|
-
console.warn(`[opencode-session-recap] recap generation failed: ${errorMessage(error)}`);
|
|
607
|
-
result = "failed";
|
|
608
|
-
}
|
|
609
|
-
if (result === "generated" && await showStoredRecap(sessionID)) {
|
|
610
|
-
scheduleIdleRecap(sessionID);
|
|
611
|
-
return;
|
|
612
|
-
}
|
|
613
|
-
const messages = {
|
|
614
|
-
generated: "Recap was generated but could not be displayed.",
|
|
615
|
-
unchanged: "Recap skipped because the session changed while it was generated.",
|
|
616
|
-
empty: "No conversation found to recap.",
|
|
617
|
-
unavailable: "OpenCode small_model is not configured.",
|
|
618
|
-
failed: "Could not generate recap; details were written to the log."
|
|
619
|
-
};
|
|
620
|
-
api.ui.toast({
|
|
621
|
-
title: "OpenCode Session Recap",
|
|
622
|
-
message: messages[result],
|
|
623
|
-
variant: result === "failed" ? "warning" : "info"
|
|
624
|
-
});
|
|
625
|
-
scheduleIdleRecap(sessionID);
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
}],
|
|
629
|
-
bindings: []
|
|
630
|
-
});
|
|
631
586
|
const disposeMessage = api.event.on("message.updated", (event) => {
|
|
632
587
|
const sessionID = event.properties.info.sessionID;
|
|
633
588
|
if (!helperSessions.has(sessionID))
|
|
@@ -663,7 +618,6 @@ ${fullConversation.slice(-MAX_CONVERSATION_CHARS)}` : fullConversation;
|
|
|
663
618
|
disposeUpdated();
|
|
664
619
|
disposeIdle();
|
|
665
620
|
disposeMessage();
|
|
666
|
-
disposeCommand();
|
|
667
621
|
});
|
|
668
622
|
};
|
|
669
623
|
var src_default = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@mtayfur/opencode-session-recap",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"description": "Context-free session recaps and topic-aware title refreshes for the OpenCode TUI.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|