slingit 0.2.1 → 0.2.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
@@ -67,7 +67,7 @@ Env takes precedence over the file; the file takes precedence over the built-in
67
67
  ## Loading a note (`pull`)
68
68
 
69
69
  ```bash
70
- npx slingit pull <url> [--comments]
70
+ npx slingit pull <url> [--comments|--comments-only]
71
71
  ```
72
72
 
73
73
  Fetches a published note and prints its Markdown to stdout — handy for pulling an
@@ -84,9 +84,14 @@ note you shared. Comments on encrypted notes are decrypted locally with the same
84
84
  the comments cannot be fetched, the note body still prints and a one-line notice goes to
85
85
  stderr.
86
86
 
87
+ With `--comments-only`, only the comments are fetched and printed — the note body is
88
+ skipped entirely. Unlike `--comments`, a failure to fetch here is a hard error (there's
89
+ nothing else to fall back to).
90
+
87
91
  | Flag | Description | Default |
88
92
  |---|---|---|
89
93
  | `--comments` | Also fetch reader comments and append them after the note body | off |
94
+ | `--comments-only` | Fetch and print just the comments, skipping the note body | off |
90
95
 
91
96
  ## Skill installation
92
97
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slingit",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Share formatted Markdown notes via link. Encrypted by default (key in #URL), optional email delivery.",
5
5
  "type": "module",
6
6
  "bin": {
package/skill/SKILL.md CHANGED
@@ -41,6 +41,14 @@ encrypted notes are decrypted locally with the same key from the `#` fragment. I
41
41
  has no comments yet, the section reads `## Comments (0)`; if the comments cannot be
42
42
  fetched, the note body still prints and a one-line notice goes to stderr.
43
43
 
44
+ If you only care about the feedback and not the (already-known) note body — e.g. checking
45
+ in on a note you slung earlier in the same session — use `--comments-only` instead to skip
46
+ re-fetching and re-printing the whole document:
47
+
48
+ ```bash
49
+ npx slingit pull <url> --comments-only
50
+ ```
51
+
44
52
  ## Choose the input method first
45
53
 
46
54
  Use the method that matches the user's request:
package/src/cli.js CHANGED
@@ -8,7 +8,8 @@ const HELP = `slingit — share Markdown notes via link (encrypted by default)
8
8
 
9
9
  Usage:
10
10
  slingit shot [file.md] [flags] publish a note (file or stdin)
11
- slingit pull <url> [--comments] fetch a note by link, print its Markdown to stdout
11
+ slingit pull <url> [--comments|--comments-only]
12
+ fetch a note by link, print its Markdown to stdout
12
13
  slingit install-skill [flags] install the agent skill
13
14
  slingit help this help
14
15
 
@@ -40,6 +41,7 @@ pull decrypts locally too: it reads the note id from the URL path and the key fr
40
41
  the #fragment, fetches the ciphertext by id alone, and prints the Markdown. The key
41
42
  is never sent to the server. Pass the full link, including the part after #.
42
43
  Add --comments to also fetch reader feedback and append it as a Comments section.
44
+ Use --comments-only to fetch just the comments, without the note body.
43
45
  `;
44
46
 
45
47
  export async function main(argv) {
package/src/pull.js CHANGED
@@ -11,10 +11,23 @@ const ID_RE = /^[A-Za-z0-9_-]{10,14}$/;
11
11
  * reader, so the key never reaches the server — the iron rule stays intact.
12
12
  */
13
13
  export async function pull(args) {
14
- const { url, comments: wantComments } = parseArgs(args);
14
+ const { url, comments: wantComments, commentsOnly } = parseArgs(args);
15
15
  const { id, origin, key } = parseUrl(url);
16
16
 
17
17
  const meta = await fetchMeta(origin, id);
18
+
19
+ if (commentsOnly) {
20
+ if (meta.mode !== 'public' && !key) {
21
+ throw new Error(
22
+ 'this note is encrypted but the link has no key after "#" — you need the full link (including the #fragment) to read its comments'
23
+ );
24
+ }
25
+ const raw = await fetchComments(origin, id);
26
+ const normalized = await decryptComments(raw, meta, key);
27
+ process.stdout.write(formatCommentsSection(normalized, { standalone: true }));
28
+ return;
29
+ }
30
+
18
31
  const blob = await fetchBlob(origin, id);
19
32
 
20
33
  let markdown;
@@ -58,17 +71,22 @@ export async function pull(args) {
58
71
  function parseArgs(args) {
59
72
  let url = null;
60
73
  let comments = false;
74
+ let commentsOnly = false;
61
75
  for (const a of args) {
62
76
  if (a === '--comments') {
63
77
  comments = true;
64
78
  continue;
65
79
  }
80
+ if (a === '--comments-only') {
81
+ commentsOnly = true;
82
+ continue;
83
+ }
66
84
  if (a.startsWith('-')) throw new Error(`unknown flag "${a}". See: slingit help`);
67
85
  if (url) throw new Error('only one URL can be given');
68
86
  url = a;
69
87
  }
70
- if (!url) throw new Error('usage: slingit pull <url> [--comments]');
71
- return { url, comments };
88
+ if (!url) throw new Error('usage: slingit pull <url> [--comments|--comments-only]');
89
+ return { url, comments, commentsOnly };
72
90
  }
73
91
 
74
92
  function parseUrl(input) {
@@ -160,11 +178,16 @@ async function decryptComments(raw, meta, key) {
160
178
  }
161
179
 
162
180
  /**
163
- * Render a normalized comments array as a Markdown section appended after the
164
- * note body. Pure and self-contained so it can be unit-tested without a server.
181
+ * Render a normalized comments array as a Markdown section. By default it's
182
+ * appended after the note body (so it opens with a `---` separator); pass
183
+ * `standalone: true` for `--comments-only` output, which has no document above
184
+ * it to separate from. Pure and self-contained so it can be unit-tested without
185
+ * a server.
165
186
  */
166
- export function formatCommentsSection(comments) {
167
- let out = `\n---\n\n## Comments (${comments.length})\n\n`;
187
+ export function formatCommentsSection(comments, { standalone = false } = {}) {
188
+ let out = standalone
189
+ ? `## Comments (${comments.length})\n\n`
190
+ : `\n---\n\n## Comments (${comments.length})\n\n`;
168
191
  if (comments.length === 0) {
169
192
  return `${out}_No comments yet._\n`;
170
193
  }