attnmd 0.3.5 → 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 +137 -41
- package/bin/attn.js +122 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,46 +1,112 @@
|
|
|
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
|
+
```
|
|
30
91
|
|
|
31
|
-
|
|
92
|
+
CLI share flow:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
attn review share path/to/docs
|
|
96
|
+
```
|
|
32
97
|
|
|
33
|
-
|
|
98
|
+
Reviewer flow:
|
|
34
99
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
100
|
+
```bash
|
|
101
|
+
attn review join 'attn://review/<room-id>#key=<secret>'
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
For headless reviewers or agents:
|
|
105
|
+
|
|
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
|
|
|
@@ -58,20 +124,15 @@ npx attnmd
|
|
|
58
124
|
npm install -g attnmd && attn
|
|
59
125
|
```
|
|
60
126
|
|
|
61
|
-
### From source
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
cargo install attn
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### From source (git)
|
|
127
|
+
### From source
|
|
68
128
|
|
|
69
129
|
```bash
|
|
70
130
|
git clone https://github.com/lightsofapollo/attn.git
|
|
71
|
-
cd attn
|
|
131
|
+
cd attn
|
|
132
|
+
cargo install --path .
|
|
72
133
|
```
|
|
73
134
|
|
|
74
|
-
Requires Rust 1.85+.
|
|
135
|
+
Requires Rust 1.85+. npm installs require Node 18+.
|
|
75
136
|
|
|
76
137
|
## Usage
|
|
77
138
|
|
|
@@ -80,17 +141,29 @@ attn # open current directory
|
|
|
80
141
|
attn README.md # open a file
|
|
81
142
|
attn ~/projects/myapp # open a project
|
|
82
143
|
attn --dark # force dark mode
|
|
83
|
-
attn --status todo.md # print task progress
|
|
144
|
+
attn --status todo.md # print task progress, e.g. "3/5 tasks complete"
|
|
84
145
|
attn --json spec.md # dump document structure as JSON
|
|
85
146
|
```
|
|
86
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
|
+
|
|
87
159
|
### Keyboard shortcuts
|
|
88
160
|
|
|
89
161
|
| Shortcut | Action |
|
|
90
162
|
|---|---|
|
|
91
163
|
| `Cmd+P` | Fuzzy file search |
|
|
92
164
|
| `Cmd+E` | Toggle editor |
|
|
93
|
-
| `Cmd+F` | Find
|
|
165
|
+
| `Cmd+F` | Find and replace |
|
|
166
|
+
| `Cmd+Shift+S` | Share for review |
|
|
94
167
|
| `Cmd+;` | Switch project |
|
|
95
168
|
| `Cmd+W` | Close tab |
|
|
96
169
|
| `Cmd+Tab` / `Cmd+Shift+Tab` | Navigate tabs |
|
|
@@ -100,37 +173,60 @@ attn --json spec.md # dump document structure as JSON
|
|
|
100
173
|
|
|
101
174
|
## How it works
|
|
102
175
|
|
|
103
|
-
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.
|
|
179
|
+
|
|
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.
|
|
104
185
|
|
|
105
|
-
|
|
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.
|
|
106
190
|
|
|
107
191
|
```
|
|
108
192
|
src/
|
|
109
193
|
main.rs CLI, native window, keyboard shortcuts
|
|
110
194
|
daemon.rs Unix socket IPC, single-instance daemon
|
|
111
195
|
watcher.rs File system monitoring with debouncing
|
|
112
|
-
markdown.rs Structure extraction
|
|
113
|
-
ipc.rs Webview
|
|
114
|
-
files.rs File tree
|
|
196
|
+
markdown.rs Structure extraction
|
|
197
|
+
ipc.rs Webview <-> Rust messaging
|
|
198
|
+
files.rs File tree and media type detection
|
|
115
199
|
projects.rs Project registry
|
|
200
|
+
review/ Encrypted review rooms, anchors, transport, apply flow
|
|
116
201
|
|
|
117
202
|
web/src/ Svelte 5 frontend
|
|
118
|
-
|
|
203
|
+
relay/ Cloudflare Worker relay for encrypted review traffic
|
|
204
|
+
site/ Public marketing site
|
|
119
205
|
```
|
|
120
206
|
|
|
121
|
-
##
|
|
207
|
+
## Development
|
|
122
208
|
|
|
123
209
|
```bash
|
|
124
210
|
task dev # Vite HMR + Rust in foreground
|
|
125
|
-
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
|
|
126
220
|
```
|
|
127
221
|
|
|
128
|
-
|
|
222
|
+
Useful gates:
|
|
129
223
|
|
|
130
224
|
```bash
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
|
134
230
|
```
|
|
135
231
|
|
|
136
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 {
|