From bc4387e2de1c3356ec7399960b7fffeed195f8fc Mon Sep 17 00:00:00 2001 From: Makito Date: Sat, 28 Feb 2026 01:22:11 +0700 Subject: [PATCH] fix(plugin-host): persist session cwd and explicitly assign default --- packages/plugin-sdk/src/plugin-host/core.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/plugin-sdk/src/plugin-host/core.ts b/packages/plugin-sdk/src/plugin-host/core.ts index ba14ed14f..cee77c4c2 100644 --- a/packages/plugin-sdk/src/plugin-host/core.ts +++ b/packages/plugin-sdk/src/plugin-host/core.ts @@ -422,6 +422,7 @@ export interface PluginHostSession { plugin: Plugin id: string index: number + cwd: string identity: ModuleIdentity phase: PluginSessionPhase lifecycle: ActorRefFrom @@ -482,6 +483,7 @@ export class PluginHost { async load(manifest: ManifestV1, options: PluginLoadOptions = {}): Promise { // Step 0 (channel gateway preparation): resolve runtime and transport for this plugin. const runtime = options.runtime ?? this.runtime + const sessionCwd = options.cwd ?? cwd() // Explicitly assign the default CWD. const transport = this.transport // TODO: implement other transports and runtime bindings. @@ -519,6 +521,7 @@ export class PluginHost { plugin: {}, id, index: sessionIndex, + cwd: sessionCwd, identity, phase: lifecycle.getSnapshot().value as PluginSessionPhase, lifecycle, @@ -537,7 +540,7 @@ export class PluginHost { // Load plugin module from manifest-selected runtime entrypoint. // This is where malformed entrypoints or import errors surface. session.plugin = await this.loader.loadPluginFor(manifest, { - cwd: options.cwd, + cwd: sessionCwd, runtime, }) @@ -906,11 +909,10 @@ export class PluginHost { } const manifest = previous.manifest - const cwdValue = options.cwd this.stop(sessionId) return this.start(manifest, { ...options, - cwd: cwdValue, + cwd: options.cwd ?? previous.cwd, runtime: options.runtime ?? previous.runtime, }) }