extraktr 1.0.0 → 1.0.1

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 +28 -29
  2. package/index.js +3 -8
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,50 +1,41 @@
1
1
  # Extraktr CLI
2
2
 
3
- Installable Node package that calls **`POST /api/extract`** on the Extraktr frontend (same route as the web app). The server proxy may attach session-derived `Authorization` for browser traffic; the CLI uses optional bearer JWTs or anonymous access when the deployment allows it.
4
-
5
- This package is **npm-ready** (valid `package.json`, `bin`, and publish `files`). A **public npm publish** may happen later; this README does not assume the package is on the public registry yet.
3
+ Published npm package **[extraktr](https://www.npmjs.com/package/extraktr)** calls **`POST /api/extract`** on the Extraktr frontend (same route as the web app). The server proxy may attach session-derived `Authorization` for browser traffic; the CLI uses optional bearer JWTs or anonymous access when the deployment allows it.
6
4
 
7
5
  ## Requirements
8
6
 
9
7
  - **Node.js 18+** (global `fetch`)
10
8
 
11
- ## Install options
9
+ ## Install
12
10
 
13
- ### From this repo (local development)
11
+ ### From npm (recommended)
14
12
 
15
13
  ```bash
16
- cd cli
17
- npm install
14
+ npm install -g extraktr
18
15
  ```
19
16
 
20
- Run with Node:
17
+ Then:
21
18
 
22
19
  ```bash
23
- node index.js extract --file ./sample-simple.txt
24
- node index.js --help
25
- node index.js --version
20
+ extraktr --help
21
+ extraktr extract --file ./thread.txt
26
22
  ```
27
23
 
28
- ### Global-style command on your machine (`extraktr`)
29
-
30
- From `cli/`:
24
+ Run once without a global install:
31
25
 
32
26
  ```bash
33
- npm link
27
+ npx extraktr --help
34
28
  ```
35
29
 
36
- Then:
30
+ ### From this repo (contributors)
37
31
 
38
32
  ```bash
39
- extraktr extract --file ./sample-simple.txt
40
- extraktr --help
41
- extraktr extract --help
42
- extraktr --version
33
+ cd cli
34
+ npm install
35
+ npm link
43
36
  ```
44
37
 
45
- To remove the link later: `npm unlink -g extraktr-cli` (package name) or follow npm’s unlink docs for your setup.
46
-
47
- After a future **public publish**, `npx extraktr-cli …` or a scoped name chosen at publish time would work the same way as any other npm binary; until then, use repo paths or `npm link`.
38
+ Use `node index.js …` instead of `extraktr …` if you prefer not to link.
48
39
 
49
40
  ## Environment
50
41
 
@@ -61,18 +52,26 @@ Use **exactly one** input method:
61
52
  - `--file <path>`
62
53
  - `--stdin` (pipe text in; fails if stdin is a TTY with no pipe)
63
54
 
64
- ### Examples
55
+ ### Examples (generic shell)
65
56
 
66
57
  ```bash
67
- extraktr extract --file ./sample-simple.txt
68
- Get-Content sample-simple.txt | extraktr extract --stdin
69
- extraktr extract --file ./sample-simple.txt --format json
70
- extraktr extract --file ./sample-simple.txt --format json --output out.json
58
+ npm install -g extraktr
59
+ extraktr extract --file ./thread.txt
60
+ extraktr extract --file ./thread.txt --format json
61
+ extraktr extract --file ./thread.txt --format json --output out.json
71
62
  extraktr extract --file ./thread.txt --source slack
72
63
  EXTRAKTR_BEARER="Bearer …" extraktr extract --file ./thread.txt
73
64
  ```
74
65
 
75
- With **`--format json`**, successful runs write **only JSON to stdout** so you can pipe it. Diagnostics (e.g. `POST https://…`) go to **stderr** for non-JSON formats; for JSON they are omitted on success. Errors are written to **stderr**.
66
+ ### Examples (PowerShell)
67
+
68
+ ```powershell
69
+ npm install -g extraktr
70
+ extraktr extract --file C:\path\to\thread.txt
71
+ Get-Content C:\path\to\thread.txt | extraktr extract --stdin
72
+ ```
73
+
74
+ On **success**, stdout contains only the formatted extraction (text, Markdown, or JSON). **Errors** and hints go to **stderr**. With **`--format json`**, stdout is valid JSON only on success—safe for `jq` when stderr is not merged into stdout.
76
75
 
77
76
  The frontend proxy forwards **`X-Forwarded-For`** and **`X-Forwarded-Proto`** from your request when applicable.
78
77
 
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  /**
4
4
  * Extraktr CLI — calls the same POST /api/extract contract as the web app (via the frontend proxy).
@@ -70,7 +70,7 @@ Options:
70
70
  --help, -h Show this help
71
71
 
72
72
  Notes:
73
- Do not combine --file and --stdin. With --format json, stdout is valid JSON only on success (errors on stderr).
73
+ Do not combine --file and --stdin. On success, stdout is only the formatted result (text, markdown, or JSON). Errors go to stderr.
74
74
 
75
75
  Examples:
76
76
  extraktr extract --file sample.txt
@@ -265,7 +265,6 @@ async function run() {
265
265
  }
266
266
 
267
267
  const content = input.content;
268
- const API_URL = extractUrl();
269
268
 
270
269
  const payload = { raw_content: content };
271
270
  if (opts.source) payload.source_type = opts.source;
@@ -279,13 +278,9 @@ async function run() {
279
278
  headers.Authorization = opts.bearer.startsWith("Bearer ") ? opts.bearer : `Bearer ${opts.bearer}`;
280
279
  }
281
280
 
282
- if (opts.format !== "json") {
283
- console.error("POST", API_URL);
284
- }
285
-
286
281
  let res;
287
282
  try {
288
- res = await fetch(API_URL, {
283
+ res = await fetch(extractUrl(), {
289
284
  method: "POST",
290
285
  headers,
291
286
  body: JSON.stringify(payload),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extraktr",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "private": false,
5
5
  "description": "Terminal client for Extraktr — calls the same POST /api/extract contract as the web app.",
6
6
  "main": "index.js",