mosage 0.1.0 → 0.8.0

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.
Files changed (146) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +16 -217
  3. package/bin.js +2 -0
  4. package/dist/build-C7NW_3Pk.js +14 -0
  5. package/dist/check-CP4873Wx.js +41 -0
  6. package/dist/cli/bin.d.ts +1 -0
  7. package/dist/cli/bin.js +228 -0
  8. package/dist/config-DPm1BBAb.js +2619 -0
  9. package/dist/config-TlTe7Ona.d.ts +24 -0
  10. package/dist/context-BqsdSrAQ.js +1084 -0
  11. package/dist/dev-Biz42qlu.js +17 -0
  12. package/dist/diagram-xlVDekYk.js +763 -0
  13. package/dist/export-Bi6nuxjT.js +31 -0
  14. package/dist/import-D2jNB07F.js +25 -0
  15. package/dist/index.d.ts +455 -0
  16. package/dist/index.js +693 -0
  17. package/dist/init-Bbtj2pxF.js +262 -0
  18. package/dist/preview-CLm51aRt.js +19 -0
  19. package/dist/sdk-DjpX6mCv.js +51 -0
  20. package/dist/vite/index.d.ts +25 -0
  21. package/dist/vite/index.js +2 -0
  22. package/env.d.ts +83 -0
  23. package/package.json +84 -64
  24. package/skills/apply-comments/SKILL.md +43 -56
  25. package/skills/create-doc/SKILL.md +106 -0
  26. package/skills/create-theme/SKILL.md +184 -0
  27. package/skills/current-doc/SKILL.md +120 -0
  28. package/skills/doc-authoring/SKILL.md +434 -0
  29. package/skills/doc-authoring/references/assets.md +47 -0
  30. package/skills/doc-authoring/references/design-system.md +81 -0
  31. package/skills/doc-authoring/references/long-form.md +131 -0
  32. package/skills/doc-authoring/references/pagination.md +118 -0
  33. package/skills/doc-authoring/references/tables-and-charts.md +161 -0
  34. package/src/app/app.tsx +42 -0
  35. package/src/app/components/data-table.tsx +196 -0
  36. package/src/app/components/design-panel/design-panel.tsx +318 -0
  37. package/src/app/components/design-panel/design-provider.tsx +121 -0
  38. package/src/app/components/design-panel/use-design.ts +85 -0
  39. package/src/app/components/diagram.tsx +76 -0
  40. package/src/app/components/doc-assets.tsx +129 -0
  41. package/src/app/components/doc-search.tsx +248 -0
  42. package/src/app/components/doc-sidebar.tsx +162 -0
  43. package/src/app/components/flow-page.tsx +93 -0
  44. package/src/app/components/footnote.tsx +204 -0
  45. package/src/app/components/image-placeholder.tsx +50 -0
  46. package/src/app/components/inspector/inspector.tsx +518 -0
  47. package/src/app/components/numbering.tsx +224 -0
  48. package/src/app/components/page-frame.tsx +70 -0
  49. package/src/app/components/sidebar/folder-item.tsx +212 -0
  50. package/src/app/components/sidebar/icon-picker.tsx +99 -0
  51. package/src/app/components/sidebar/sidebar.tsx +252 -0
  52. package/src/app/components/table-of-contents.tsx +93 -0
  53. package/src/app/components/theme-toggle.tsx +50 -0
  54. package/src/app/components/themes/markdown.tsx +249 -0
  55. package/src/app/components/themes/theme-preview.tsx +74 -0
  56. package/src/app/components/ui/menu.tsx +143 -0
  57. package/src/app/index.html +12 -0
  58. package/src/app/lib/agent-bridge.ts +140 -0
  59. package/src/app/lib/assets.ts +151 -0
  60. package/src/app/lib/design-presets.ts +109 -0
  61. package/src/app/lib/design.ts +88 -0
  62. package/src/app/lib/diagnostics.ts +282 -0
  63. package/src/app/lib/doc-preview.tsx +29 -0
  64. package/src/app/lib/docs.ts +26 -0
  65. package/src/app/lib/docx/extract.ts +1623 -0
  66. package/src/app/lib/docx/fonts.test.ts +136 -0
  67. package/src/app/lib/docx/fonts.ts +166 -0
  68. package/src/app/lib/docx/media.ts +102 -0
  69. package/src/app/lib/docx/model.ts +206 -0
  70. package/src/app/lib/docx/paragraph.test.ts +92 -0
  71. package/src/app/lib/docx/paragraph.ts +107 -0
  72. package/src/app/lib/docx/props.ts +187 -0
  73. package/src/app/lib/docx/styles.ts +306 -0
  74. package/src/app/lib/docx/units.ts +35 -0
  75. package/src/app/lib/docx/write.test.ts +507 -0
  76. package/src/app/lib/docx/write.ts +581 -0
  77. package/src/app/lib/docx/xml.ts +39 -0
  78. package/src/app/lib/export-docx.ts +289 -0
  79. package/src/app/lib/export-dom.ts +318 -0
  80. package/src/app/lib/export-html.ts +156 -0
  81. package/src/app/lib/export-image.ts +70 -0
  82. package/src/app/lib/export-pdf.ts +165 -0
  83. package/src/app/lib/flow-measure.test.ts +31 -0
  84. package/src/app/lib/flow-measure.ts +183 -0
  85. package/src/app/lib/flow.test.ts +110 -0
  86. package/src/app/lib/flow.ts +136 -0
  87. package/src/app/lib/folders.ts +192 -0
  88. package/src/app/lib/footnotes.test.tsx +102 -0
  89. package/src/app/lib/footnotes.ts +94 -0
  90. package/src/app/lib/inspector/fiber.ts +99 -0
  91. package/src/app/lib/labels.test.ts +18 -0
  92. package/src/app/lib/labels.ts +181 -0
  93. package/src/app/lib/outline.ts +118 -0
  94. package/src/app/lib/page-context.tsx +43 -0
  95. package/src/app/lib/page-range.test.ts +95 -0
  96. package/src/app/lib/page-range.ts +90 -0
  97. package/src/app/lib/print-ready.ts +69 -0
  98. package/src/app/lib/rasterize.ts +173 -0
  99. package/src/app/lib/scan.ts +26 -0
  100. package/src/app/lib/sdk.test.ts +32 -0
  101. package/src/app/lib/sdk.ts +115 -0
  102. package/src/app/lib/themes.ts +31 -0
  103. package/src/app/lib/use-doc-module.ts +53 -0
  104. package/src/app/lib/use-doc-pages.ts +147 -0
  105. package/src/app/lib/utils.ts +6 -0
  106. package/src/app/lib/view-mode.test.ts +91 -0
  107. package/src/app/lib/view-mode.ts +104 -0
  108. package/src/app/main.tsx +14 -0
  109. package/src/app/routes/assets.tsx +257 -0
  110. package/src/app/routes/doc.tsx +877 -0
  111. package/src/app/routes/home-shell.tsx +203 -0
  112. package/src/app/routes/home.tsx +269 -0
  113. package/src/app/routes/themes.tsx +121 -0
  114. package/src/app/styles.css +97 -0
  115. package/src/app/virtual.d.ts +30 -0
  116. package/template/AGENTS.md +27 -0
  117. package/template/README.md +39 -0
  118. package/template/docs/getting-started/index.tsx +230 -0
  119. package/template/mosage.config.ts +5 -0
  120. package/template/package.json +24 -0
  121. package/template/tsconfig.json +17 -0
  122. package/README.en.md +0 -57
  123. package/dist/cli.js +0 -4545
  124. package/dist/web/assets/index-Czg2WeHe.js +0 -182
  125. package/dist/web/assets/index-DKAyt92W.css +0 -1
  126. package/dist/web/index.html +0 -15
  127. package/skills/current-position/SKILL.md +0 -65
  128. package/skills/kickoff/SKILL.md +0 -105
  129. package/skills/mosage-reference/SKILL.md +0 -164
  130. package/skills/outline/SKILL.md +0 -79
  131. package/skills/review/SKILL.md +0 -64
  132. package/skills/write-chapter/SKILL.md +0 -58
  133. package/template/book/STYLE.md +0 -6
  134. package/template/book/assets/.gitkeep +0 -0
  135. package/template/book/book.yaml +0 -42
  136. package/template/book/brief.md +0 -6
  137. package/template/book/chapters/.gitkeep +0 -0
  138. package/template/book/notes/README.md +0 -7
  139. package/template/project/AGENTS.md +0 -82
  140. package/template/project/CLAUDE.md +0 -1
  141. package/template/project/README.md +0 -48
  142. package/template/project/books/.gitkeep +0 -0
  143. package/template/project/gitignore +0 -5
  144. package/template/project/mosage.yaml +0 -23
  145. package/template/project/notes/README.md +0 -8
  146. package/template/project/package.json +0 -14
