keep-markdown 0.1.0 → 0.2.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 (3) hide show
  1. package/README.md +7 -0
  2. package/bin/keep.js +59 -5
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -20,10 +20,17 @@ Alternatively set the `KEEP_API_KEY` environment variable.
20
20
  ```
21
21
  keep list --since 7d
22
22
  keep search "react hooks"
23
+ keep feed --since 7d
24
+ keep processed <id1> <id2>
23
25
  keep get <id>
24
26
  keep content <id>
25
27
  keep me
26
28
  keep stats
27
29
  ```
28
30
 
31
+ Default text output for `list`, `search`, and `feed` is:
32
+ `<id>\t<url>\t<title>`
33
+
34
+ Use `--json` for structured output.
35
+
29
36
  Run `keep help` for the full list of commands and options.
package/bin/keep.js CHANGED
@@ -17,20 +17,27 @@ Commands:
17
17
  archive <id> Archive an item (hide from default list)
18
18
  me Show account info
19
19
  stats Get usage stats
20
+ feed List unprocessed items (for agent consumption)
21
+ processed <id...> Mark items as processed
20
22
 
21
23
  Global options:
22
24
  --base <url> Base API URL (env KEEP_API_BASE_URL)
23
25
  --key <token> API key (env KEEP_API_KEY or KEEP_API_TOKEN)
24
26
  --json Output raw JSON
25
27
 
26
- List options:
28
+ List/feed options:
27
29
  --since <value> e.g. 7d, 24h, 2024-01-01
28
30
  --until <value>
29
- --status <list> comma-separated
30
31
  --limit <n>
31
32
  --offset <n>
32
- --content Include markdown in list
33
33
  --query <text> Filter by title, URL, notes, or tags
34
+
35
+ List-only options:
36
+ --status <list> comma-separated
37
+ --content Include markdown in list
38
+
39
+ Default text output (list/search/feed):
40
+ <id>\\t<url>\\t<title>
34
41
  `
35
42
 
36
43
  const parseArgs = (argv) => {
@@ -78,7 +85,7 @@ const loadConfig = async () => {
78
85
 
79
86
  const saveConfig = async (data) => {
80
87
  await mkdir(configDir, { recursive: true })
81
- await writeFile(configFile, JSON.stringify(data, null, 2) + '\n')
88
+ await writeFile(configFile, `${JSON.stringify(data, null, 2)}\n`)
82
89
  }
83
90
 
84
91
  const requireAuth = async (flags) => {
@@ -230,8 +237,43 @@ const getStats = async (flags) => {
230
237
  await output(res, Boolean(flags.json))
231
238
  }
232
239
 
240
+ const feedItems = async (flags) => {
241
+ const { baseUrl, apiKey } = await requireAuth(flags)
242
+ const params = new URLSearchParams()
243
+ const since = parseTimeInput(flags.since)
244
+ const until = parseTimeInput(flags.until)
245
+ if (since) params.set('since', since)
246
+ if (until) params.set('until', until)
247
+ if (flags.limit) params.set('limit', flags.limit)
248
+ if (flags.offset) params.set('offset', flags.offset)
249
+ if (flags.query) params.set('q', flags.query)
250
+ const res = await apiFetch(
251
+ baseUrl,
252
+ apiKey,
253
+ `/api/feed${params.toString() ? `?${params}` : ''}`,
254
+ )
255
+ if (flags.json) {
256
+ await output(res, true)
257
+ return
258
+ }
259
+ const data = await res.json()
260
+ printItems(data)
261
+ }
262
+
263
+ const markProcessed = async (ids, flags) => {
264
+ const { baseUrl, apiKey } = await requireAuth(flags)
265
+ const res = await apiFetch(baseUrl, apiKey, '/api/items/mark-processed', {
266
+ method: 'POST',
267
+ headers: { 'content-type': 'application/json' },
268
+ body: JSON.stringify({ ids }),
269
+ })
270
+ await output(res, true)
271
+ }
272
+
233
273
  const main = async () => {
234
- const [command, ...rest] = process.argv.slice(2)
274
+ const args = [...process.argv.slice(2)]
275
+ while (args[0] === '--') args.shift()
276
+ const [command, ...rest] = args
235
277
  if (!command || command === 'help' || command === '--help') {
236
278
  process.stdout.write(usage())
237
279
  return
@@ -293,6 +335,18 @@ const main = async () => {
293
335
  return
294
336
  }
295
337
 
338
+ if (command === 'feed') {
339
+ await feedItems(flags)
340
+ return
341
+ }
342
+
343
+ if (command === 'processed') {
344
+ if (!positionals.length)
345
+ throw new Error('Missing item id(s). Usage: keep processed <id> [id...]')
346
+ await markProcessed(positionals, flags)
347
+ return
348
+ }
349
+
296
350
  throw new Error(`Unknown command: ${command}`)
297
351
  }
298
352
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "keep-markdown",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "CLI for keep.md — search and retrieve saved web content as Markdown",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "homepage": "https://keep.md",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/iannuttall/keep.git",
10
+ "url": "git+https://github.com/iannuttall/keep.git",
11
11
  "directory": "packages/cli"
12
12
  },
13
13
  "author": "Ian Nuttall",