@workover/cli 0.3.0 → 0.5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @workover/cli
2
2
 
3
- The command line for [Workover](https://workover.dev) — sign in from your terminal so tools like Claude Code can read and cowork on your documents.
3
+ The command line for [Workover](https://workover.io) — sign in from your terminal so tools like Claude Code can read and cowork on your documents.
4
4
 
5
5
  ## Install
6
6
 
@@ -69,7 +69,19 @@ workover doc write 1234 --file rewritten.md --note "as discussed"
69
69
  ```
70
70
 
71
71
  `doc write` **replaces the whole body**, so pass the complete document — anything you leave out is
72
- deleted. Read it first with `workover doc read`. It needs a token from `workover login --write`;
72
+ deleted. Read it first with `workover doc read`, which returns the LIVE body from the editor's own
73
+ room, images included:
74
+
75
+ ```sh
76
+ workover doc read 1234 > body.md # images come back as ![alt](url)
77
+ $EDITOR body.md
78
+ workover doc write 1234 --file body.md --note "tightened the intro"
79
+ ```
80
+
81
+ The image URLs round-trip, so editing one paragraph and writing the file back keeps every picture.
82
+ This matters more than it sounds: a document that is *only* screenshots has no plain text at all, so
83
+ anything reading the stored row sees an empty page — and "empty page" plus "replace the whole body"
84
+ is how images get deleted by something that thought it was filling in a blank. It needs a token from `workover login --write`;
73
85
  without that scope it is refused and `doc propose` is the way through. Every direct edit is recorded
74
86
  in the workspace's audit log, since unlike a proposal it leaves no review trail of its own.
75
87
 
@@ -109,7 +121,9 @@ Either surface, same operations, same permissions.
109
121
 
110
122
  ## Configuration
111
123
 
112
- - `WORKOVER_API` — point the CLI at a different Workover API (defaults to `https://api.workover.dev`).
124
+ - `WORKOVER_API` — point the CLI at a different Workover API. Defaults to `https://api.workover.io`.
125
+ `workover login` prints the environment it signed into, because there is only one stored token and
126
+ signing in replaces it.
113
127
 
114
128
  ---
115
129
 
package/bin/workover.mjs CHANGED
@@ -24,8 +24,20 @@ import {
24
24
  contentCommitted,
25
25
  } from '../lib.mjs';
26
26
 
27
- // Point at a different API with WORKOVER_API (e.g. https://api.workover.test for local dev).
28
- const API = normalizeApi(process.env.WORKOVER_API || 'https://api.workover.dev');
27
+ /*
28
+ * PRODUCTION is the default, because this package is published to npm and everyone who installs it
29
+ * is a customer.
30
+ *
31
+ * It defaulted to `api.workover.dev` — staging — which is ours, internal, and behind Cloudflare
32
+ * Access. So every command an outside user ran went to an environment they cannot reach, and the
33
+ * only people for whom the CLI worked out of the box were us. It also meant `workover login` from a
34
+ * production checkout silently signed into staging and replaced whatever token was there, which is
35
+ * visible only by running `whoami` afterwards.
36
+ *
37
+ * Point at anything else with WORKOVER_API (https://api.workover.dev for staging,
38
+ * https://api.workover.test for local dev).
39
+ */
40
+ const API = normalizeApi(process.env.WORKOVER_API || 'https://api.workover.io');
29
41
  const CONFIG_DIR = join(homedir(), '.workover');
30
42
  const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
31
43
 
@@ -156,7 +168,14 @@ async function login() {
156
168
  const decision = pollDecision(res);
157
169
  if (decision === 'complete') {
158
170
  saveConfig({ api: API, token: res.access_token });
159
- console.log('\n\n \x1b[32m✓\x1b[0m Signed in to Workover.\n');
171
+ /*
172
+ * NAME THE ENVIRONMENT. There is one token, so signing in REPLACES whichever one was there,
173
+ * and the only way to notice you have swapped environments used to be running `whoami`
174
+ * afterwards. Someone working on production who runs a bare `login` — or who has WORKOVER_API
175
+ * exported from an earlier command — ends up authenticated somewhere else entirely, and the
176
+ * next read fails in a way that looks like missing data rather than the wrong server.
177
+ */
178
+ console.log(`\n\n \x1b[32m✓\x1b[0m Signed in to ${API}\n`);
160
179
  return;
161
180
  }
162
181
  if (decision === 'denied') {
@@ -628,10 +647,27 @@ async function docCommand() {
628
647
  console.error(`\n ✗ Document ${docId} not found (or no access).\n`);
629
648
  process.exit(1);
630
649
  }
631
- if (asJson) return console.log(JSON.stringify(doc, null, 2));
632
- if (flags.html === true) return console.log(doc.content || '');
650
+ // The LIVE body, from the collab room, with images kept at their real URLs.
651
+ //
652
+ // The document row is not the document. Its `content` is only written on a WordPress import and
653
+ // its `bodyText` is plain text for search, so a page written in the editor used to read as
654
+ // empty here — and one made of screenshots read as empty EXACTLY, because plain text of an
655
+ // image is nothing. Reading nothing and then calling `doc write`, which replaces the whole
656
+ // body, is how an agent deletes somebody's images while believing the page was blank.
657
+ //
658
+ // Best-effort: an older api has no such route, and collab can be unconfigured. Fall back to
659
+ // what the row holds rather than failing to print anything.
660
+ let live = null;
661
+ try {
662
+ live = await authedCall(cfg, `/project/doc/${docId}/content`);
663
+ } catch {
664
+ live = null;
665
+ }
666
+
667
+ if (asJson) return console.log(JSON.stringify(live ? { ...doc, ...live } : doc, null, 2));
668
+ if (flags.html === true) return console.log(live?.html || doc.content || '');
633
669
  console.log(`\n# ${doc.title || 'Untitled'} (id ${doc.id})\n`);
634
- console.log(documentText(doc) || '(empty document)');
670
+ console.log(live?.markdown?.trim() || documentText(doc) || '(empty document)');
635
671
  console.log('');
636
672
  return;
637
673
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@workover/cli",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Workover command line — sign in and cowork on your documents from the terminal.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "ScaleMath",
7
- "homepage": "https://workover.dev",
7
+ "homepage": "https://workover.io",
8
8
  "bugs": {
9
- "url": "https://workover.dev"
9
+ "url": "https://workover.io"
10
10
  },
11
11
  "keywords": [
12
12
  "workover",