@lincyaw/cli 1.0.0-rc.15 → 1.0.0-rc.16

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/cli",
3
- "version": "1.0.0-rc.15",
3
+ "version": "1.0.0-rc.16",
4
4
  "description": "The presmium command: build, dev, ir, check and serve for Presmium documents",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -36,10 +36,10 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "jiti": "^2.7.0",
39
- "@lincyaw/compiler": "1.0.0-rc.15",
40
- "@lincyaw/kernel": "1.0.0-rc.15",
41
- "@lincyaw/workspace": "1.0.0-rc.15",
42
- "@lincyaw/server": "1.0.0-rc.15",
43
- "@lincyaw/skills": "1.0.0-rc.15"
39
+ "@lincyaw/kernel": "1.0.0-rc.16",
40
+ "@lincyaw/server": "1.0.0-rc.16",
41
+ "@lincyaw/skills": "1.0.0-rc.16",
42
+ "@lincyaw/workspace": "1.0.0-rc.16",
43
+ "@lincyaw/compiler": "1.0.0-rc.16"
44
44
  }
45
45
  }
package/src/cli.ts CHANGED
@@ -6,7 +6,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url'
6
6
  import { parseArgs } from 'node:util'
7
7
  import { createJiti } from 'jiti'
8
8
  import { APPROVAL_KINDS, errorMessage } from '@lincyaw/kernel'
9
- import { bracketIPv6, ffmpegInstallCommand, findFfmpeg, irRevision, lanAddresses } from '@lincyaw/kernel/node'
9
+ import { bracketIPv6, irRevision, lanAddresses } from '@lincyaw/kernel/node'
10
10
  import type { ApprovalKind, Finding, Severity } from '@lincyaw/kernel'
11
11
  import { build, Compiler, dev, resolveEntry } from '@lincyaw/compiler'
12
12
  import type { BuildReport, Compilation, RunStats } from '@lincyaw/compiler'
@@ -36,7 +36,7 @@ const OPTIONS = {
36
36
  'dev': ['to', 'out', 'server-port', 'allow'],
37
37
  'ir': ['out'],
38
38
  'check': ['json', 'update-lock', 'env', 'audience', 'external-links'],
39
- 'serve': ['port', 'host', 'operator-dir', 'preview-origin', 'public-url'],
39
+ 'serve': ['port', 'host', 'operator-dir', 'preview-origin', 'public-url', 'allow'],
40
40
  } as const
41
41
 
42
42
  type Name = keyof typeof OPTIONS
@@ -66,6 +66,7 @@ export async function main(argv: string[], options: MainOptions = {}): Promise<n
66
66
  if (argv[0] === 'new') return runNewCommand(argv.slice(1), bundled)
67
67
  if (argv[0] === 'skills') return (await import('@lincyaw/skills')).main(argv.slice(1))
68
68
  if (argv[0] === 'studio') return runStudioCommand(argv.slice(1), bundled, options.bin ?? PRESMIUM_BIN)
69
+ if (argv[0] === 'mcp') return runMcpCommand(argv.slice(1), bundled)
69
70
  let command: Command | 'help'
70
71
  try {
71
72
  command = parseCommand(argv)
@@ -289,12 +290,12 @@ async function runServeCommand(command: Command, bundled: string): Promise<numbe
289
290
  check: compilation => compilation.check(),
290
291
  previewOrigins: command.previewOrigins,
291
292
  ...command.publicUrl ? { publicUrl: command.publicUrl } : {},
293
+ allow: command.allow,
292
294
  })
293
295
  process.stdout.write(`serve ${started.url}\n${networkLines(command.listenAddress, started.url)}workspace ${started.root}\nmcp ${started.mcp.url}${t.token(started.mcp.stateFile)}\n`)
294
296
  if (command.listenAddress && !isLoopback(command.listenAddress)) {
295
297
  process.stderr.write(`${t.serveOpen(command.listenAddress, new URL(started.url).port)}\n`)
296
298
  }
