@profullstack/readm3 0.2.0 → 0.4.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 (49) hide show
  1. package/README.md +222 -13
  2. package/dist/cli.d.ts +5 -1
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +52 -6
  5. package/dist/cli.js.map +1 -1
  6. package/dist/cloud-cli.d.ts +4 -0
  7. package/dist/cloud-cli.d.ts.map +1 -0
  8. package/dist/cloud-cli.js +192 -0
  9. package/dist/cloud-cli.js.map +1 -0
  10. package/dist/cloud-client.d.ts +14 -0
  11. package/dist/cloud-client.d.ts.map +1 -0
  12. package/dist/cloud-client.js +62 -0
  13. package/dist/cloud-client.js.map +1 -0
  14. package/dist/editor.d.ts +77 -0
  15. package/dist/editor.d.ts.map +1 -0
  16. package/dist/editor.js +308 -0
  17. package/dist/editor.js.map +1 -0
  18. package/dist/emoji.d.ts +12 -0
  19. package/dist/emoji.d.ts.map +1 -0
  20. package/dist/emoji.js +73 -0
  21. package/dist/emoji.js.map +1 -0
  22. package/dist/flavors.d.ts +68 -0
  23. package/dist/flavors.d.ts.map +1 -0
  24. package/dist/flavors.js +223 -0
  25. package/dist/flavors.js.map +1 -0
  26. package/dist/index.d.ts +10 -5
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +7 -4
  29. package/dist/index.js.map +1 -1
  30. package/dist/markdown.d.ts +12 -3
  31. package/dist/markdown.d.ts.map +1 -1
  32. package/dist/markdown.js +424 -379
  33. package/dist/markdown.js.map +1 -1
  34. package/dist/mcp.d.ts +2 -0
  35. package/dist/mcp.d.ts.map +1 -0
  36. package/dist/mcp.js +301 -0
  37. package/dist/mcp.js.map +1 -0
  38. package/dist/print.d.ts +3 -3
  39. package/dist/print.d.ts.map +1 -1
  40. package/dist/print.js +8 -3
  41. package/dist/print.js.map +1 -1
  42. package/dist/roles.d.ts.map +1 -1
  43. package/dist/roles.js +17 -0
  44. package/dist/roles.js.map +1 -1
  45. package/dist/viewer.d.ts +5 -0
  46. package/dist/viewer.d.ts.map +1 -1
  47. package/dist/viewer.js +375 -60
  48. package/dist/viewer.js.map +1 -1
  49. package/package.json +18 -6
package/README.md CHANGED
@@ -1,7 +1,12 @@
1
1
  # readm3
2
2
 
3
- A terminal markdown reader. File browser on the left, the rendered document on
4
- the right, and nothing else in the way.
3
+ Markdown editing and sharing for people and teams, with a terminal reader and editor. File browser on the left, the rendered
4
+ document on the right, and nothing else in the way. Press `e` to edit the file
5
+ you are looking at, `esc` to see it rendered again.
6
+
7
+ CommonMark and GitHub Flavored Markdown, plus the extras each dialect added on
8
+ top: GitHub alerts, footnotes and `:emoji:`, and Reddit spoilers, superscript
9
+ and `r/` `u/` links.
5
10
 
