@lincyaw/studio 0.2.0-rc.115 → 0.2.0-rc.116

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 CHANGED
@@ -17,7 +17,7 @@ Studio is included with Presmium. In a project with `pnpm add -D @lincyaw/presmi
17
17
 
18
18
  Sessions use the workspace root as their working directory and can read and write files throughout it. Opening another lecture changes document context, not the session or its directory.
19
19
 
20
- Local AI clients use native stdio, configured once as `presmium mcp <absolute-workspace-or-document-path>`. It starts or reuses the workspace authoring service before initialization. With default local listener settings, Studio can borrow a service already started by MCP; closing Studio leaves that service running. Keep the original owning stdio session open while using Studio: closing it ends the borrowed service and Studio. Studio does not migrate to a replacement host. Explicit `--host`, `--preview-port` or `--preview-url` settings require stopping the current service and starting Studio with those settings first. Older services lacking the separate launcher credential also require replacement before Studio can attach.
20
+ Local AI clients use native stdio, configured once as `presmium mcp <absolute-workspace-or-document-path>`. It starts or reuses a current workspace authoring service before initialization. With default local listeners, Studio shares only a matching runtime version. A newer launch requests a graceful handover from an older service, waits for in-flight operations and the workspace lease, and starts the current runtime. Stdio relays reconnect subsequent requests and notification subscriptions without replaying business requests. MCP-owned services run in separate child processes so a surviving relay cannot reload cached older modules. Closing Studio preserves a borrowed service; closing its owning stdio session ends that service and Studio. Explicit listener settings require a dedicated service. An older Studio cannot downgrade a newer running service.
21
21
 
22
22
  For Streamable HTTP clients, use the MCP URL and token-file path printed at startup and send `Authorization: Bearer <token>`. A service-state JSON file stores the credential in its `token` field; a plain token file contains it directly. Studio's own workspace service defaults to `http://127.0.0.1:4321/mcp` and preserves its credential for the same launch directory across restarts and upgrades. A borrowed service keeps its existing address and credential. With `--host 0.0.0.0`, use the printed network MCP address from other machines.
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lincyaw/studio",
3
- "version": "0.2.0-rc.115",
3
+ "version": "0.2.0-rc.116",
4
4
  "description": "presmium studio: Presmium's workbench on DeepSeek Harness in one command, with the workspace service of a directory (experimental)",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -39,10 +39,10 @@
39
39
  "@deepseek-ai/dsh": "0.2.1-alpha.4",
40
40
  "http-proxy-3": "2.0.1",
41
41
  "jiti": "^2.7.0",
42
- "@lincyaw/dsh": "0.2.0-rc.115",
43
- "@lincyaw/kernel": "1.0.0-rc.116"
42
+ "@lincyaw/dsh": "0.2.0-rc.116",
43
+ "@lincyaw/kernel": "1.0.0-rc.117"
44
44
  },
45
45
  "devDependencies": {
46
- "@lincyaw/cli": "1.0.0-rc.116"
46
+ "@lincyaw/cli": "1.0.0-rc.117"
47
47
  }
48
48
  }
