From 5c50edb9bbd149593fc4f8e49858398a6f7fdadd Mon Sep 17 00:00:00 2001 From: Filip <34747899+neriousy@users.noreply.github.com> Date: Mon, 7 Sep 2026 20:38:26 +0200 Subject: [PATCH] feat(core): expose session rename tool (#47837) --- packages/core/src/tool/plugin/opencode.ts | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/core/src/tool/plugin/opencode.ts b/packages/core/src/tool/plugin/opencode.ts index 17356f97350..d43e6c087dd 100644 --- a/packages/core/src/tool/plugin/opencode.ts +++ b/packages/core/src/tool/plugin/opencode.ts @@ -6,6 +6,13 @@ import { AbsolutePath } from "@opencode-ai/schema/schema" import { Session } from "@opencode-ai/schema/session" import { Effect, Schema } from "effect" +export const RenameInput = Schema.Struct({ + sessionID: Schema.optionalKey(Session.ID).annotate({ description: "Omit to rename the current session." }), + title: Schema.String.check(Schema.isMinLength(1)).annotate({ description: "New session title." }), +}) + +const RenameOutput = Schema.Struct({ sessionID: Session.ID, title: Schema.String }) + export const MoveInput = Schema.Struct({ sessionID: Schema.optionalKey(Session.ID).annotate({ description: "Omit to move the current session." }), directory: AbsolutePath.check(Schema.isMinLength(1)).annotate({ @@ -30,6 +37,26 @@ export const Plugin = { yield* ctx.tool .transform((draft) => { draft.namespace({ name: "opencode", description: "OpenCode session and runtime tools." }) + draft.add({ + name: "session_rename", + description: + "Rename a session, or omit sessionID to rename the current session. Use a short, specific title that summarizes the work being done.", + input: RenameInput, + output: RenameOutput, + options: { namespace: "opencode", codemode: true }, + execute: (input, context) => { + const sessionID = input.sessionID ?? context.sessionID + const title = input.title.trim() + if (!title) return Effect.fail(new ToolFailure({ message: "Session title must not be empty" })) + return ctx.session.rename({ sessionID, title }).pipe( + Effect.as({ + output: { sessionID, title }, + content: `Renamed session ${sessionID} to ${title}.`, + }), + Effect.mapError((error) => new ToolFailure({ message: `Unable to rename session ${sessionID}`, error })), + ) + }, + }) draft.add({ name: "session_move", description: