@lincyaw/studio 0.2.0-rc.122 → 0.2.0-rc.124

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lincyaw/studio",
3
- "version": "0.2.0-rc.122",
3
+ "version": "0.2.0-rc.124",
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/kernel": "1.0.0-rc.123",
43
- "@lincyaw/dsh": "0.2.0-rc.122"
42
+ "@lincyaw/dsh": "0.2.0-rc.124",
43
+ "@lincyaw/kernel": "1.0.0-rc.125"
44
44
  },
45
45
  "devDependencies": {
46
- "@lincyaw/cli": "1.0.0-rc.123"
46
+ "@lincyaw/cli": "1.0.0-rc.125"
47
47
  }
48
48
  }
package/src/cli.ts CHANGED
@@ -46,10 +46,10 @@ function watchParentPipe(onEnd: () => void): () => void {
46
46
  }
47
47
 
48
48
  export async function main(argv: string[], options: MainOptions = {}): Promise<number> {
49
- let values: { port?: string, host?: string, 'public-url'?: string, 'preview-url'?: string, 'preview-port'?: string, help?: boolean }
49
+ let values: { port?: string, host?: string, 'public-url'?: string, 'preview-url'?: string, 'preview-port'?: string, verbose?: boolean, help?: boolean }
50
50
  let dir: string
51
51
  try {
52
- const parsed = parseArgs({ args: argv, allowPositionals: true, options: { port: { type: 'string' }, host: { type: 'string' }, 'public-url': { type: 'string' }, 'preview-url': { type: 'string' }, 'preview-port': { type: 'string' }, help: { type: 'boolean', short: 'h' } } })
52
+ const parsed = parseArgs({ args: argv, allowPositionals: true, options: { port: { type: 'string' }, host: { type: 'string' }, 'public-url': { type: 'string' }, 'preview-url': { type: 'string' }, 'preview-port': { type: 'string' }, verbose: { type: 'boolean' }, help: { type: 'boolean', short: 'h' } } })
53
53
  values = parsed.values
54
54
  const [given = '.', ...extra] = parsed.positionals
55
55
  if (extra.length > 0) throw new Error(t.unexpectedArgument(extra[0]!))
@@ -76,18 +76,21 @@ export async function main(argv: string[], options: MainOptions = {}): Promise<n
76
76
  const unwatchParent = watchParentPipe(() => parentStop())
77
77
  let studio
78
78
  try {
79
- studio = await startStudio({ dir, port: portOf(values.port), onServiceOutput: text => process.stderr.write(text), ...values.host ? { listenAddress: values.host } : {}, ...values['public-url'] ? { publicUrl: urlOf('--public-url', values['public-url']) } : {}, ...values['preview-url'] ? { previewUrl: urlOf('--preview-url', values['preview-url']) } : {}, ...values['preview-port'] ? { previewPort: portOf(values['preview-port']) } : {}, ...options.presmium ? { presmium: options.presmium } : {} })
79
+ studio = await startStudio({ dir, port: portOf(values.port), ...values.verbose ? { onServiceOutput: (text: string) => void process.stderr.write(text) } : {}, ...values.host ? { listenAddress: values.host } : {}, ...values['public-url'] ? { publicUrl: urlOf('--public-url', values['public-url']) } : {}, ...values['preview-url'] ? { previewUrl: urlOf('--preview-url', values['preview-url']) } : {}, ...values['preview-port'] ? { previewPort: portOf(values['preview-port']) } : {}, ...options.presmium ? { presmium: options.presmium } : {} })
80
80
  } catch (error) {
81
81
  unwatchParent()
82
82
  process.stderr.write(`presmium studio: ${error instanceof Error ? error.message : String(error)}\n`)
83
83
  return 2
84
84
  }
85
+ // One address to open; the MCP address, its token and the log file only with --verbose (the log has them too).
85
86
  process.stdout.write(`studio ${studio.url}\n`)
86
87
  for (const url of studio.networkUrls) process.stdout.write(`network ${url}\n`)
87
- process.stdout.write(`mcp ${studio.mcp.url}\n`)
88
- process.stderr.write(`${t.mcpToken(studio.mcp.tokenFile)}\n`)
89
- if (studio.mcp.movedFrom) process.stderr.write(`${t.previewPortMoved(studio.mcp.movedFrom, studio.mcp.url)}\n`)
90
- process.stderr.write(`${t.log(studio.log)}\n`)
88
+ if (values.verbose) {
89
+ process.stdout.write(`mcp ${studio.mcp.url}\n`)
90
+ process.stderr.write(`${t.mcpToken(studio.mcp.tokenFile)}\n`)
91
+ if (studio.mcp.movedFrom) process.stderr.write(`${t.previewPortMoved(studio.mcp.movedFrom, studio.mcp.url)}\n`)
92
+ process.stderr.write(`${t.log(studio.log)}\n`)
93
+ } else process.stderr.write(`${t.open}\n`)
91
94
  if (values.host && values.host !== '127.0.0.1' && values.host !== '::1' && !values['public-url']) {
92
95
  process.stderr.write(`${studio.networkUrls.length
93
96
  ? t.openOnAllNetworks(new URL(studio.url).port, new URL(studio.workspaceServerUrl).port)
package/src/messages.ts CHANGED
@@ -9,6 +9,7 @@ export interface StudioMessages {
9
9
  unexpectedArgument(argument: string): string
10
10
  notDirectory(dir: string): string
11
11
  log(file: string): string
12
+ open: string
12
13
  openOnNetwork(address: string, port: string, previewPort: string): string
13
14
  openOnAllNetworks(port: string, previewPort: string): string
14
15
  ended(how: string, log: string): string
@@ -34,7 +35,8 @@ export const STUDIO_MESSAGES: Record<Locale, StudioMessages> = {
34
35
 
35
36
  启动 Presmium Studio(实验性):在浏览器中编辑这个目录(工作区的根目录或一份文稿所在的目录;
36
37
  默认为 .)中的文稿,并为它提供工作区服务。只打印一个要在浏览器中打开的网址。AI 助手所用的模型在
37
- “设置 → 模型”中设置,也可以由环境变量给出:DEEPSEEK_API_KEY,或者兼容 Messages 接口的服务的
38
+ “设置 → 模型”中设置,也可以由环境变量给出:DEEPSEEK_API_KEY(可加 DEEPSEEK_BASE_URL 与
39
+ DEEPSEEK_SEARCH_BASE_URL),或者兼容 Messages 接口的服务的
38
40
  PRESMIUM_MODEL_URL、PRESMIUM_MODEL_KEY 与 PRESMIUM_MODEL_PROVIDER。对话、模型设置、密钥与日志
39
41
  presmium-studio-<散列>.log(每个安装一个)保存在 $XDG_STATE_HOME/presmium/studio 中。
40
42
 
@@ -47,6 +49,7 @@ presmium-studio-<散列>.log(每个安装一个)保存在 $XDG_STATE_HOME/pr
47
49
  --preview-url <网址> 同样情况下预览所在的地址,由代理转发到工作区服务;可以带路径,
48
50
  此时它必须与 Studio 不同源,否则预览中文稿的代码能读到 Studio 的会话
49
51
  --preview-port <端口> 工作区服务与 HTTP MCP 的固定端口(默认 4321,被占用时换一个空闲端口);0 为随机端口
52
+ --verbose 另外打印 HTTP MCP 的地址与访问令牌文件、日志文件,并转发工作区服务的输出
50
53
  -h, --help 显示本说明`,
51
54
  badPort: value => `--port 需要 0 到 65535 之间的端口号,而不是“${value}”。`,
52
55
  badUrl: (option, value) => `${option} 需要一个完整的网址,例如 https://studio.example.com/,而不是“${value}”。`,
@@ -54,6 +57,7 @@ presmium-studio-<散列>.log(每个安装一个)保存在 $XDG_STATE_HOME/pr
54
57
  unexpectedArgument: argument => `多余的参数“${argument}”。只能给出一个目录。`,
55
58
  notDirectory: dir => `${dir} 不是目录。请给出工作区的根目录或一份文稿所在的目录。`,
56
59
  log: file => `presmium studio: 日志在 ${file}`,
60
+ open: 'presmium studio: 在浏览器中打开上面的网址。按 Ctrl+C 停止。',
57
61
  openOnNetwork: (address, port, previewPort) => `presmium studio: 正在 ${address} 上监听,局域网中的设备可以访问,且没有登录:任何能用上面的网址访问端口 ${port}(以及预览的端口 ${previewPort})的人都以你的身份使用这个工作区(编辑、运行代码、使用你的模型)。请只在可信的网络中使用;不加 --host 时只在本机监听。`,
58
62
  openOnAllNetworks: (port, previewPort) => `presmium studio: 正在全部局域网网络接口上监听,且没有登录:任何能用上面的网址访问端口 ${port}(以及预览的端口 ${previewPort})的人都以你的身份使用这个工作区(编辑、运行代码、使用你的模型)。请只在可信的网络中使用;不加 --host 时只在本机监听。`,
59
63
  ended: (how, log) => `presmium studio: ${how}。日志在 ${log}`,
@@ -77,8 +81,8 @@ presmium-studio-<散列>.log(每个安装一个)保存在 $XDG_STATE_HOME/pr
77
81
  Presmium Studio (experimental): edit the documents of the directory (the workspace root, or a deck’s
78
82
  directory; default: .) in the browser, with the workspace service of that directory. It prints the one
79
83
  address to open in the browser. The AI Assistant’s model is chosen in Settings > Models, or given by the
80
- environment: DEEPSEEK_API_KEY, or PRESMIUM_MODEL_URL, PRESMIUM_MODEL_KEY, and PRESMIUM_MODEL_PROVIDER
81
- for a Messages-compatible service. Chats, model settings, API keys, and the log
84
+ environment: DEEPSEEK_API_KEY (with DEEPSEEK_BASE_URL and DEEPSEEK_SEARCH_BASE_URL if needed), or
85
+ PRESMIUM_MODEL_URL, PRESMIUM_MODEL_KEY, and PRESMIUM_MODEL_PROVIDER for a Messages-compatible service. Chats, model settings, API keys, and the log
82
86
  presmium-studio-<hash>.log (one per installation) are kept in $XDG_STATE_HOME/presmium/studio.
83
87
 
84
88
  Options:
@@ -92,6 +96,7 @@ Options:
92
96
  may have a path, and should be another origin than Studio’s, or the documents’ code in
93
97
  previews can read Studio’s session
94
98
  --preview-port <n> fixed workspace-service and HTTP MCP port (default: 4321, or a free one when that is in use); 0 requests a random port
99
+ --verbose also print the HTTP MCP address, its access token file and the log file, and pass on the workspace service’s output
95
100
  -h, --help show this help`,
96
101
  badPort: value => `--port takes a port number from 0 to 65535, not “${value}”.`,
97
102
  badUrl: (option, value) => `${option} takes a full address, such as https://studio.example.com/, not “${value}”.`,
@@ -99,6 +104,7 @@ Options:
99
104
  unexpectedArgument: argument => `Unexpected argument “${argument}”. Give one directory.`,
100
105
  notDirectory: dir => `${dir} is not a directory. Give the workspace root, or the directory of a document.`,
101
106
  log: file => `presmium studio: log ${file}`,
107
+ open: 'presmium studio: open the address above in your browser. Press Ctrl+C to stop.',
102
108
  openOnNetwork: (address, port, previewPort) => `presmium studio: listening on ${address}, on the local network, with no login: anyone who reaches port ${port} (and the previews’ port ${previewPort}) with the address above works in this workspace as you (edits, runs code, uses your model). Use it on a network you trust; without --host it listens on this machine only.`,
103
109
  openOnAllNetworks: (port, previewPort) => `presmium studio: listening on all local network interfaces, with no login: anyone who reaches port ${port} (and the previews’ port ${previewPort}) with the addresses above works in this workspace as you (edits, runs code, uses your model). Use it on a network you trust; without --host it listens on this machine only.`,
104
110
  ended: (how, log) => `presmium studio: ${how}; the log is ${log}`,
package/src/model-env.ts CHANGED
@@ -12,12 +12,14 @@ const searchUrl = (url: string) => `${url.replace(/\/+$/, '').replace(/\/v1$/, '
12
12
 
13
13
  const deepseekEndpoints = (url: string) => ({ DEEPSEEK_BASE_URL: url, DEEPSEEK_SEARCH_BASE_URL: searchUrl(url) })
14
14
 
15
+ /** DeepSeek Harness's own provider variables, passed on as the launching shell sets them. */
16
+ export const DEEPSEEK_VARIABLES = ['DEEPSEEK_API_KEY', 'DEEPSEEK_BASE_URL', 'DEEPSEEK_SEARCH_BASE_URL'] as const
17
+
15
18
  export function modelEnv(env: NodeJS.ProcessEnv): ModelEnv {
16
19
  const [url, key, provider] = MODEL_VARIABLES.map(name => env[name]?.trim() || undefined)
17
20
  if (url && key && provider) return { env: { ...deepseekEndpoints(url), DEEPSEEK_API_KEY: key }, from: [...MODEL_VARIABLES] }
18
21
  const unset = MODEL_VARIABLES.filter((_, i) => ![url, key, provider][i])
19
22
  const warning = unset.length < MODEL_VARIABLES.length ? { warning: STUDIO_MESSAGES[systemLocale(env)].modelVariables(MODEL_VARIABLES, unset) } : {}
20
- const deepseek = env.DEEPSEEK_API_KEY?.trim()
21
- if (deepseek) return { env: { DEEPSEEK_API_KEY: deepseek }, from: ['DEEPSEEK_API_KEY'], ...warning }
22
- return { env: {}, from: [], ...warning }
23
+ const given = DEEPSEEK_VARIABLES.flatMap(name => env[name]?.trim() ? [[name, env[name]!.trim()] as const] : [])
24
+ return { env: Object.fromEntries(given), from: given.map(([name]) => name), ...warning }
23
25
  }
package/src/studio.ts CHANGED
@@ -10,7 +10,7 @@ import { bracketIPv6, dshBin, inheritedEnv, isLauncherVariable, launchArgs, laun
10
10
  import type { LaunchedProcess } from '@lincyaw/dsh/launch'
11
11
  import { compareServiceVersion, findWorkspaceServiceState, readServiceState, serveStateDir, SERVICE_VERSION, ServiceUpgradeError, upgradeWorkspaceService } from '@lincyaw/kernel/node'
12
12
  import { STUDIO_MESSAGES, systemLocale } from './messages.ts'
13
- import { modelEnv } from './model-env.ts'
13
+ import { DEEPSEEK_VARIABLES, modelEnv } from './model-env.ts'
14
14
  import { startProxy } from './proxy.ts'
15
15
  import type { Proxy } from './proxy.ts'
16
16
 
@@ -353,7 +353,7 @@ export async function startStudio(options: StudioOptions): Promise<Studio> {
353
353
  ], {
354
354
  cwd: root,
355
355
  env: {
356
- ...inheritedEnv(env, name => isLauncherVariable(name) || ['DEEPSEEK_API_KEY', 'DEEPSEEK_BASE_URL', 'DEEPSEEK_SEARCH_BASE_URL'].includes(name)),
356
+ ...inheritedEnv(env, name => isLauncherVariable(name) || (DEEPSEEK_VARIABLES as readonly string[]).includes(name)),
357
357
  ...modelEnv(env).env,
358
358
  ...launchEnv(home, env),
359
359
  PRESMIUM_COMMAND: presmium,