package/src/messages.ts CHANGED
@@ -18,6 +18,7 @@ export interface StudioMessages {
18
18
  mcpToken(file: string): string
19
19
  badMcpToken(file: string): string
20
20
  existingService(url: string): string
21
+ serviceUpgrade(reason: 'busy' | 'newer' | 'unavailable', version?: string): string
21
22
  noFreePort(address: string): string
22
23
  badHost(address: string): string
23
24
  wholeLog(message: string, file: string): string
@@ -62,6 +63,7 @@ presmium-studio-<散列>.log(每个安装一个)保存在 $XDG_STATE_HOME/pr
62
63
  mcpToken: file => `presmium studio: HTTP MCP 客户端从 ${file} 读取访问令牌(server.json 使用 token 字段),设置 Authorization: Bearer <访问令牌>。本机客户端建议用 presmium mcp 自动发现服务。`,
63
64
  badMcpToken: file => `MCP 访问令牌文件 ${file} 无效。请移走该文件后重试,并在客户端更新访问令牌。`,
64
65
  existingService: url => `工作区服务已在 ${url} 运行。当前服务不支持复用,或指定的预览监听选项需要新服务;请先关闭它,再启动 Studio。`,
66
+ serviceUpgrade: (reason, version) => reason === 'busy' ? '工作区正在编辑或导出,请等待当前操作结束后重试升级。' : reason === 'newer' ? `工作区服务已运行更新版本 ${version},请升级当前 Presmium 后再打开。` : '无法自动切换旧版工作区服务,请关闭使用该工作区的旧版 Presmium 后重试。',
65
67
  noFreePort: address => `${address} 上没有空闲的端口。请停止占用端口的服务后重试。`,
66
68
  badHost: address => `--host 需要本机的一个 IP 地址,例如 192.168.0.21,也可以使用 0.0.0.0,而不是“${address}”。`,
67
69
  wholeLog: (message, file) => `${message}${message.endsWith('\n') ? '' : '。'}完整的日志在 ${file}`,
@@ -106,6 +108,7 @@ Options:
106
108
  mcpToken: file => `presmium studio: HTTP MCP clients read the access token from ${file} (the token field in server.json) and set Authorization: Bearer <value>. Local clients should use presmium mcp to discover the service automatically.`,
107
109
  badMcpToken: file => `MCP access token file ${file} is invalid. Move it aside and retry, then update the access token in your clients.`,
108
110
  existingService: url => `A workspace service is running at ${url}. It cannot be reused, or the explicit preview listener options require a new service; close it before starting Studio.`,
111
+ serviceUpgrade: (reason, version) => reason === 'busy' ? 'The workspace is being edited or exported. Wait for the current operation to finish, then retry the upgrade.' : reason === 'newer' ? `The workspace service runs the newer version ${version}. Update this Presmium before opening it.` : 'The older workspace service could not be replaced automatically. Close the older Presmium using this workspace, then retry.',
109
112
  noFreePort: address => `There is no free port on ${address}. Stop a service that uses one, then retry.`,
110
113
  badHost: address => `--host takes one local IP address, such as 192.168.0.21, or 0.0.0.0 to listen on all IPv4 network interfaces, not “${address}”.`,
111
114
  wholeLog: (message, file) => `${message.endsWith('\n') ? message : `${message}; `}the whole log is ${file}`,
package/src/studio.ts CHANGED
@@ -8,7 +8,7 @@ import { delimiter, dirname, join, resolve } from 'node:path'
8
8
  import { fileURLToPath } from 'node:url'
9
9
  import { bracketIPv6, dshBin, inheritedEnv, isLauncherVariable, launchArgs, launchEnv, launchNode, launchWorkspaceServer, WEB_READY, writeProfile } from '@lincyaw/dsh/launch'
10
10
  import type { LaunchedProcess } from '@lincyaw/dsh/launch'
11
- import { findWorkspaceServiceState, readServiceState, serveStateDir } from '@lincyaw/kernel/node'
11
+ import { compareServiceVersion, findWorkspaceServiceState, readServiceState, serveStateDir, SERVICE_VERSION, ServiceUpgradeError, upgradeWorkspaceService } from '@lincyaw/kernel/node'
12
12
  import { STUDIO_MESSAGES, systemLocale } from './messages.ts'
13
13
  import { modelEnv } from './model-env.ts'
14
14
  import { startProxy } from './proxy.ts'
@@ -225,6 +225,16 @@ export async function startStudio(options: StudioOptions): Promise<Studio> {
225
225
  let existing = findWorkspaceServiceState(options.dir, env)
226
226
  const canReuse = () => existing?.state.launcherToken && listenAddress === undefined && options.previewPort === undefined && options.previewUrl === undefined
227
227
  if (existing && !canReuse()) throw new Error(t.existingService(existing.state.url))
228
+ try {
229
+ while (existing && compareServiceVersion(existing.state, SERVICE_VERSION) !== 0) {
230
+ if (compareServiceVersion(existing.state, SERVICE_VERSION) > 0) throw new ServiceUpgradeError('newer', existing.state.version)
231
+ await upgradeWorkspaceService(existing.root, existing.state, SERVICE_VERSION, env)
232
+ existing = findWorkspaceServiceState(options.dir, env)
233
+ }
234
+ } catch (error) {
235
+ if (error instanceof ServiceUpgradeError) throw new Error(t.serviceUpgrade(error.reason, error.version))
236
+ throw error
237
+ }
228
238
  const wildcard = WILDCARD.test(boundAddress)
229
239
  // External MCP clients keep the default address, so it is preferred; an explicit port must be free.
230
240
  let previewPort = options.previewPort ?? DEFAULT_PREVIEW_PORT
@@ -305,6 +315,7 @@ export async function startStudio(options: StudioOptions): Promise<Studio> {
305
315
  if (!existing) await new Promise(done => setTimeout(done, 100))
306
316
  }
307
317
  if (!existing || !canReuse()) throw error
318
+ if (compareServiceVersion(existing.state, SERVICE_VERSION) !== 0) throw new Error(t.serviceUpgrade('unavailable'))
308
319
  serviceToken = existing.state.launcherToken!
309
320
  ready = { url: existing.state.url, root: existing.root }
310
321
  }