md-review-server 0.1.0 → 0.1.2

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
@@ -1,13 +1,152 @@
1
1
  # md-review-server
2
2
 
3
- 简体中文 | [日本語](./README-ja.md)
3
+ [![npm version](https://img.shields.io/npm/v/md-review-server.svg)](https://www.npmjs.com/package/md-review-server)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](./LICENSE)
5
+ [![GitHub](https://img.shields.io/badge/GitHub-md--review--server-black.svg)](https://github.com/tracyxiong1/md-review-server)
4
6
 
5
7
  ![demo](./assets/demo.gif)
6
8
 
7
- `md-review-server` 是一个本地 Markdown 可视化评审服务。它保留 `md-review` 的 Markdown 预览、选区评论、评论列表和文件树能力,并将评论存储迁移到 sidecar review 文件,同时提供本地 HTTP API,供 Codex、其他 agent 或脚本读取评论并回写处理状态。
9
+ `md-review-server` 是面向 Codex 的本地 Markdown 可视化评审工具。
8
10
 
9
- ## 功能
11
+ Codex 中,纯对话方式适合提出整体修改要求,但不方便对长文中的具体文本进行圈选和批注。`md-review-server` 提供浏览器评审页面和 `markdown-review-loop` skill,让用户可以在浏览器中阅读 Markdown、留下局部评论,再由 Codex 根据评论生成下一版文档,形成“批注 -> 修订 -> 再评审”的迭代流程。
10
12
 
13
+ ## 使用场景
14
+
15
+ - 需要在浏览器里阅读 Markdown,并对具体段落做批注。
16
+ - 需要让 Codex 根据批注生成下一版文档。
17
+ - 需要对技术方案、README、机制说明、复盘草稿做多轮修改。
18
+ - 需要保留 `v1`、`v2`、`v3` 等多个版本,方便回看每轮改动。
19
+
20
+ 适合处理的问题包括:
21
+
22
+ - 章节结构需要调整。
23
+ - 表达不够清晰,需要重写。
24
+ - 某段内容缺少背景、边界或结论。
25
+ - 长文需要分轮评审,先看结构,再看内容,再看措辞。
26
+
27
+ ## 示意流程
28
+
29
+ | 1. 进入流程 | 2. Review & comment | 3. Review & comment | 4. Review 完毕,提交 | 5. 查看结果 & loop |
30
+ | --------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------ |
31
+ | ![进入流程](./assets/review-loop/01-enter-flow.png) | ![Review and comment](./assets/review-loop/02-review-comment.png) | ![Review and comment](./assets/review-loop/03-review-comment.png) | ![Review 完毕,提交](./assets/review-loop/04-submit-review.png) | ![查看结果并进入下一轮](./assets/review-loop/05-review-result.png) |
32
+
33
+ ## 快速开始
34
+
35
+ ### 安装
36
+
37
+ 推荐让 Codex 自动安装:
38
+
39
+ ```text
40
+ 帮我安装 skill:https://www.npmjs.com/package/md-review-server
41
+ ```
42
+
43
+ 也可以手动安装:
44
+
45
+ ```sh
46
+ npx -y md-review-server@latest skill install
47
+ ```
48
+
49
+ 检查状态:
50
+
51
+ ```sh
52
+ npx -y md-review-server@latest skill doctor
53
+ ```
54
+
55
+ 看到 `Status: up to date` 即可使用。
56
+
57
+ ### 启动评审循环
58
+
59
+ 在 Codex 中输入:
60
+
61
+ ```text
62
+ 使用 $markdown-review-loop 帮我启动 docs/example.md 的评审循环。
63
+ ```
64
+
65
+ Codex 会打开本地评审页面。用户在浏览器中阅读文档,并对需要修改的位置创建评论。
66
+
67
+ ### 在浏览器中评论
68
+
69
+ 在浏览器中操作:
70
+
71
+ 1. 选中需要修改的文字。
72
+ 2. 点击 `Comment`。
73
+ 3. 输入评论。
74
+ 4. 提交评论。
75
+
76
+ ### 让 Codex 生成下一版
77
+
78
+ 评论完成后,回到 Codex 输入:
79
+
80
+ ```text
81
+ 评论完了
82
+ ```
83
+
84
+ Codex 会根据评论生成新版本,例如:
85
+
86
+ ```text
87
+ example.v1.md -> example.v2.md
88
+ ```
89
+
90
+ ### 继续评审
91
+
92
+ 如果还需要继续修改,在浏览器中切换到新版文档,继续评论。然后对 Codex 说:
93
+
94
+ ```text
95
+ 我已经在 v2 上补充了新评论,继续生成 v3。
96
+ ```
97
+
98
+ 推荐使用版本化文件名:
99
+
100
+ ```text
101
+ example.v1.md
102
+ example.v2.md
103
+ example.v3.md
104
+ ```
105
+
106
+ 查看历史版本:
107
+
108
+ ![查看历史版本](./assets/review-loop/06-history-versions.png)
109
+
110
+ ### 常用话术
111
+
112
+ 启动评审:
113
+
114
+ ```text
115
+ 使用 $markdown-review-loop 帮我启动这份 Markdown 的评审循环。
116
+ ```
117
+
118
+ 生成下一版:
119
+
120
+ ```text
121
+ 评论完了,读取评论并生成下一版。
122
+ ```
123
+
124
+ 继续下一轮:
125
+
126
+ ```text
127
+ 我已经在新版上补充了评论,继续处理。
128
+ ```
129
+
130
+ ## 手动启动 Review Server
131
+
132
+ 不使用 Codex skill 时,可以直接启动本地评审页面:
133
+
134
+ ```sh
135
+ npx -y md-review-server@latest docs --port 3030 --active-file docs/guide.md
136
+ ```
137
+
138
+ 也可以全局安装:
139
+
140
+ ```sh
141
+ npm install -g md-review-server
142
+ md-review-server docs --port 3030
143
+ ```
144
+
145
+ 默认只监听 `127.0.0.1`。如果使用 `--host 0.0.0.0`,服务会在启动时输出安全提示。
146
+
147
+ ## 主要能力
148
+
149
+ - 内置 `markdown-review-loop` Codex skill,可通过 npm 安装和更新
11
150
  - 按原始结构预览 Markdown 和 MDX 文件
12
151
  - 解析并展示 Frontmatter 元数据
13
152
  - 对选中文本和指定行范围创建评论
@@ -20,21 +159,29 @@
20
159
  - 点击评论行号跳转到对应内容
21
160
  - Markdown 文件变更后通过 SSE 自动刷新
22
161
 
23
- ## 安装
162
+ ## 评论管理
24
163
 
25
- ```sh
26
- npm install -g md-review-server
27
- ```
164
+ ### 添加评论
28
165
 
29
- 当前首轮交付以本地使用为主,也可以在仓库中直接运行:
166
+ 1. 在 Markdown 预览区域选择文本
167
+ 2. 点击出现的 `Comment` 按钮
168
+ 3. 输入评论内容
169
+ 4. 按 `Cmd/Ctrl+Enter` 或点击 `Submit`
30
170
 
31
- ```sh
32
- pnpm install
33
- pnpm build
34
- node bin/md-review.js docs --port 3030
35
- ```
171
+ ### 编辑评论
36
172
 
37
- ## 使用方式
173
+ 1. 点击评论上的编辑按钮
174
+ 2. 修改文本框中的内容
175
+ 3. 按 `Cmd/Ctrl+Enter` 或点击 `Save`
176
+ 4. 按 `Escape` 或点击 `Cancel` 放弃修改
177
+
178
+ ### 快捷键
179
+
180
+ - `Cmd/Ctrl+Enter`:提交或保存评论
181
+ - `Escape`:取消编辑
182
+ - `Cmd+K`:目录模式中聚焦搜索框
183
+
184
+ ## CLI 使用方式
38
185
 
39
186
  ```sh
40
187
  md-review-server [options] # 浏览当前目录下的 Markdown 文件
@@ -68,9 +215,9 @@ md-review-server skill install
68
215
  md-review-server skill update --force
69
216
  ```
70
217
 
71
- 默认只监听 `127.0.0.1`。如果使用 `--host 0.0.0.0`,服务会在启动时输出安全提示;MVP 不包含认证能力。
218
+ ## 进阶说明
72
219
 
73
- ## 评论数据
220
+ ### 评论数据
74
221
 
75
222
  评论由服务端写入 Markdown 所在 review 目录:
76
223
 
@@ -110,21 +257,21 @@ review 文件使用 JSON 存储,核心字段包括:
110
257
  - `unresolved`:无法处理,需记录原因
111
258
  - `ignored`:明确跳过
112
259
 
113
- ## HTTP API
260
+ ### HTTP API
114
261
 
115
- ### 获取会话信息
262
+ #### 获取会话信息
116
263
 
117
264
  ```sh
118
265
  curl http://127.0.0.1:3030/api/session
119
266
  ```
120
267
 
121
- ### 获取待处理评论
268
+ #### 获取待处理评论
122
269
 
123
270
  ```sh
124
271
  curl 'http://127.0.0.1:3030/api/comments?file=guide.v2.md&status=open'
125
272
  ```
126
273
 
127
- ### 创建评论
274
+ #### 创建评论
128
275
 
129
276
  ```sh
130
277
  curl -X POST 'http://127.0.0.1:3030/api/comments' \
@@ -138,7 +285,7 @@ curl -X POST 'http://127.0.0.1:3030/api/comments' \
138
285
  }'
139
286
  ```
140
287
 
141
- ### 批量回写状态
288
+ #### 批量回写状态
142
289
 
143
290
  ```sh
144
291
  curl -X PATCH 'http://127.0.0.1:3030/api/comments' \
@@ -156,79 +303,48 @@ curl -X PATCH 'http://127.0.0.1:3030/api/comments' \
156
303
  }'
157
304
  ```
158
305
 
159
- ## Codex 评审循环
160
-
161
- 推荐使用目录模式启动 review server:
306
+ ## 本地开发
162
307
 
163
308
  ```sh
164
- md-review-server docs --port 3030 --active-file docs/guide.v2.md
309
+ pnpm install
310
+ pnpm dev
311
+ pnpm test
312
+ pnpm build
313
+ pnpm lint
165
314
  ```
166
315
 
167
- 典型流程:
316
+ ## 发布流程
168
317
 
169
- 1. Codex 生成一个版本化 Markdown 文件,例如 `guide.v2.md`
170
- 2. 用户在浏览器中选区并创建评论
171
- 3. 服务端将评论写入 `.reviews/*.review.json`
172
- 4. Codex 通过 `GET /api/comments?status=open` 获取待处理评论
173
- 5. Codex 生成下一版 Markdown,例如 `guide.v3.md`
174
- 6. Codex 通过批量 `PATCH /api/comments` 回写每条评论的处理状态
175
- 7. 用户在同一个 review server 中选择新版本继续评审
318
+ 项目使用 GitHub Actions npm Trusted Publishing 发布 npm 包,不需要在 GitHub Secrets 中保存长期 `NPM_TOKEN`。
176
319
 
177
- ### 安装 Codex Skill
320
+ npm 包后台需要配置 Trusted Publisher:
178
321
 
179
- 包内提供 `markdown-review-loop` skill,用于让 Codex 自动执行启动 review server、读取评论、生成下一版 Markdown 和回写状态的流程。
322
+ - Package:`md-review-server`
323
+ - Publisher:GitHub Actions
324
+ - Owner:`tracyxiong1`
325
+ - Repository:`md-review-server`
326
+ - Workflow filename:`release-please.yml`
180
327
 
181
- ```sh
182
- npx -y md-review-server@latest skill install
183
- ```
328
+ 发布步骤:
184
329
 
185
- 如果已经全局安装 `md-review-server`,也可以直接运行 `md-review-server skill install`。
330
+ 1. 使用语义化 commit 合并改动到 `main`
331
+ 2. `release-please` 自动创建或更新 release PR
332
+ 3. 合并 release PR 后,workflow 创建 GitHub Release 和版本 tag
333
+ 4. 同一个 workflow 在 tag 对应代码上执行 `lint`、`test`、`build`
334
+ 5. 验证 npm 上不存在同版本后,通过 OIDC 发布到 npm
186
335
 
187
- 安装后可通过 `$markdown-review-loop` 显式触发,例如:
188
-
189
- ```text
190
- 使用 $markdown-review-loop 帮我启动这份 Markdown 的评审循环。
191
- ```
192
-
193
- skill 依赖本机可运行 `md-review-server`。本地开发阶段可以先在仓库中执行 `npm link`,或使用发布后的 npm 包。
194
-
195
- 更新 skill:
336
+ 也可以手动创建版本 tag 触发同一个发布流程:
196
337
 
197
338
  ```sh
198
- npx -y md-review-server@latest skill update
199
- md-review-server skill doctor
339
+ npm version patch
340
+ git push origin main --tags
200
341
  ```
201
342
 
202
- ## 评论管理
203
-
204
- ### 添加评论
205
-
206
- 1. 在 Markdown 预览区域选择文本
207
- 2. 点击出现的 `Comment` 按钮
208
- 3. 输入评论内容
209
- 4. 按 `Cmd/Ctrl+Enter` 或点击 `Submit`
210
-
211
- ### 编辑评论
212
-
213
- 1. 点击评论上的编辑按钮
214
- 2. 修改文本框中的内容
215
- 3. 按 `Cmd/Ctrl+Enter` 或点击 `Save`
216
- 4. 按 `Escape` 或点击 `Cancel` 放弃修改
217
-
218
- ### 快捷键
219
-
220
- - `Cmd/Ctrl+Enter`:提交或保存评论
221
- - `Escape`:取消编辑
222
- - `Cmd+K`:目录模式中聚焦搜索框
223
-
224
- ## 本地开发
343
+ 发布完成后可验证:
225
344
 
226
345
  ```sh
227
- pnpm install
228
- pnpm dev
229
- pnpm test
230
- pnpm build
231
- pnpm lint
346
+ npm view md-review-server version --registry=https://registry.npmjs.org/
347
+ npx -y md-review-server@latest skill doctor
232
348
  ```
233
349
 
234
350
  ## License
Binary file
Binary file
Binary file
@@ -1,11 +1,4 @@
1
- import {
2
- cpSync,
3
- existsSync,
4
- mkdirSync,
5
- readFileSync,
6
- rmSync,
7
- writeFileSync,
8
- } from 'fs';
1
+ import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'fs';
9
2
  import { dirname, join, resolve } from 'path';
10
3
 
11
4
  export const SKILL_NAME = 'markdown-review-loop';
@@ -98,7 +91,9 @@ export function printSkillStatus(status) {
98
91
  console.log(`Bundled: ${status.bundledVersion || 'missing'}`);
99
92
  console.log(`Installed: ${status.installedVersion || 'missing'}`);
100
93
  console.log(`Path: ${status.target}`);
101
- console.log(`Status: ${status.upToDate ? 'up to date' : status.installed ? 'update available' : 'not installed'}`);
94
+ console.log(
95
+ `Status: ${status.upToDate ? 'up to date' : status.installed ? 'update available' : 'not installed'}`,
96
+ );
102
97
  }
103
98
 
104
99
  export function printSkillHelp() {
@@ -115,11 +110,7 @@ Examples:
115
110
  `);
116
111
  }
117
112
 
118
- export function handleSkillCommand({
119
- packageRoot,
120
- argv,
121
- env = process.env,
122
- } = {}) {
113
+ export function handleSkillCommand({ packageRoot, argv, env = process.env } = {}) {
123
114
  const subcommand = argv[0] || 'doctor';
124
115
  const force = argv.includes('--force');
125
116
  const quiet = argv.includes('--quiet');
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "md-review-server",
3
- "version": "0.1.0",
4
- "description": "Local Markdown review server with visual comments, sidecar storage, and HTTP APIs",
3
+ "version": "0.1.2",
4
+ "description": "Visual Markdown review server with Codex skill, sidecar comments, and HTTP APIs",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "md-review-server": "bin/md-review.js"
8
8
  },
9
9
  "files": [
10
+ "assets",
10
11
  "bin/md-review.js",
11
12
  "bin/skill-manager.js",
12
13
  "dist",
@@ -51,14 +52,21 @@
51
52
  "keywords": [
52
53
  "markdown",
53
54
  "review",
55
+ "codex",
56
+ "skill",
57
+ "agent",
54
58
  "cli",
55
59
  "preview",
56
60
  "comments",
61
+ "http-api",
62
+ "sidecar",
57
63
  "documentation"
58
64
  ],
59
- "author": "ryo-manba",
65
+ "author": "tracyxiong1",
66
+ "contributors": [
67
+ "ryo-manba"
68
+ ],
60
69
  "license": "MIT",
61
- "funding": "https://github.com/ryo-manba/md-review?sponsor=1",
62
70
  "packageManager": "pnpm@10.23.0",
63
71
  "dependencies": {
64
72
  "@hono/node-server": "^1.19.6",
package/server/app.js CHANGED
@@ -137,7 +137,11 @@ export function createApp(options = {}) {
137
137
 
138
138
  try {
139
139
  const files = await scanMarkdownFiles(baseDir);
140
- return c.json({ files, baseDir, selectedFile: resolveSelectedFile(files, options.activeFile) });
140
+ return c.json({
141
+ files,
142
+ baseDir,
143
+ selectedFile: resolveSelectedFile(files, options.activeFile),
144
+ });
141
145
  } catch (err) {
142
146
  console.error('Error scanning markdown files:', err.message);
143
147
  return jsonError(c, 'Failed to scan markdown files');
@@ -1,13 +1,7 @@
1
1
  import { mkdir, readFile, readdir, rename, writeFile } from 'fs/promises';
2
2
  import { dirname, extname, isAbsolute, join, resolve } from 'path';
3
3
 
4
- const VALID_STATUSES = new Set([
5
- 'open',
6
- 'resolved',
7
- 'partially_resolved',
8
- 'unresolved',
9
- 'ignored',
10
- ]);
4
+ const VALID_STATUSES = new Set(['open', 'resolved', 'partially_resolved', 'unresolved', 'ignored']);
11
5
 
12
6
  function normalizeReviewFile(file) {
13
7
  if (!file || typeof file !== 'string') {
@@ -132,6 +132,7 @@ docs/example.v1.md:L42
132
132
 
133
133
  ```md
134
134
  ## C001
135
+
135
136
  source: docs/example.v1.md:L42-L48
136
137
  quote: "长行中的局部选区"
137
138
  status: open
@@ -1,4 +1,4 @@
1
1
  interface:
2
- display_name: "Markdown 评审循环"
3
- short_description: "可视化批注、修订并跟踪 Markdown 评审。"
4
- default_prompt: "使用 $markdown-review-loop 打开可视化 Markdown 评审,收集批注并生成下一版修订稿。"
2
+ display_name: 'Markdown 评审循环'
3
+ short_description: '可视化批注、修订并跟踪 Markdown 评审。'
4
+ default_prompt: '使用 $markdown-review-loop 打开可视化 Markdown 评审,收集批注并生成下一版修订稿。'
@@ -9,6 +9,7 @@ document: docs/example.v1.md
9
9
  next_version: docs/example.v2.md
10
10
 
11
11
  ## C001
12
+
12
13
  source: docs/example.v1.md:L42-L48
13
14
  quote: "ABase 写入不在 RDS 事务内"
14
15
  status: open
@@ -16,6 +17,7 @@ comment: 需要补充 RDS 与 ABase 一致性边界。
16
17
  resolution:
17
18
 
18
19
  ## C002
20
+
19
21
  source: docs/example.v1.md:L77
20
22
  quote:
21
23
  status: open
@@ -27,6 +29,7 @@ resolution:
27
29
 
28
30
  ```md
29
31
  ## C001
32
+
30
33
  source: docs/example.v1.md:L42-L48
31
34
  quote: "ABase 写入不在 RDS 事务内"
32
35
  status: resolved