opencode-auto-rename 1.1.0 → 1.2.0

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.
Files changed (2) hide show
  1. package/dist/index.js +16 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,14 +1,15 @@
1
1
  /**
2
2
  * Auto-Rename Plugin
3
3
  *
4
- * Automatically renames conversations based on their content.
5
- * Renames on the first assistant response, then periodically re-renames
6
- * if at least 5 minutes have passed since the last rename to keep the
7
- * title relevant as the conversation evolves.
4
+ * Periodically re-renames conversations to keep the title relevant as
5
+ * the conversation evolves. Skips the first idle event (OpenCode already
6
+ * names the session initially) and only renames after 5+ minutes have
7
+ * passed since the session was first seen.
8
8
  */
9
9
  const RENAME_INTERVAL_MS = 5 * 60 * 1000; // 5 minutes
10
10
  export const AutoRenamePlugin = async ({ client }) => {
11
- // Track the last rename timestamp per session
11
+ // Track the first seen and last renamed timestamps per session
12
+ const firstSeen = new Map();
12
13
  const lastRenamed = new Map();
13
14
  return {
14
15
  event: async ({ event }) => {
@@ -18,9 +19,17 @@ export const AutoRenamePlugin = async ({ client }) => {
18
19
  if (!sessionId)
19
20
  return;
20
21
  const now = Date.now();
22
+ // Record when we first see a session and skip it —
23
+ // OpenCode already handles the initial naming.
24
+ if (!firstSeen.has(sessionId)) {
25
+ firstSeen.set(sessionId, now);
26
+ return;
27
+ }
28
+ // Only rename if enough time has passed since we first saw it
29
+ // or since the last rename
21
30
  const lastRenamedAt = lastRenamed.get(sessionId);
22
- // Skip if we renamed this session recently (within the interval)
23
- if (lastRenamedAt && now - lastRenamedAt < RENAME_INTERVAL_MS)
31
+ const baseline = lastRenamedAt ?? firstSeen.get(sessionId);
32
+ if (now - baseline < RENAME_INTERVAL_MS)
24
33
  return;
25
34
  try {
26
35
  // Check that there is at least one assistant message
@@ -31,7 +40,6 @@ export const AutoRenamePlugin = async ({ client }) => {
31
40
  if (!hasAssistantMessage)
32
41
  return;
33
42
  // Use the built-in summarize endpoint to generate a title.
34
- // Omitting body lets OpenCode use the default model.
35
43
  await client.session.summarize({
36
44
  path: { id: sessionId },
37
45
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-auto-rename",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "OpenCode plugin that automatically renames conversations based on their content",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",