6
11
  Built on [HQTUI](https://github.com/profullstack/hqtui) — truecolor, mouse, and
7
12
  a terminal that gets restored no matter how the process dies.
@@ -76,22 +81,73 @@ pruned, `node_modules` and friends are never walked, and README sorts first.
76
81
  | `enter` | open the file | `esc` | clear the filter |
77
82
  | `space` `b` | page down / up | `r` | rescan and reload |
78
83
  | `g` `G` | top / bottom | `[` `]` | sidebar width |
79
- | `?` | help | `q` `ctrl+c` | quit |
84
+ | `e` `i` | edit this file | `s` | reveal spoilers |
85
+ | `ctrl+s` | save | `?` | help |
86
+ | | | `q` `ctrl+c` | quit |
80
87
 
81
88
  The mouse works too: the wheel scrolls whichever pane it is over, and a click
82
89
  opens a file.
83
90
 
91
+ ### Editing
92
+
93
+ `e` puts the caret in the file. `esc` takes it out, and the preview re-renders
94
+ what you just typed — there is no separate preview pane to keep in step,
95
+ because both modes read the same buffer.
96
+
97
+ | | | | |
98
+ |---|---|---|---|
99
+ | `esc` | back to the preview | `ctrl+s` | save |
100
+ | `ctrl+z` `ctrl+y` | undo / redo | `ctrl+g` | keys |
101
+ | `ctrl+a` `ctrl+e` | line start / end | `ctrl+k` | kill to end of line |
102
+ | `ctrl+←` `ctrl+→` | move by word | `ctrl+u` | kill to start of line |
103
+ | `ctrl+home` `ctrl+end` | top / bottom | `tab` | indent two spaces |
104
+
105
+ `enter` continues the list you are in — the same bullet, the next number, an
106
+ unchecked box for a task — and ends it when you press it on an empty item.
107
+ Quitting or switching files with unsaved changes asks first. `--read-only`
108
+ turns editing off entirely, for use as a pager.
109
+
110
+ There is no selection, and so no cut and paste: this is a place to fix a typo
111
+ and add a paragraph, not a replacement for your editor. `$EDITOR` is still
112
+ `$EDITOR`.
113
+
84
114
  ## What it renders
85
115
 
86
- Headings, **bold**, *italic*, `inline code`, links, fenced and indented code
87
- blocks with a language label, ordered and unordered lists, nested lists, task
88
- lists, blockquotes, tables with per-column alignment, horizontal rules, images
89
- as labelled placeholders, and YAML front matter — shown rather than hidden,
90
- because it is usually what you opened the file for.
116
+ Parsing is [marked](https://github.com/markedjs/marked) — CommonMark and GFM.
117
+ The terminal UI uses HQTUI; the cloud tools use the official MCP SDK.
118
+
119
+ Headings, **bold**, *italic*, `inline code`, links, reference links, bare URLs,
120
+ fenced and indented code blocks with a language label, ordered and unordered
121
+ lists, nested lists, task lists, blockquotes, tables with per-column alignment,
122
+ strikethrough, hard line breaks, horizontal rules, images as labelled
123
+ placeholders, and YAML front matter — shown rather than hidden, because it is
124
+ usually what you opened the file for.
91
125
 
92
126
  The HTML that real READMEs are full of is folded back into markdown rather than
93
- printed as tags, and inline code is held out of that, so `Array<string>`
94
- survives.
127
+ printed as tags, and code is held out of that, so `Array<string>` survives.
128
+
129
+ ### Flavors
130
+
131
+ `--flavor` picks which dialect's extras are honored. The default is `github`.
132
+
133
+ | flavor | adds |
134
+ |---|---|
135
+ | `commonmark` | nothing beyond CommonMark |
136
+ | `github` | GFM, alerts (`> [!WARNING]`), footnotes (`[^1]`), `:emoji:` |
137
+ | `reddit` | GFM, spoilers (`>!hidden!<`), superscript (`^(text)`), `r/` and `u/` links |
138
+ | `all` | both dialects at once |
139
+
140
+ It matters which one you pick. `2^32` is a number in a README and a superscript
141
+ on Reddit, and `>!spoiler!<` is a blockquote everywhere except Reddit — so the
142
+ flavor decides, rather than every document getting every rule.
143
+
144
+ Alerts get a gutter colored by severity. Footnotes are numbered in order of
145
+ first reference and collected under a rule at the foot of the document.
146
+ Superscript uses real Unicode glyphs when every character has one (`mc^2`
147
+ becomes mc²) and keeps its caret when they do not, because there is no
148
+ superscript `q`. Spoilers are blocked out with `█` rather than colored out, so
149
+ they stay hidden in a pipe and with `--color never`; `s` reveals them in the
150
+ reader, `--spoilers` in `--print`.
95
151
 
96
152
  ## Options
97
153
 
@@ -103,6 +159,9 @@ survives.
103
159
  monochrome, high-contrast, light
104
160
  -w, --width <n> sidebar width in columns, or the render width with --print
105
161
  (default: 28% of the terminal, its full width printing)
162
+ -f, --flavor <name> commonmark, github (default), reddit, or all
163
+ --spoilers reveal spoiler text instead of blocking it out
164
+ -R, --read-only refuse to edit, for use as a pager
106
165
  -a, --all include dot-directories and dotfiles
107
166
  -M, --no-mouse disable mouse tracking
108
167
  -v, --version
@@ -111,8 +170,8 @@ survives.
111
170
 
112
171
  ## As a library
113
172
 
114
- The renderer and the file tree are pure and need no terminal, so they can be
115
- reused on their own:
173
+ The renderer, the file tree and the edit buffer are pure and need no terminal,
174
+ so they can be reused on their own:
116
175
 
117
176
  ```ts
118
177
  import { renderMarkdown, toText, renderAnsi, scan, files } from "@profullstack/readm3";
@@ -121,9 +180,26 @@ const lines = renderMarkdown("# Hello\n\nSome **text**.", 60);
121
180
  console.log(toText(lines));
122
181
  // [ 'Hello', '━━━…', '', 'Some text.' ]
123
182
 
183
+ // A flavor, and spoilers revealed.
184
+ renderMarkdown(post, 60, { flavor: "reddit", spoilers: true });
185
+
124
186
  for (const file of files(scan("./docs"))) console.log(file.path);
125
187
  ```
126
188
 
189
+ The edit buffer is a plain object with functions over it, so the editing rules
190
+ can be tested without a screen:
191
+
192
+ ```ts
193
+ import { createEditor, insert, newline, undo, text } from "@profullstack/readm3";
194
+
195
+ const ed = createEditor("- first");
196
+ ed.col = 7;
197
+ newline(ed); // continues the list
198
+ insert(ed, "second");
199
+ console.log(text(ed)); // "- first\n- second"
200
+ undo(ed);
201
+ ```
202
+
127
203
  `renderMarkdown` returns lines of spans carrying a semantic `role` — `h1`,
128
204
  `code`, `link`, `quote` and so on — rather than colors, so the same document can
129
205
  be re-themed without re-parsing. `renderAnsi(source, width, theme, depth)` is
@@ -139,12 +215,145 @@ Windows Terminal.
139
215
  ```bash
140
216
  bun install
141
217
  bun src/cli.ts . # run it against its own repo
142
- bun test test/ # 68 tests, no TTY needed
218
+ bun test ./test # 68 tests, no TTY needed
143
219
  npm test # the same tests on node
144
220
  bun run typecheck
145
221
  bun run build
146
222
  ```
147
223
 
224
+ ## Shared documents, organizations, and teams
225
+
226
+ Read and edit online at https://readm3.com/viewer, and manage your account at
227
+ https://readm3.com/admin. Create private Markdown files, share view or edit links,
228
+ add named collaborators, and grant access to an organization or team. Every link
229
+ opens in read mode. File owners manage permissions and deletion; editors save new
230
+ versions; the super administrator can manage every user's documents.
231
+
232
+ Every online save creates an immutable version with a short ID and SHA-256 checksum.
233
+ Stale saves are rejected so concurrent edits cannot silently overwrite each other.
234
+ Owners can restore prior versions, pin links to a version, and revoke links.
235
+
236
+ ```sh
237
+ readm3 login --token-stdin # token from /admin → API tokens
238
+ readm3 orgs list
239
+ readm3 share README.md --org ORG_ID # view link by default
240
+ readm3 docs update DOC_ID notes.md --base VERSION_ID
241
+ readm3 docs history DOC_ID
242
+ readm3 mcp # stdio MCP, same account permissions
243
+ ```
244
+
245
+ The REST API is at `/api/v1`, with all operations also available through
246
+ `POST /api/v1/actions` and `readm3 cloud OPERATION --args JSON`.
247
+ Full permissions, accounts, CLI, API, and MCP documentation: https://readm3.com/sharing.
248
+
249
+ ## Web reader
250
+
251
+ Open https://readm3.com/viewer for the same two-pane Markdown reader in your browser.
252
+ Open local files or a folder, drop Markdown files into the window, open a raw URL or
253
+ GitHub file link, or start a new note. The explorer filters files, prunes hidden and
254
+ build directories, and sorts README first. All nine themes and Markdown flavors use
255
+ the same renderer as the terminal.
256
+
257
+ Press `/` to filter, `e` to edit, `Escape` to return to reading, and `?` for shortcuts.
258
+ `Ctrl+S` / `⌘S` downloads the current Markdown. Files and edits are saved in IndexedDB
259
+ on this device; originals on disk are never overwritten. Reopening a file adds a copy
260
+ so an existing draft is preserved. Clearing browser site data removes the workspace.
261
+
262
+ Install through your browser’s app menu, or Share → Add to Home Screen on iOS.
263
+ After the first visit, the application and saved workspace work offline. Remote URLs
264
+ need a connection and a host that permits browser access (CORS); files are fetched
265
+ directly with no credentials or server proxy. Local files are uploaded only when you explicitly choose Share → Save online.
266
+
267
+ Imports are limited to 4 MB per file, 20 MB per workspace, and 1,000 files.
268
+
269
+ ## The website
270
+
271
+ ### Accounts
272
+
273
+ Open https://readm3.com/account to create an email-verified account or sign in.
274
+ The email link expires after 15 minutes and works once. A confirmation button
275
+ prevents email scanners from consuming links. Accounts are created only after
276
+ verification; returning users sign in to the same identity. Account settings
277
+ include display name, sign out, and sign out on all devices.
278
+
279
+ The server stores accounts, hashed sessions, verification challenges, and rate
280
+ limits in SQLite. Set `READM3_DB` to a persistent volume path (production uses
281
+ `/data/readm3.sqlite`), `READM3_URL` to the canonical public origin,
282
+ `READM3_MAIL_FROM` to a verified sender, and `RESEND_API_KEY` to an email-sending key.
283
+ Missing or failed mail delivery returns an error; verification links are never
284
+ printed to logs. Production cookies are Secure, HttpOnly, SameSite=Lax, and
285
+ host-scoped. The account page and APIs are excluded from offline caches.
286
+
287
+ On Railway, attach a volume at `/data`, keep a single replica, and set
288
+ `RAILWAY_RUN_UID=0` for the root-owned volume. Back up the volume before changing
289
+ the account schema. The local reader remains usable without an account.
290
+
291
+ ```bash
292
+ bun run test:accounts # account security tests and browser signup flow
293
+ ```
294
+
295
+ The account service is `server/accounts.ts`. It can accept an existing Bun SQLite
296
+ `Database` so workspace APIs share the same `users` and `sessions` tables.
297
+ `account_emails` holds the verified identity associated with each user ID.
298
+ Use `Accounts.authenticate(token)` or `Accounts.requireAccount(request)` when
299
+ authorizing organization, team, role, or API-token operations: these methods
300
+ reject sessions whose user has no verified email. Browser sessions use
301
+ `__Host-readm3_session` over HTTPS and `readm3_session` on localhost.
302
+ Do not enable a separate unverified registration or password-recovery path.
303
+
304
+ | Endpoint | Purpose |
305
+ | --- | --- |
306
+ | `POST /api/auth/email` | Send a sign-in link for an email address |
307
+ | `POST /api/auth/preview` | Show the email associated with an unconsumed link |
308
+ | `POST /api/auth/verify` | Consume the link and set a browser session |
309
+ | `GET /api/auth/session` | Return the verified account, or `null` |
310
+ | `POST /api/auth/profile` | Update the current account's display name |
311
+ | `POST /api/auth/logout` | Revoke the current session |
312
+ | `POST /api/auth/logout-all` | Revoke all sessions belonging to the account |
313
+
314
+ POST requests require JSON and an `Origin` matching `READM3_URL`.
315
+
316
+ ### Building and serving
317
+
318
+ [readm3.com](https://readm3.com) is built from this repository by `site/build.ts`,
319
+ which renders every document on the page through `renderMarkdown` and takes every
320
+ color from a real HQTUI theme. There is no second implementation to keep in sync:
321
+ change the parser and the site changes with it.
322
+
323
+ ```bash
324
+ bun run site:build # writes site/dist
325
+ bun run site:start # serves it on $PORT, default 3000
326
+ bun x playwright install chromium # once, for browser checks
327
+ bun run test:site # imports, editing, persistence, offline PWA, and mobile layout
328
+ ```
329
+
330
+ The site build bundles `site/viewer.ts` for browsers, generates content-addressed
331
+ assets, and precaches the viewer shell through a service worker scoped to `/viewer`.
332
+ Updates wait until the reader chooses **Update available**; drafts are saved before
333
+ reloading. The web viewer does not load the marketing site’s third-party scripts.
334
+
335
+ ## Hosting shared documents
336
+
337
+ The web server uses Bun and SQLite. Set `READM3_DB` to a database file on persistent
338
+ storage, and `READM3_URL` to the public HTTPS origin. The Docker image uses
339
+ `/data/readm3.sqlite`; mount a volume at `/data`. On Railway set `RAILWAY_RUN_UID=0`
340
+ for access to the mounted volume. Use one service replica for SQLite and configure
341
+ volume backups in the hosting platform.
342
+
343
+ Set `READM3_ADMIN_BOOTSTRAP_SECRET` to a random secret. Sign in at `/account` as
344
+ the intended super administrator, then open `/admin#claim=YOUR_SECRET`. This is a
345
+ one-time claim stored in the database. Never publish this URL; remove the environment
346
+ secret after claiming. Email sign-in never grants administrator access by itself.
347
+
348
+ Accounts use verified email sign-in and HttpOnly cookies. API tokens and share
349
+ capabilities are stored as SHA-256 hashes. Shared documents are not cached in the
350
+ PWA or saved in the browser's local workspace, so revocation applies to future access.
351
+
352
+ ```sh
353
+ bun run test:server # auth, roles, version history, persistence, CLI and MCP
354
+ bun run test:site # local/offline reader plus browser sharing and admin workflows
355
+ ```
356
+
148
357
  ## License
149
358
 
150
359
  MIT.
package/dist/cli.d.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  import { type ColorMode } from "./print.ts";
2
2
  import { type ViewerOptions } from "./viewer.ts";
3
- export declare const VERSION = "0.2.0";
3
+ export declare const VERSION = "0.4.0";
4
+ /** The help text, exported so a test can hold it to the flags it documents. */
5
+ export declare const USAGE: string;
4
6
  export interface ParsedArgs extends ViewerOptions {
5
7
  help: boolean;
6
8
  version: boolean;
7
9
  /** Render to stdout instead of opening the reader. */
8
10
  print: boolean;
9
11
  color: ColorMode;
12
+ /** Reveal spoiler text rather than blocking it out. */
13
+ spoilers: boolean;
10
14
  }
11
15
  export declare function parseArgs(argv: string[]): ParsedArgs;
12
16
  export declare function main(argv?: string[]): Promise<void>;
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAOA,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAO,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtD,eAAO,MAAM,OAAO,UAAU,CAAC;AAiC/B,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,sDAAsD;IACtD,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,SAAS,CAAC;CAClB;AAID,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA2FpD;AAED,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAiChF"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAQA,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAO,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAGtD,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,+EAA+E;AAC/E,eAAO,MAAM,KAAK,QA2CH,CAAC;AAEhB,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,sDAAsD;IACtD,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,SAAS,CAAC;IACjB,uDAAuD;IACvD,QAAQ,EAAE,OAAO,CAAC;CACnB;AAID,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CA6GpD;AAED,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAyChF"}
package/dist/cli.js CHANGED
@@ -5,10 +5,13 @@ import { statSync } from "node:fs";
5
5
  import { dirname, resolve } from "node:path";
6
6
  import { pathToFileURL } from "node:url";
7
7
  import { themeList } from "@profullstack/hqtui";
8
+ import { FLAVORS, isFlavor } from "./flavors.js";
8
9
  import { printDocument, COLOR_MODES } from "./print.js";
9
10
  import { run } from "./viewer.js";
10
- export const VERSION = "0.2.0";
11
- const USAGE = `readm3 — a terminal markdown reader
11
+ import { isCloudCommand, cloudMain, CLOUD_USAGE } from "./cloud-cli.js";
12
+ export const VERSION = "0.4.0";
13
+ /** The help text, exported so a test can hold it to the flags it documents. */
14
+ export const USAGE = `readm3 — a terminal markdown reader and editor
12
15
 
13
16
  Usage
14
17
  readm3 [path] [options]
@@ -25,6 +28,11 @@ Options
25
28
  -w, --width <n> Sidebar width in columns, or the render width with
26
29
  --print. Default: 28% of the terminal, and its full
27
30
  width when printing
31
+ -f, --flavor <name> Markdown dialect. One of: ${FLAVORS.join(", ")}.
32
+ Default: github (GFM, alerts, footnotes, :emoji:).
33
+ reddit adds spoilers, superscript and r/ u/ links
34
+ --spoilers Reveal spoiler text instead of blocking it out
35
+ -R, --read-only Refuse to edit, for use as a pager
28
36
  -a, --all Include dot-directories and dotfiles
29
37
  -M, --no-mouse Disable mouse tracking
30
38
  -v, --version Print the version
@@ -35,9 +43,18 @@ Keys
35
43
  right/left l h expand or collapse / filter files
36
44
  enter open the file r rescan and reload
37
45
  space / b page down / up [ ] sidebar width
38
- g / G top / bottom ? help
39
- q quit
40
- `;
46
+ g / G top / bottom s reveal spoilers
47
+ e / i edit this file ? help
48
+ ctrl+s save q quit
49
+
50
+ Editing
51
+ esc back to the preview, which re-renders as you left it
52
+ ctrl+z ctrl+y undo / redo ctrl+k kill to end of line
53
+ ctrl+a ctrl+e line start / end ctrl+u kill to start of line
54
+ ctrl+arrow move by word enter split, continuing a list
55
+ ctrl+g keys for editing tab indent two spaces
56
+
57
+ ${CLOUD_USAGE}`;
41
58
  class UsageError extends Error {
42
59
  }
43
60
  export function parseArgs(argv) {
@@ -47,8 +64,10 @@ export function parseArgs(argv) {
47
64
  version: false,
48
65
  print: false,
49
66
  color: "auto",
67
+ spoilers: false,
50
68
  mouse: true,
51
69
  all: false,
70
+ readOnly: false,
52
71
  };
53
72
  let target;
54
73
  for (let i = 0; i < argv.length; i++) {
@@ -92,6 +111,22 @@ export function parseArgs(argv) {
92
111
  parsed.color = value;
93
112
  break;
94
113
  }
114
+ case "-f":
115
+ case "--flavor": {
116
+ const value = next();
117
+ if (!isFlavor(value)) {
118
+ throw new UsageError(`--flavor must be one of: ${FLAVORS.join(", ")}`);
119
+ }
120
+ parsed.flavor = value;
121
+ break;
122
+ }
123
+ case "--spoilers":
124
+ parsed.spoilers = true;
125
+ break;
126
+ case "-R":
127
+ case "--read-only":
128
+ parsed.readOnly = true;
129
+ break;
95
130
  case "-a":
96
131
  case "--all":
97
132
  parsed.all = true;
@@ -136,6 +171,10 @@ export function parseArgs(argv) {
136
171
  return parsed;
137
172
  }
138
173
  export async function main(argv = process.argv.slice(2)) {
174
+ if (isCloudCommand(argv[0])) {
175
+ await cloudMain(argv);
176
+ return;
177
+ }
139
178
  let args;
140
179
  try {
141
180
  args = parseArgs(argv);
@@ -157,7 +196,14 @@ export async function main(argv = process.argv.slice(2)) {
157
196
  return;
158
197
  }
159
198
  if (args.print) {
160
- printDocument({ path: args.open, width: args.sidebar, theme: args.theme, color: args.color });
199
+ printDocument({
200
+ path: args.open,
201
+ width: args.sidebar,
202
+ theme: args.theme,
203
+ color: args.color,
204
+ flavor: args.flavor,
205
+ spoilers: args.spoilers,
206
+ });
161
207
  return;
162
208
  }
163
209
  if (!process.stdout.isTTY) {
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAkB,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,GAAG,EAAsB,MAAM,aAAa,CAAC;AAEtD,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,MAAM,KAAK,GAAG;;;;;;;;;;;;;8CAagC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE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nC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const CLOUD_USAGE = "Shared Markdown\n readm3 login --token-stdin Save a personal API token securely\n readm3 logout Remove the local token\n readm3 share FILE --org ID [--role view|edit]\n readm3 docs list [--org ID] [--search TEXT] [--limit N] [--offset N]\n readm3 docs get ID [--raw]\n readm3 docs create FILE --org ID [--title NAME]\n readm3 docs update ID FILE --base VERSION\n readm3 docs delete ID\n readm3 docs history ID\n readm3 docs restore ID --version VERSION --base CURRENT\n readm3 docs share ID [--role view|edit] [--version VERSION]\n readm3 docs revoke ID --share SHARE_ID\n readm3 docs transfer ID --username USERNAME\n readm3 shared get URL [--raw]\n readm3 shared update URL FILE --base VERSION\n readm3 orgs list | create --name NAME | update ID --name NAME | delete ID\n readm3 teams list --org ID | create --org ID --name NAME\n readm3 members list --org ID\n readm3 cloud OPERATION --args '{\"key\":\"value\"}'\n readm3 mcp Start the stdio MCP server\n\nFILE may be - for stdin. --raw prints Markdown; other results are JSON.\nREADM3_URL selects a self-hosted server; READM3_TOKEN supplies an API token.\nView links cannot write. Edit links can save versions. Owners administer files.\nUse readm3 cloud for the full API, including team membership and permissions.\n";
2
+ export declare function isCloudCommand(command: string | undefined): boolean;
3
+ export declare function cloudMain(argv: string[]): Promise<void>;
4
+ //# sourceMappingURL=cloud-cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-cli.d.ts","sourceRoot":"","sources":["../src/cloud-cli.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,WAAW,m1CA0BvB,CAAC;AAaF,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,WAEzD;AACD,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,iBAiJ7C"}
@@ -0,0 +1,192 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { basename } from "node:path";
3
+ import { cloudAction, cloudConfig, cloudRequest, clearCloudConfig, saveCloudConfig, sharedLocation, } from "./cloud-client.js";
4
+ export const CLOUD_USAGE = `Shared Markdown
5
+ readm3 login --token-stdin Save a personal API token securely
6
+ readm3 logout Remove the local token
7
+ readm3 share FILE --org ID [--role view|edit]
8
+ readm3 docs list [--org ID] [--search TEXT] [--limit N] [--offset N]
9
+ readm3 docs get ID [--raw]
10
+ readm3 docs create FILE --org ID [--title NAME]
11
+ readm3 docs update ID FILE --base VERSION
12
+ readm3 docs delete ID
13
+ readm3 docs history ID
14
+ readm3 docs restore ID --version VERSION --base CURRENT
15
+ readm3 docs share ID [--role view|edit] [--version VERSION]
16
+ readm3 docs revoke ID --share SHARE_ID
17
+ readm3 docs transfer ID --username USERNAME
18
+ readm3 shared get URL [--raw]
19
+ readm3 shared update URL FILE --base VERSION
20
+ readm3 orgs list | create --name NAME | update ID --name NAME | delete ID
21
+ readm3 teams list --org ID | create --org ID --name NAME
22
+ readm3 members list --org ID
23
+ readm3 cloud OPERATION --args '{"key":"value"}'
24
+ readm3 mcp Start the stdio MCP server
25
+
26
+ FILE may be - for stdin. --raw prints Markdown; other results are JSON.
27
+ READM3_URL selects a self-hosted server; READM3_TOKEN supplies an API token.
28
+ View links cannot write. Edit links can save versions. Owners administer files.
29
+ Use readm3 cloud for the full API, including team membership and permissions.
30
+ `;
31
+ const commands = new Set([
32
+ "login",
33
+ "logout",
34
+ "share",
35
+ "docs",
36
+ "shared",
37
+ "orgs",
38
+ "teams",
39
+ "members",
40
+ "cloud",
41
+ "mcp",
42
+ ]);
43
+ export function isCloudCommand(command) {
44
+ return !!command && commands.has(command);
45
+ }
46
+ export async function cloudMain(argv) {
47
+ if (argv.includes("--help") || argv.includes("-h")) {
48
+ process.stdout.write(CLOUD_USAGE);
49
+ return;
50
+ }
51
+ const command = argv[0];
52
+ if (command === "mcp") {
53
+ const { runMcp } = await import("./mcp.js");
54
+ await runMcp();
55
+ return;
56
+ }
57
+ const flags = {};
58
+ const positional = [];
59
+ for (let i = 1; i < argv.length; i++) {
60
+ const value = argv[i];
61
+ if (value.startsWith("--")) {
62
+ const name = value.slice(2);
63
+ if (["raw", "token-stdin", "json"].includes(name))
64
+ flags[name] = "true";
65
+ else {
66
+ if (!argv[i + 1] || argv[i + 1].startsWith("--"))
67
+ throw new Error(`${value} needs a value.`);
68
+ flags[name] = argv[++i];
69
+ }
70
+ }
71
+ else
72
+ positional.push(value);
73
+ }
74
+ const output = (value) => process.stdout.write(JSON.stringify(value, null, 2) + "\n");
75
+ const fileSource = (file) => {
76
+ if (!file)
77
+ throw new Error("A Markdown file is required.");
78
+ const value = readFileSync(file === "-" ? 0 : file, "utf8");
79
+ if (Buffer.byteLength(value) > 1024 * 1024)
80
+ throw new Error("Shared documents are limited to 1 MB.");
81
+ return value;
82
+ };
83
+ if (command === "login") {
84
+ if (!flags["token-stdin"])
85
+ throw new Error("Use --token-stdin and paste the API token, then end input (Ctrl+D). Tokens are created at /admin.");
86
+ const token = readFileSync(0, "utf8").trim();
87
+ if (!token)
88
+ throw new Error("No token supplied.");
89
+ const config = { ...cloudConfig(), token };
90
+ const user = await cloudAction("account_me", {}, config);
91
+ saveCloudConfig(config);
92
+ output({ signedIn: true, user });
93
+ return;
94
+ }
95
+ if (command === "logout") {
96
+ clearCloudConfig();
97
+ output({
98
+ signedOut: true,
99
+ note: "Revoke the token in /admin to invalidate other copies.",
100
+ });
101
+ return;
102
+ }
103
+ if (command === "cloud") {
104
+ if (!positional[0])
105
+ throw new Error(CLOUD_USAGE);
106
+ const args = flags.args ? JSON.parse(flags.args) : {};
107
+ output(await cloudAction(positional[0], args));
108
+ return;
109
+ }
110
+ if (command === "shared") {
111
+ const [verb, url, file] = positional;
112
+ if (!["get", "update"].includes(verb))
113
+ throw new Error("Use shared get or shared update.");
114
+ if (!url)
115
+ throw new Error("A shared document URL is required.");
116
+ const { token, config } = sharedLocation(url);
117
+ const result = await cloudRequest(`shared/${token}`, verb === "update" ? "PATCH" : "GET", verb === "update"
118
+ ? { source: fileSource(file), baseVersion: flags.base }
119
+ : undefined, config);
120
+ if (!["get", "update"].includes(verb))
121
+ throw new Error("Use shared get or shared update.");
122
+ if (flags.raw)
123
+ process.stdout.write(result.version.source);
124
+ else
125
+ output(result);
126
+ return;
127
+ }
128
+ const args = {};
129
+ const names = {
130
+ org: "orgId",
131
+ team: "teamId",
132
+ base: "baseVersion",
133
+ version: "versionId",
134
+ share: "shareId",
135
+ user: "userId",
136
+ };
137
+ for (const [name, value] of Object.entries(flags))
138
+ if (!["raw", "json"].includes(name))
139
+ args[names[name] || name] = value;
140
+ if (command === "share") {
141
+ const file = positional[0];
142
+ const doc = await cloudAction("documents_create", {
143
+ ...args,
144
+ title: flags.title || basename(file || "Document.md"),
145
+ source: fileSource(file),
146
+ });
147
+ output(await cloudAction("shares_create", {
148
+ documentId: doc.id,
149
+ role: flags.role || "view",
150
+ }));
151
+ return;
152
+ }
153
+ const [verb, identifier, file] = positional;
154
+ if (command === "docs") {
155
+ const operations = {
156
+ list: "documents_list",
157
+ get: "documents_get",
158
+ create: "documents_create",
159
+ update: "documents_update",
160
+ delete: "documents_delete",
161
+ history: "versions_list",
162
+ restore: "versions_restore",
163
+ share: "shares_create",
164
+ revoke: "shares_revoke",
165
+ transfer: "documents_transfer",
166
+ };
167
+ const op = operations[verb];
168
+ if (!op)
169
+ throw new Error(CLOUD_USAGE);
170
+ if (verb === "create") {
171
+ args.source = fileSource(identifier);
172
+ args.title = flags.title || basename(identifier || "Document.md");
173
+ }
174
+ else if (verb !== "list")
175
+ args.documentId = identifier;
176
+ if (verb === "update")
177
+ args.source = fileSource(file);
178
+ const result = await cloudAction(op, args);
179
+ if (flags.raw && result.version)
180
+ process.stdout.write(result.version.source);
181
+ else
182
+ output(result);
183
+ return;
184
+ }
185
+ const prefix = command === "orgs" ? "organizations" : command;
186
+ if (!["list", "create", "update", "delete", "remove"].includes(verb))
187
+ throw new Error(CLOUD_USAGE);
188
+ if (identifier)
189
+ args[command === "orgs" ? "orgId" : command === "teams" ? "teamId" : "userId"] = identifier;
190
+ output(await cloudAction(`${prefix}_${verb}`, args));
191
+ }
192
+ //# sourceMappingURL=cloud-cli.js.map