@@ -0,0 +1,30 @@
1
+ declare module 'virtual:mosage/docs' {
2
+ import type { DocModule } from './lib/sdk';
3
+
4
+ export const docIds: string[];
5
+ export const docCreatedAt: Record<string, number>;
6
+ export const docThemes: Record<string, string>;
7
+ export function loadDoc(id: string): Promise<DocModule>;
8
+ }
9
+
10
+ declare module 'virtual:mosage/themes' {
11
+ import type { ThemeDemoModule, ThemeMeta } from './lib/themes';
12
+
13
+ export const themes: ThemeMeta[];
14
+ export function loadThemeDemo(id: string): Promise<ThemeDemoModule>;
15
+ }
16
+
17
+ declare module 'virtual:mosage/folders' {
18
+ import type { FoldersManifest } from './lib/sdk';
19
+
20
+ const manifest: FoldersManifest;
21
+ export default manifest;
22
+ }
23
+
24
+ declare module 'virtual:mosage/config' {
25
+ import type { MoSageConfig } from '../config';
26
+
27
+ type ResolvedBuild = { showDocBrowser: boolean; allowHtmlExport: boolean };
28
+ const config: MoSageConfig & { build: ResolvedBuild; version: string };
29
+ export default config;
30
+ }
@@ -0,0 +1,27 @@
1
+ # MoSage workspace
2
+
3
+ You author **documents** here — reports, proposals, whitepapers, memos. Each document is a folder under `docs/` with one `index.tsx` that exports an array of page components. Every page is one printed sheet (A4 by default).
4
+
5
+ ## Rules
6
+
7
+ - Write only inside `docs/<id>/`. Don't touch `package.json`, `mosage.config.ts`, or other documents.
8
+ - No new dependencies. Only `react`, `mosage`, and standard web APIs are available.
9
+ - A document is one `index.tsx` plus an optional `assets/` folder. No sibling components files.
10
+
11
+ ## Skills
12
+
13
+ | Skill | Use it for |
14
+ | --- | --- |
15
+ | `create-doc` | Drafting a new document end to end — scoping questions, page plan, then the file. |
16
+ | `doc-authoring` | The technical reference: file contract, page canvas, print type scale, vertical budget, tables, TOC, page numbers. Read before any edit under `docs/`. |
17
+ | `current-doc` | Resolving "this page" / "this element" — reads the cursor the dev server writes to `node_modules/.mosage/current.json`. |
18
+
19
+ ## Commands
20
+
21
+ ```bash
22
+ pnpm dev # dev server at http://localhost:5273
23
+ pnpm build # static site into dist/
24
+ pnpm preview # preview the build
25
+ ```
26
+
27
+ In the viewer: outline sidebar, zoom, **PDF** export (true page size) and **HTML** export (self-contained).
@@ -0,0 +1,39 @@
1
+ # 我的文件
2
+
3
+ 這個資料夾是一個 [MoSage](https://github.com/nickchen1998/MoSage) 專案:用 AI 寫文件,在瀏覽器裡預覽成真實的紙張,最後匯出 PDF、Word 或 HTML。
4
+
5
+ ## 開始
6
+
7
+ ```bash
8
+ npm install # 如果建立專案時跳過了安裝
9
+ npm run dev # 開啟 http://localhost:5273
10
+ ```
11
+
12
+ 在同一個資料夾開啟 Claude Code 或 Codex,描述你要的文件,例如「幫我寫一份 Q3 營運報告,給主管看,大約 6 頁」。
13
+ AI 會用內建的 `create-doc` skill 先確認主題與資料來源,再規劃頁面、撰寫。
14
+
15
+ ## 資料夾
16
+
17
+ ```
18
+ docs/
19
+ <文件代號>/
20
+ index.tsx 每份文件一個檔案,預設匯出頁面陣列
21
+ assets/ 這份文件用到的圖片(選用)
22
+ themes/ 可重複使用的主題(選用)
23
+ mosage.config.ts 專案設定
24
+ ```
25
+
26
+ ## 常用指令
27
+
28
+ | 指令 | 說明 |
29
+ | --- | --- |
30
+ | `npm run dev` | 開啟檢視器,檔案一改就即時更新 |
31
+ | `npx mosage check` | 找出超出紙張的內容、空白頁、落在頁尾的標題等問題 |
32
+ | `npx mosage export <文件> --format docx` | 匯出 Word;也可以用 `pdf`、`html`、`png` |
33
+ | `npx mosage import notes.md` | 把 Markdown 轉成一份文件 |
34
+ | `npm run build` | 輸出靜態網站 |
35
+
36
+ `check` 與 `export` 需要 Playwright:`npm i -D playwright && npx playwright install chromium`。
37
+ 在瀏覽器裡用右上角的 **Download** 匯出則不需要。
38
+
39
+ 升級 mosage 後,執行 `npx mosage sync:skills` 更新 `.agents/skills` 與 `.claude/skills`。
@@ -0,0 +1,230 @@
1
+ import {
2
+ type DesignSystem,
3
+ type DocMeta,
4
+ type DocPage,
5
+ TableOfContents,
6
+ useDocPageCount,
7
+ useDocPageNumber,
8
+ } from 'mosage';
9
+ import type { CSSProperties, ReactNode } from 'react';
10
+
11
+ export const design: DesignSystem = {
12
+ palette: {
13
+ bg: '#ffffff',
14
+ text: '#16181d',
15
+ muted: '#6b7280',
16
+ accent: '#1d4ed8',
17
+ rule: '#e4e7ec',
18
+ },
19
+ fonts: {
20
+ heading: '-apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif',
21
+ body: '-apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif',
22
+ mono: 'ui-monospace, "SF Mono", Menlo, monospace',
23
+ },
24
+ typeScale: { title: 44, h1: 28, h2: 20, h3: 16, body: 14, caption: 10 },
25
+ margin: 76,
26
+ leading: 1.55,
27
+ radius: 6,
28
+ };
29
+
30
+ const page: CSSProperties = {
31
+ width: '100%',
32
+ height: '100%',
33
+ boxSizing: 'border-box',
34
+ padding: 'var(--od-margin)',
35
+ background: 'var(--od-bg)',
36
+ color: 'var(--od-text)',
37
+ fontFamily: 'var(--od-font-body)',
38
+ fontSize: 'var(--od-size-body)',
39
+ lineHeight: 'var(--od-leading)',
40
+ position: 'relative',
41
+ };
42
+
43
+ const h1: CSSProperties = {
44
+ fontFamily: 'var(--od-font-heading)',
45
+ fontSize: 'var(--od-size-h1)',
46
+ lineHeight: 1.2,
47
+ fontWeight: 650,
48
+ letterSpacing: '-0.015em',
49
+ margin: '0 0 18px',
50
+ };
51
+
52
+ const h2: CSSProperties = {
53
+ fontFamily: 'var(--od-font-heading)',
54
+ fontSize: 'var(--od-size-h2)',
55
+ lineHeight: 1.25,
56
+ fontWeight: 600,
57
+ margin: '24px 0 10px',
58
+ };
59
+
60
+ const p: CSSProperties = { margin: '0 0 14px' };
61
+
62
+ const Code = ({ children }: { children: ReactNode }) => (
63
+ <pre
64
+ style={{
65
+ fontFamily: 'var(--od-font-mono)',
66
+ fontSize: 11.5,
67
+ lineHeight: 1.55,
68
+ background: '#f6f7f9',
69
+ border: '1px solid var(--od-rule)',
70
+ borderRadius: 'var(--od-radius)',
71
+ padding: '12px 14px',
72
+ margin: '0 0 14px',
73
+ whiteSpace: 'pre-wrap',
74
+ }}
75
+ >
76
+ {children}
77
+ </pre>
78
+ );
79
+
80
+ const Footer = () => {
81
+ const n = useDocPageNumber();
82
+ const total = useDocPageCount();
83
+ return (
84
+ <div
85
+ style={{
86
+ position: 'absolute',
87
+ left: 'var(--od-margin)',
88
+ right: 'var(--od-margin)',
89
+ bottom: 40,
90
+ display: 'flex',
91
+ justifyContent: 'space-between',
92
+ fontSize: 'var(--od-size-caption)',
93
+ color: 'var(--od-muted)',
94
+ borderTop: '1px solid var(--od-rule)',
95
+ paddingTop: 8,
96
+ }}
97
+ >
98
+ <span>Getting started with MoSage</span>
99
+ <span style={{ fontVariantNumeric: 'tabular-nums' }}>
100
+ {n} / {total}
101
+ </span>
102
+ </div>
103
+ );
104
+ };
105
+
106
+ const Cover: DocPage = () => (
107
+ <div style={{ ...page, display: 'flex', flexDirection: 'column', justifyContent: 'flex-end' }}>
108
+ <p
109
+ style={{
110
+ fontSize: 12,
111
+ letterSpacing: '0.18em',
112
+ textTransform: 'uppercase',
113
+ color: 'var(--od-accent)',
114
+ margin: '0 0 16px',
115
+ }}
116
+ >
117
+ mosage
118
+ </p>
119
+ <h1
120
+ data-od-outline="skip"
121
+ style={{ ...h1, fontSize: 'var(--od-size-title)', margin: '0 0 16px', maxWidth: 480 }}
122
+ >
123
+ Getting started
124
+ </h1>
125
+ <p style={{ ...p, fontSize: 15, color: 'var(--od-muted)', maxWidth: 460 }}>
126
+ Documents written as React. One component per printed page — the framework handles the sheet,
127
+ the outline, and the export.
128
+ </p>
129
+ <p style={{ ...p, marginTop: 40, fontSize: 11, color: 'var(--od-muted)' }}>
130
+ Delete this document once you've read it — it's just a starting point.
131
+ </p>
132
+ </div>
133
+ );
134
+
135
+ const Contents: DocPage = () => (
136
+ <div style={page}>
137
+ <h1 style={h1} data-od-outline="skip">
138
+ Contents
139
+ </h1>
140
+ <TableOfContents maxLevel={2} />
141
+ <p style={{ ...p, marginTop: 24, fontSize: 12, color: 'var(--od-muted)' }}>
142
+ This list is generated from the headings on the following pages. Page numbers update on their
143
+ own — never write a contents list by hand.
144
+ </p>
145
+ <Footer />
146
+ </div>
147
+ );
148
+
149
+ const HowItWorks: DocPage = () => (
150
+ <div style={page}>
151
+ <h1 style={h1}>How a document works</h1>
152
+ <p style={p}>
153
+ A document is a folder under <code>docs/</code> with a single <code>index.tsx</code>. It
154
+ default-exports an array of components — one per page, in order. There is no automatic reflow:
155
+ what you put on a page is exactly what lands on that sheet.
156
+ </p>
157
+
158
+ <Code>{`docs/
159
+ my-report/
160
+ index.tsx // export default [Cover, Summary, …]
161
+ assets/ // optional images`}</Code>
162
+
163
+ <h2 style={h2}>The page canvas</h2>
164
+ <p style={p}>
165
+ A4 portrait is 794 × 1123 CSS pixels at 96dpi. With the default 76px margin, the text block is
166
+ 642 × 971 — about 44 lines of body copy. Design in absolute pixels; the viewer only scales the
167
+ whole sheet.
168
+ </p>
169
+
170
+ <h2 style={h2}>Design tokens</h2>
171
+ <p style={p}>
172
+ The exported <code>design</code> const becomes CSS variables on every page:
173
+ <code> var(--od-bg)</code>, <code>var(--od-text)</code>, <code>var(--od-accent)</code>,
174
+ <code> var(--od-size-body)</code>, <code>var(--od-margin)</code>, and the rest. Change one
175
+ value and the whole document follows.
176
+ </p>
177
+
178
+ <Footer />
179
+ </div>
180
+ );
181
+
182
+ const Authoring: DocPage = () => (
183
+ <div style={page}>
184
+ <h1 style={h1}>Writing with an agent</h1>
185
+ <p style={p}>
186
+ This workspace ships with two skills. Ask your coding agent to draft a document and it runs
187
+ the <code>create-doc</code> workflow: scoping questions, a page plan, then the file.
188
+ </p>
189
+
190
+ <h2 style={h2}>Outline, contents, page numbers</h2>
191
+ <p style={p}>
192
+ Use real <code>h1</code>/<code>h2</code>/<code>h3</code> elements for section titles — the
193
+ framework scans them to build the sidebar outline and to fill{' '}
194
+ <code>&lt;TableOfContents /&gt;</code>. Page numbers come from <code>useDocPageNumber()</code>{' '}
195
+ and <code>useDocPageCount()</code>; never hardcode them.
196
+ </p>
197
+
198
+ <Code>{`import { useDocPageNumber, useDocPageCount } from 'mosage';
199
+
200
+ const Footer = () => {
201
+ const n = useDocPageNumber();
202
+ const total = useDocPageCount();
203
+ return <span>{n} / {total}</span>;
204
+ };`}</Code>
205
+
206
+ <h2 style={h2}>Exporting</h2>
207
+ <p style={p}>
208
+ <strong>PDF</strong> prints at the true page size — choose "Save as PDF" in the print dialog.
209
+ <strong> HTML</strong> downloads a self-contained copy (a zip when the document has assets).
210
+ Both wait for fonts and images, and both fill the contents list before serializing.
211
+ </p>
212
+
213
+ <h2 style={h2}>Next</h2>
214
+ <p style={p}>
215
+ Delete this folder, then ask your agent for the document you actually need. Everything the
216
+ agent has to know lives in the <code>doc-authoring</code> skill.
217
+ </p>
218
+
219
+ <Footer />
220
+ </div>
221
+ );
222
+
223
+ export const meta: DocMeta = {
224
+ title: 'Getting started',
225
+ subtitle: 'A tour of MoSage',
226
+ pageSize: 'A4',
227
+ createdAt: '2026-08-15T13:44:40.268Z',
228
+ };
229
+
230
+ export default [Cover, Contents, HowItWorks, Authoring] satisfies DocPage[];
@@ -0,0 +1,5 @@
1
+ import type { MoSageConfig } from 'mosage';
2
+
3
+ const mosageConfig: MoSageConfig = {};
4
+
5
+ export default mosageConfig;
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "workspace",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "mosage dev",
8
+ "build": "mosage build",
9
+ "preview": "mosage preview",
10
+ "check": "mosage check",
11
+ "export": "mosage export",
12
+ "sync:skills": "mosage sync:skills"
13
+ },
14
+ "dependencies": {
15
+ "mosage": "^0.1.0",
16
+ "react": "^18.3.1",
17
+ "react-dom": "^18.3.1"
18
+ },
19
+ "devDependencies": {
20
+ "@types/react": "^18.3.12",
21
+ "@types/react-dom": "^18.3.1",
22
+ "vite": "^5.4.10"
23
+ }
24
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "jsx": "react-jsx",
8
+ "resolveJsonModule": true,
9
+ "isolatedModules": true,
10
+ "moduleDetection": "force",
11
+ "noEmit": true,
12
+ "strict": true,
13
+ "skipLibCheck": true,
14
+ "types": ["mosage/env"]
15
+ },
16
+ "include": ["docs/**/*", "mosage.config.ts"]
17
+ }
package/README.en.md DELETED
@@ -1,57 +0,0 @@
1
- # MoSage
2
-
3
- [繁體中文](README.md) · **English**
4
-
5
- **A local workspace for writing books and theses with an AI.** Open the project folder in Claude Code,
6
- Codex or any agent that reads `AGENTS.md`, and work through kickoff, title and outline, drafting and
7
- revision in conversation. In the browser you read the manuscript typeset like a book, select text to
8
- leave notes for the AI, and accept or reject its suggested rewrites — then export the Word file your
9
- publisher or university asks for.
10
-
11
- ```bash
12
- npx mosage init my-writing
13
- cd my-writing
14
- npm run dev # http://localhost:5280
15
- claude # or: codex — then say "開始" / "start" (or /kickoff)
16
- ```
17
-
18
- No database, no account: everything is plain files (Markdown + YAML) in the project folder. Images and
19
- reference material are simply copied into it.
20
-
21
- ## Highlights
22
-
23
- - **One project, many books** — each book or thesis lives in `books/<id>/` with its own settings, brief, style guide and chapters.
24
- - **Agent-led kickoff** — on a fresh project the agent interviews you (purpose, readers, voice, length), proposes titles and chapter structures, and scaffolds the outline.
25
- - **Outline board** — drag to reorder chapters, edit titles and summaries, track status per chapter.
26
- - **Book-like preview** — first-line indent, leading and fonts follow the Word export settings.
27
- - **Notes for the AI** — select any text and comment; notes are stored as `<!-- mosage:comment … -->` markers that the `apply-comments` skill processes.
28
- - **Suggestions you approve** — edits to existing prose arrive as `<!-- mosage:suggest … -->` markers shown as a diff with Accept / Reject.
29
- - **Live** — the page updates as the agent edits files.
30
- - **Automatic history** — every change snapshots the previous version; compare and restore in the UI.
31
- - **Where am I** — the UI writes `.mosage/current.json` so "make this paragraph shorter" just works.
32
- - **Word export** — real Word styles (Heading 1–4, body text, quote, caption), TOC field, page numbers, footnotes, tables, images; plus HTML (print to PDF) and merged Markdown.
33
- - **Import** — `mosage import manuscript.docx` splits an existing Word manuscript into chapters by heading style.
34
-
35
- ## Commands
36
-
37
- | Command | |
38
- | --- | --- |
39
- | `npx mosage init <dir>` | Create a project |
40
- | `mosage dev` | Start the writing UI |
41
- | `mosage new <id> --title … --type book\|thesis` | Add a book |
42
- | `mosage status [book] [--json]` | Shelf overview / one book's chapters, words and pending markers |
43
- | `mosage export [book] [docx\|html\|md]` | Export to `output/<book>/` |
44
- | `mosage import <file.docx\|.md> [--book id]` | Import an existing manuscript |
45
- | `mosage sync-skills` | Refresh the agent skills after upgrading |
46
-
47
- ## Credits
48
-
49
- The concepts — an `npx` scaffolder, agent skills shipped inside the workspace, browser comments applied
50
- by the agent, and a dev server that publishes the reader's position — come from
51
- [open-slide](https://github.com/open-slide/open-slide) by Yiwei Ho and
52
- [open-doc](https://github.com/simonliu-ai-product/open-doc) by Simon Liu (both MIT). MoSage is an
53
- independent implementation for long-form writing and Word delivery; it does not copy their code.
54
-
55
- ## License
56
-
57
- [MIT](LICENSE)