297
- if (!findFfmpeg()) process.stderr.write(`${t.noFfmpeg(ffmpegInstallCommand())}\n`)
298
299
  await new Promise<void>((done) => {
299
300
  process.once('SIGINT', done)
300
301
  process.once('SIGTERM', done)
@@ -333,6 +334,18 @@ async function runStudioCommand(argv: string[], bundled: string, presmiumBin: st
333
334
  return studioMain(argv, { presmium: presmiumBin })
334
335
  }
335
336
 
337
+ /** MCP on stdio, from the installed `@lincyaw/mcp`; stdout carries only its messages. */
338
+ async function runMcpCommand(argv: string[], bundled: string): Promise<number> {
339
+ const entry = resolveInstalled('@lincyaw/mcp/cli', bundled)
340
+ if (!entry) {
341
+ process.stderr.write(`${t.mcpMissing}\n`)
342
+ return 2
343
+ }
344
+ console.log = console.info = console.debug = console.error
345
+ const { main: mcpMain } = await createJiti(import.meta.url).import<{ main(argv: string[], options: { bundled: string }): Promise<number | undefined> }>(entry)
346
+ return await mcpMain(argv, { bundled }) ?? 0
347
+ }
348
+
336
349
  function networkLines(listenAddress: string | undefined, url: string): string {
337
350
  if (!listenAddress || isLoopback(listenAddress)) return ''
338
351
  const { port } = new URL(url)
package/src/messages.ts CHANGED
@@ -24,9 +24,9 @@ export interface CliMessages {
24
24
  token(file: string): string
25
25
  watching(ir: string): string
26
26
  serveOpen(address: string, port: string): string
27
- noFfmpeg(command: string): string
28
27
  newMissing: string
29
28
  studioMissing: string
29
+ mcpMissing: string
30
30
  noProblems: string
31
31
  counts(errors: number, warnings: number, infos: number): string
32
32
  severity: Record<'error' | 'warning' | 'info', string>
@@ -53,6 +53,7 @@ export const CLI_MESSAGES: Record<Locale, CliMessages> = {
53
53
  skills 安装内置技能(与 MCP 和可视化编辑器共用)
54
54
  install <目录> [--json] 安装缺少的 .agents/skills,保留已有技能
55
55
  --name <技能> 只安装指定技能,可重复
56
+ --update 把已有的技能换成这个版本的(升级 Presmium 之后)
56
57
  --json 以 JSON 打印安装结果
57
58
  build 导出文稿:写出 <输出>/ir.json 与 <输出>/<形态>/;在工作区的根目录
58
59
  (有 presmium.workspace.yaml)把整个工作区导出为网站,写到 <输出>/web/
@@ -86,6 +87,11 @@ export const CLI_MESSAGES: Record<Locale, CliMessages> = {
86
87
  工作区的路由要求它(Authorization: Bearer)
87
88
  --public-url <网址> 反向代理在前面时浏览器使用的地址:信任它的主机,预览与产物
88
89
  的地址用它给出;带路径时代理原样转发该路径,服务的全部内容都在它下面
90
+ --allow <种类> 无需询问即允许的操作:operate、spend、write、agent(默认在打开的
91
+ Presmium 窗口中询问)
92
+ mcp 以标准输入输出提供 MCP 服务,供 Claude Code、Codex 等 AI 工具连接:这个目录的
93
+ Presmium Studio 或 presmium serve 正在运行时转接到它,AI 可以修改文稿;否则只编译
94
+ 文稿,提供阅读、检查与导出。详见 presmium mcp --help
89
95
  studio 启动 Presmium Studio(实验性):浏览器中的编辑应用与这个目录(工作区的
90
96
  根目录或一份文稿)的工作区服务,只打印一个要打开的网址。随 Presmium 一起安装
91
97
  --port <端口> Presmium Studio 的端口(默认为 4320,被占用时取空闲端口)
@@ -112,10 +118,10 @@ export const CLI_MESSAGES: Record<Locale, CliMessages> = {
112
118
  compiled: (sections, summary) => `已更新 ${sections} 个页面;${summary}`,
113
119
  token: file => ` (访问令牌在 ${file} 中)`,
114
120
  watching: ir => `正在监视修改;运行快照在 ${ir}`,
115
- noFfmpeg: command => `presmium serve: 没有找到 FFmpeg,讲授视频只能由浏览器导出为 WebM,画质较低。安装后可导出清晰的 MP4:${command}`,
116
121
  serveOpen: (address, port) => `presmium serve: 正在 ${address} 上监听,局域网中的设备可以访问,且没有登录:任何能访问端口 ${port} 的人都以你的身份使用这个工作区(编辑、运行代码、允许操作)。请只在可信的网络中使用;不加 --host 时只在本机监听。`,
117
122
  newMissing: 'presmium new: 没有安装 create-presmium。它随 presmium 一起安装,请运行 pnpm add -g @lincyaw/presmium。',
118
123
  studioMissing: 'presmium studio: 没有安装 Presmium Studio。它随 Presmium 一起安装,请运行 pnpm add -g @lincyaw/presmium。',
124
+ mcpMissing: 'presmium mcp: 没有安装 @lincyaw/mcp。它随 Presmium 一起安装,请运行 pnpm add -g @lincyaw/presmium。',
119
125
  noProblems: '没有问题',
120
126
  counts: (errors, warnings, infos) => `${errors} 个错误,${warnings} 个警告,${infos} 条信息`,
121
127
  severity: { error: '错误', warning: '警告', info: '信息' },
@@ -140,6 +146,7 @@ Commands:
140
146
  skills install bundled skills, shared with MCP and the visual editor
141
147
  install <dir> [--json] install missing .agents/skills; keep existing skills
142
148
  --name <skill> install only the named skill; repeat for more
149
+ --update replace the existing skills with this version's (after upgrading Presmium)
143
150
  --json print the installation result as JSON
144
151
  build export the deck: writes <out>/ir.json and <out>/<renderer>/; at a workspace root
145
152
  (presmium.workspace.yaml) exports the workspace as a website into <out>/web/
@@ -174,6 +181,11 @@ Commands:
174
181
  --public-url <url> the address browsers use when a reverse proxy fronts the service: its
175
182
  host is trusted, and previews and outputs are linked under it; with a path, the
176
183
  proxy forwards that path unchanged and everything the service serves is below it
184
+ --allow <kinds> approvals given without asking: operate, spend, write, agent (by default
185
+ they are asked in an open Presmium window)
186
+ mcp MCP on stdio for AI tools such as Claude Code and Codex: relays to the running Presmium
187
+ Studio or presmium serve of the directory, where the AI can edit documents; otherwise it
188
+ compiles the document for reading, checking and exporting. See presmium mcp --help
177
189
  studio Presmium Studio (experimental): the editing app in the browser and the workspace service
178
190
  of the directory (the workspace root, or a deck); prints the one address to open.
179
191
  Included with Presmium
@@ -201,10 +213,10 @@ Exit Codes: 0 no errors, 1 error findings, 2 usage or internal error.`,
201
213
  compiled: (sections, summary) => `compiled ${sections} sections; ${summary}`,
202
214
  token: file => ` (its token is in ${file})`,
203
215
  watching: ir => `watching; runtime snapshot in ${ir}`,
204
- noFfmpeg: command => `presmium serve: FFmpeg was not found, so lecture videos export from the browser as WebM, at a lower quality. Install it for sharp MP4 videos: ${command}`,
205
216
  serveOpen: (address, port) => `presmium serve: listening on ${address}, on the local network, with no login: anyone who reaches port ${port} uses this workspace as you (edits, runs code, approves). Use it on a network you trust; without --host it listens on this machine only.`,
206
217
  newMissing: 'presmium new: create-presmium is not installed. It comes with the presmium package: run pnpm add -g @lincyaw/presmium.',
207
218
  studioMissing: 'presmium studio: Presmium Studio is not installed. It comes with Presmium: run pnpm add -g @lincyaw/presmium.',
219
+ mcpMissing: 'presmium mcp: @lincyaw/mcp is not installed. It comes with Presmium: run pnpm add -g @lincyaw/presmium.',
208
220
  noProblems: 'no problems',
209
221
  counts: (errors, warnings, infos) => `${errors} errors, ${warnings} warnings, ${infos} infos`,
210
222
  severity: { error: 'error', warning: 'warning', info: 'info' },