attnmd 0.3.4 → 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.
- package/README.md +139 -38
- package/bin/attn.js +130 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,56 +1,122 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<h1 align="center">attn</h1>
|
|
3
3
|
<p align="center">
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
Read markdown beautifully. Review it together.<br>
|
|
5
|
+
Native window. End-to-end encrypted collaboration. No Electron.
|
|
6
6
|
</p>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
+
<a href="#collaboration">Collaboration</a> ·
|
|
10
11
|
<a href="#install">Install</a> ·
|
|
11
|
-
<a href="
|
|
12
|
-
<a href="
|
|
12
|
+
<a href="#usage">Usage</a> ·
|
|
13
|
+
<a href="https://github.com/lightsofapollo/attn/issues">Issues</a>
|
|
13
14
|
</p>
|
|
14
15
|
|
|
15
16
|
---
|
|
16
17
|
|
|
17
18
|
<p align="center">
|
|
18
|
-
<
|
|
19
|
+
<picture>
|
|
20
|
+
<source media="(prefers-color-scheme: dark)" srcset="site/static/screenshots/collab-dark.png">
|
|
21
|
+
<img src="site/static/screenshots/collab-light.png" alt="attn showing a shared markdown review with comments, suggestions, and a collaborator cursor" width="860">
|
|
22
|
+
</picture>
|
|
19
23
|
</p>
|
|
20
24
|
|
|
21
25
|
```bash
|
|
22
26
|
attn .
|
|
23
27
|
```
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
attn opens your markdown in a native desktop window with a file tree, tabs,
|
|
30
|
+
live reload, and a real editor. When a document needs feedback, hit Share and
|
|
31
|
+
send an invite link. Reviewers can comment, suggest edits, and co-edit from the
|
|
32
|
+
same markdown surface.
|
|
33
|
+
|
|
34
|
+
No account. No browser tab. No Electron runtime. The review relay only sees
|
|
35
|
+
encrypted bytes.
|
|
26
36
|
|
|
27
37
|
## Why attn?
|
|
28
38
|
|
|
29
|
-
|
|
39
|
+
Markdown usually lives in your repo, but review often moves somewhere else:
|
|
40
|
+
screenshots, pasted docs, stale exported PDFs, or a SaaS editor with a copy of
|
|
41
|
+
your source.
|
|
42
|
+
|
|
43
|
+
attn keeps the source of truth local and makes review a layer over the file you
|
|
44
|
+
already have. You get a focused reader, a capable editor, and an encrypted
|
|
45
|
+
review room without changing how your project is organized.
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- **Beautiful markdown rendering** - readable line length, careful typography,
|
|
50
|
+
syntax-highlighted code, tables, task lists, math, and Mermaid diagrams.
|
|
51
|
+
- **Live reload** - save in Vim, VS Code, Zed, or any editor and the native
|
|
52
|
+
window updates immediately.
|
|
53
|
+
- **Built-in editor** - toggle a ProseMirror editor with `Cmd+E` when you want
|
|
54
|
+
to edit in place.
|
|
55
|
+
- **Interactive checkboxes** - click a `- [ ]` task and attn writes the change
|
|
56
|
+
back to the file.
|
|
57
|
+
- **Project file tree** - browse folders, lazy-load large repos, and jump to
|
|
58
|
+
files with fuzzy search.
|
|
59
|
+
- **Tabs and project switching** - keep multiple files open and move between
|
|
60
|
+
remembered workspaces.
|
|
61
|
+
- **Native media preview** - images, video, and audio open alongside markdown.
|
|
62
|
+
- **Light and dark themes** - paper-and-ink light mode plus a low-glare dark
|
|
63
|
+
mode.
|
|
64
|
+
- **Single-instance CLI** - run `attn` from many terminals; one daemon receives
|
|
65
|
+
new files as tabs.
|
|
66
|
+
|
|
67
|
+
## Collaboration
|
|
68
|
+
|
|
69
|
+
attn's review flow is built for markdown that should stay private and local.
|
|
70
|
+
|
|
71
|
+
- **Share in one click** - use the Share button, the breadcrumb/share menu, or
|
|
72
|
+
`Cmd+Shift+S` to create a review room for the active markdown file.
|
|
73
|
+
- **Encrypted invite links** - send an `attn://review/...#key=...` link or the
|
|
74
|
+
generated `npx attnmd ...` command. The room key is in the invite fragment,
|
|
75
|
+
not on the relay.
|
|
76
|
+
- **Comments and suggestions** - reviewers anchor feedback to selected text;
|
|
77
|
+
suggestions appear beside the document with Accept/Reject actions.
|
|
78
|
+
- **Live cursors and co-editing** - connected reviewers show up in the document
|
|
79
|
+
and sidebar so you can see where people are reading or editing.
|
|
80
|
+
- **Hybrid transport** - attn uses direct peer-to-peer collaboration when it can
|
|
81
|
+
and falls back to the encrypted relay when it cannot.
|
|
82
|
+
- **Folder share** - share a directory to publish snapshots for every markdown
|
|
83
|
+
file under it; newly added markdown files are picked up by the watcher.
|
|
84
|
+
|
|
85
|
+
Owner flow:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
attn path/to/docs
|
|
89
|
+
# In the app: Share, or Cmd+Shift+S
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
CLI share flow:
|
|
30
93
|
|
|
31
|
-
|
|
94
|
+
```bash
|
|
95
|
+
attn review share path/to/docs
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Reviewer flow:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
attn review join 'attn://review/<room-id>#key=<secret>'
|
|
102
|
+
```
|
|
32
103
|
|
|
33
|
-
|
|
104
|
+
For headless reviewers or agents:
|
|
34
105
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
- **Tabs + projects** — open multiple files, switch between projects with `Cmd+;`. attn remembers your workspaces.
|
|
40
|
-
- **Mermaid diagrams** — flowcharts, sequence diagrams, and more render inline from fenced code blocks.
|
|
41
|
-
- **Media support** — images (with zoom/pan), video, and audio play natively.
|
|
42
|
-
- **Paper & ink themes** — warm parchment light theme by default, cool dark theme with `--dark`.
|
|
43
|
-
- **Single instance** — run `attn` from ten terminals. One daemon, one window, new tab each time.
|
|
106
|
+
```bash
|
|
107
|
+
attn review register-agent reviewer
|
|
108
|
+
attn review join 'attn://review/<room-id>#key=<secret>' --as-agent reviewer
|
|
109
|
+
```
|
|
44
110
|
|
|
45
111
|
## Install
|
|
46
112
|
|
|
47
|
-
###
|
|
113
|
+
### Homebrew
|
|
48
114
|
|
|
49
115
|
```bash
|
|
50
|
-
|
|
116
|
+
brew install lightsofapollo/attn/attn
|
|
51
117
|
```
|
|
52
118
|
|
|
53
|
-
###
|
|
119
|
+
### npm
|
|
54
120
|
|
|
55
121
|
```bash
|
|
56
122
|
npx attnmd
|
|
@@ -62,11 +128,11 @@ npm install -g attnmd && attn
|
|
|
62
128
|
|
|
63
129
|
```bash
|
|
64
130
|
git clone https://github.com/lightsofapollo/attn.git
|
|
65
|
-
cd attn
|
|
131
|
+
cd attn
|
|
132
|
+
cargo install --path .
|
|
66
133
|
```
|
|
67
134
|
|
|
68
|
-
Requires Rust 1.85+.
|
|
69
|
-
For npm installs, Node 18+ is required.
|
|
135
|
+
Requires Rust 1.85+. npm installs require Node 18+.
|
|
70
136
|
|
|
71
137
|
## Usage
|
|
72
138
|
|
|
@@ -75,17 +141,29 @@ attn # open current directory
|
|
|
75
141
|
attn README.md # open a file
|
|
76
142
|
attn ~/projects/myapp # open a project
|
|
77
143
|
attn --dark # force dark mode
|
|
78
|
-
attn --status todo.md # print task progress
|
|
144
|
+
attn --status todo.md # print task progress, e.g. "3/5 tasks complete"
|
|
79
145
|
attn --json spec.md # dump document structure as JSON
|
|
80
146
|
```
|
|
81
147
|
|
|
148
|
+
### Review CLI
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
attn review share docs/ # share a file or folder
|
|
152
|
+
attn review join 'attn://review/...' # join through the running app
|
|
153
|
+
attn review register-agent reviewer # create a headless reviewer identity
|
|
154
|
+
attn review join 'attn://review/...' --as-agent reviewer
|
|
155
|
+
attn review list-agents
|
|
156
|
+
attn review whoami
|
|
157
|
+
```
|
|
158
|
+
|
|
82
159
|
### Keyboard shortcuts
|
|
83
160
|
|
|
84
161
|
| Shortcut | Action |
|
|
85
162
|
|---|---|
|
|
86
163
|
| `Cmd+P` | Fuzzy file search |
|
|
87
164
|
| `Cmd+E` | Toggle editor |
|
|
88
|
-
| `Cmd+F` | Find
|
|
165
|
+
| `Cmd+F` | Find and replace |
|
|
166
|
+
| `Cmd+Shift+S` | Share for review |
|
|
89
167
|
| `Cmd+;` | Switch project |
|
|
90
168
|
| `Cmd+W` | Close tab |
|
|
91
169
|
| `Cmd+Tab` / `Cmd+Shift+Tab` | Navigate tabs |
|
|
@@ -95,37 +173,60 @@ attn --json spec.md # dump document structure as JSON
|
|
|
95
173
|
|
|
96
174
|
## How it works
|
|
97
175
|
|
|
98
|
-
The Svelte 5 frontend is compiled by Vite and
|
|
176
|
+
The Svelte 5 frontend is compiled by Vite and embedded into the Rust binary at
|
|
177
|
+
build time. There is no bundled web server and no extracted asset directory at
|
|
178
|
+
runtime.
|
|
99
179
|
|
|
100
|
-
|
|
180
|
+
On first launch, attn forks a daemon to the background. The daemon opens a
|
|
181
|
+
native window via [wry](https://github.com/tauri-apps/wry), watches your files,
|
|
182
|
+
and listens on a Unix socket. Later `attn` calls connect to that socket and
|
|
183
|
+
open new tabs in the existing window. If the binary changes after a rebuild,
|
|
184
|
+
the old daemon is replaced automatically.
|
|
185
|
+
|
|
186
|
+
Collaboration is layered on top of the local file model. The owner shares a
|
|
187
|
+
snapshot graph and review event log over an end-to-end encrypted room. The
|
|
188
|
+
relay handles discovery, mailbox fallback, and presence transport, but it does
|
|
189
|
+
not receive plaintext markdown or comments.
|
|
101
190
|
|
|
102
191
|
```
|
|
103
192
|
src/
|
|
104
193
|
main.rs CLI, native window, keyboard shortcuts
|
|
105
194
|
daemon.rs Unix socket IPC, single-instance daemon
|
|
106
195
|
watcher.rs File system monitoring with debouncing
|
|
107
|
-
markdown.rs Structure extraction
|
|
108
|
-
ipc.rs Webview
|
|
109
|
-
files.rs File tree
|
|
196
|
+
markdown.rs Structure extraction
|
|
197
|
+
ipc.rs Webview <-> Rust messaging
|
|
198
|
+
files.rs File tree and media type detection
|
|
110
199
|
projects.rs Project registry
|
|
200
|
+
review/ Encrypted review rooms, anchors, transport, apply flow
|
|
111
201
|
|
|
112
202
|
web/src/ Svelte 5 frontend
|
|
113
|
-
|
|
203
|
+
relay/ Cloudflare Worker relay for encrypted review traffic
|
|
204
|
+
site/ Public marketing site
|
|
114
205
|
```
|
|
115
206
|
|
|
116
|
-
##
|
|
207
|
+
## Development
|
|
117
208
|
|
|
118
209
|
```bash
|
|
119
210
|
task dev # Vite HMR + Rust in foreground
|
|
120
|
-
task dev ATTN_PATH=path/to/file.md #
|
|
211
|
+
task dev ATTN_PATH=path/to/file.md # open a specific file
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Builds:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
scripts/build.sh # debug build
|
|
218
|
+
scripts/build.sh release # release build with devtools/screenshots
|
|
219
|
+
scripts/build.sh prod # production release build
|
|
121
220
|
```
|
|
122
221
|
|
|
123
|
-
|
|
222
|
+
Useful gates:
|
|
124
223
|
|
|
125
224
|
```bash
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
225
|
+
npm run check --prefix web
|
|
226
|
+
npm test --prefix web
|
|
227
|
+
cargo test
|
|
228
|
+
npm test --prefix relay
|
|
229
|
+
npm run build --prefix site
|
|
129
230
|
```
|
|
130
231
|
|
|
131
232
|
## License
|
package/bin/attn.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
|
+
accessSync,
|
|
4
5
|
chmodSync,
|
|
6
|
+
constants: fsConstants,
|
|
5
7
|
createWriteStream,
|
|
6
8
|
existsSync,
|
|
7
9
|
mkdirSync,
|
|
8
10
|
readFileSync,
|
|
11
|
+
realpathSync,
|
|
9
12
|
renameSync,
|
|
10
13
|
rmSync,
|
|
11
14
|
symlinkSync,
|
|
@@ -59,6 +62,22 @@ async function main() {
|
|
|
59
62
|
const version = packageJson.version;
|
|
60
63
|
const headless = isHeadlessInvocation(args);
|
|
61
64
|
|
|
65
|
+
// Prefer a natively-installed `attn` over anything we'd download. A dev
|
|
66
|
+
// who built the binary, a Homebrew/cargo install, or a prior
|
|
67
|
+
// `npx attnmd` that installed the ~/.local/bin alias should all be used
|
|
68
|
+
// directly — `npx attnmd` becomes a thin "use what's here, else fetch"
|
|
69
|
+
// shim rather than always pulling its own copy. The recursion guard in
|
|
70
|
+
// `findNativeBinary` excludes this package's own launcher so a global
|
|
71
|
+
// `npm i -g attn` symlink can't loop back here.
|
|
72
|
+
const nativeBinary = findNativeBinary();
|
|
73
|
+
if (nativeBinary) {
|
|
74
|
+
if (process.env.ATTN_DEBUG_LAUNCHER) {
|
|
75
|
+
console.error(`attn: using native binary ${nativeBinary}`);
|
|
76
|
+
}
|
|
77
|
+
run(nativeBinary, args);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
62
81
|
let appPath = null;
|
|
63
82
|
if (process.platform === "darwin") {
|
|
64
83
|
try {
|
|
@@ -150,6 +169,109 @@ function findGlobalAppInstall() {
|
|
|
150
169
|
return null;
|
|
151
170
|
}
|
|
152
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Locate an already-installed `attn` we can hand off to instead of
|
|
174
|
+
* downloading. Priority:
|
|
175
|
+
* 1. $ATTN_BIN explicit override
|
|
176
|
+
* 2. `attn` on PATH (via `command -v`)
|
|
177
|
+
* 3. The ~/.local/bin alias this launcher installs on first run
|
|
178
|
+
* 4. Common manual / package-manager install dirs (Homebrew, cargo)
|
|
179
|
+
*
|
|
180
|
+
* Each candidate is validated by `isUsableNativeBinary`, which rejects
|
|
181
|
+
* anything inside this npm package (so a global `npm i -g attn` symlink,
|
|
182
|
+
* whose realpath points back at bin/attn.js, can't cause infinite
|
|
183
|
+
* recursion).
|
|
184
|
+
*/
|
|
185
|
+
function findNativeBinary() {
|
|
186
|
+
const candidates = [];
|
|
187
|
+
|
|
188
|
+
if (process.env.ATTN_BIN) {
|
|
189
|
+
candidates.push(process.env.ATTN_BIN);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const onPath = whichAttn();
|
|
193
|
+
if (onPath) {
|
|
194
|
+
candidates.push(onPath);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
candidates.push(
|
|
198
|
+
installLinkPath, // ~/.local/bin/attn — the alias we install ourselves
|
|
199
|
+
"/opt/homebrew/bin/attn",
|
|
200
|
+
"/usr/local/bin/attn",
|
|
201
|
+
join(userHome, ".cargo", "bin", "attn"),
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
for (const candidate of candidates) {
|
|
205
|
+
if (isUsableNativeBinary(candidate)) {
|
|
206
|
+
return candidate;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Resolve `attn` on PATH without throwing. Returns null when not found. */
|
|
213
|
+
function whichAttn() {
|
|
214
|
+
const probe = spawnSync(
|
|
215
|
+
process.platform === "win32" ? "where" : "command",
|
|
216
|
+
process.platform === "win32" ? ["attn"] : ["-v", "attn"],
|
|
217
|
+
{ encoding: "utf8", shell: process.platform !== "win32" },
|
|
218
|
+
);
|
|
219
|
+
if (probe.status !== 0 || !probe.stdout) {
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
const first = probe.stdout.split("\n").map((l) => l.trim()).find(Boolean);
|
|
223
|
+
return first || null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* True when `candidate` is an executable we can safely exec as a real
|
|
228
|
+
* `attn` — i.e. it exists, is executable, and (after symlink resolution)
|
|
229
|
+
* does NOT live inside this npm package. The last check is the recursion
|
|
230
|
+
* guard: a global `npm i -g attn` makes `attn` on PATH a symlink to
|
|
231
|
+
* `<package>/bin/attn.js`; handing off to that would re-enter this script
|
|
232
|
+
* forever.
|
|
233
|
+
*/
|
|
234
|
+
function isUsableNativeBinary(candidate) {
|
|
235
|
+
if (!candidate) return false;
|
|
236
|
+
try {
|
|
237
|
+
accessSync(candidate, fsConstants.X_OK);
|
|
238
|
+
} catch {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
let resolved;
|
|
242
|
+
try {
|
|
243
|
+
resolved = realpathSync(candidate);
|
|
244
|
+
} catch {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
// Recursion guard: never hand off to another copy of THIS launcher.
|
|
248
|
+
// Two ways that happens:
|
|
249
|
+
// 1. The candidate resolves to this exact file (a symlink to it).
|
|
250
|
+
// 2. A global `npm i -g attn` makes `attn` on PATH a symlink to some
|
|
251
|
+
// package's `bin/attn.js`; any `.js` is a node launcher, not a
|
|
252
|
+
// native binary, so reject it.
|
|
253
|
+
// A compiled binary under this repo's `target/` (dev builds) is fine —
|
|
254
|
+
// it can't re-enter this script — so we deliberately DON'T reject the
|
|
255
|
+
// whole package dir, only the launcher itself + the `bin/` dir + `.js`.
|
|
256
|
+
try {
|
|
257
|
+
if (resolved === realpathSync(__filename)) return false;
|
|
258
|
+
} catch {
|
|
259
|
+
/* __filename always resolves; ignore */
|
|
260
|
+
}
|
|
261
|
+
if (resolved.endsWith(".js")) return false;
|
|
262
|
+
const binDirReal = (() => {
|
|
263
|
+
try {
|
|
264
|
+
return realpathSync(join(packageDir, "bin"));
|
|
265
|
+
} catch {
|
|
266
|
+
return join(packageDir, "bin");
|
|
267
|
+
}
|
|
268
|
+
})();
|
|
269
|
+
if (resolved.startsWith(binDirReal + "/") || resolved === binDirReal) {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
|
|
153
275
|
function ensureCurrentAppLink(appPath) {
|
|
154
276
|
mkdirSync(managedRoot, { recursive: true });
|
|
155
277
|
try {
|
|
@@ -305,6 +427,10 @@ for arg in "$@"; do
|
|
|
305
427
|
;;
|
|
306
428
|
esac
|
|
307
429
|
done
|
|
430
|
+
# No path arg provided — default to cwd so the app doesn't open at /
|
|
431
|
+
if [ "$PATH_RESOLVED" -eq 0 ]; then
|
|
432
|
+
RESOLVED_ARGS+=("$(pwd)")
|
|
433
|
+
fi
|
|
308
434
|
exec /usr/bin/open "$APP_LINK" --args "\${RESOLVED_ARGS[@]}"
|
|
309
435
|
`
|
|
310
436
|
: `#!/usr/bin/env bash
|
|
@@ -353,6 +479,10 @@ function resolvePathArgs(args) {
|
|
|
353
479
|
resolved.push(arg);
|
|
354
480
|
}
|
|
355
481
|
}
|
|
482
|
+
// No path arg provided — default to cwd so the app doesn't open at /
|
|
483
|
+
if (!pathResolved) {
|
|
484
|
+
resolved.push(process.cwd());
|
|
485
|
+
}
|
|
356
486
|
return resolved;
|
|
357
487
|
}
|
|
358
488
|
|