@workover/cli 0.13.0 → 0.14.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.
- package/README.md +34 -1
- package/bin/workover.mjs +139 -57
- package/lib.mjs +104 -7
- package/package.json +2 -1
- package/skill/SKILL.md +64 -0
package/README.md
CHANGED
|
@@ -18,7 +18,8 @@ workover login --write # ...and also allow direct edits, with no suggestions
|
|
|
18
18
|
workover login --rules # ...and also allow changing the style guide
|
|
19
19
|
workover projects # the projects you can reach, with their ids
|
|
20
20
|
workover doc list --project 11
|
|
21
|
-
workover doc
|
|
21
|
+
workover doc get https://workover.io/app/acme/docs/<id> # a document, from its link
|
|
22
|
+
workover doc read 1234 # ...or its UUID, or its number
|
|
22
23
|
workover rules list --project 11 # the style guide agents should write by
|
|
23
24
|
workover comments list 1234 # the feedback people left on a document
|
|
24
25
|
workover doc images 1234 # image file names and alt text (set them with `doc image`)
|
|
@@ -40,6 +41,38 @@ Whatever you grant, a token can never change your account security, your billing
|
|
|
40
41
|
|
|
41
42
|
## Working on documents
|
|
42
43
|
|
|
44
|
+
**Any command that takes a document takes its link.** Paste the URL from the browser
|
|
45
|
+
(`https://workover.io/app/<workspace>/docs/<id>`, with or without anything after it), the UUID at
|
|
46
|
+
the end of it, or the number `doc list` prints (`1234` or `#1234`). `doc get` and `doc edit` are
|
|
47
|
+
the same as `doc read` and `doc write`.
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
workover doc get https://workover.io/app/acme/docs/7cd7e9ec-28af-4a2a-bb7c-668548380a08
|
|
51
|
+
workover doc edit https://workover.io/app/acme/docs/7cd7e9ec-28af-4a2a-bb7c-668548380a08 --file new.md
|
|
52
|
+
workover comments list 7cd7e9ec-28af-4a2a-bb7c-668548380a08
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
A link that the signed-in account cannot open says so ("not found, or no access"), and a
|
|
56
|
+
`workover.dev` link used with a production sign-in names the environment rather than reporting a
|
|
57
|
+
missing document.
|
|
58
|
+
|
|
59
|
+
`WORKOVER_CONFIG=/path/to/config.json` uses a different sign-in file, so a second environment can
|
|
60
|
+
be used without replacing the one in `~/.workover`. The MCP server reads it too.
|
|
61
|
+
|
|
62
|
+
## Claude Code
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
workover install-claude
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
installs a `workover` skill into `~/.claude/skills`. Claude Code lists skills to the model by their
|
|
69
|
+
description, so a pasted Workover link is matched to it and the agent runs `workover doc get <link>`
|
|
70
|
+
rather than writing its own client around the token file. For the tools as well (all projects):
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
claude mcp add --scope user workover -- npx -y @workover/mcp@latest
|
|
74
|
+
```
|
|
75
|
+
|
|
43
76
|
`workover doc` is the whole document surface, so signing in and then doing something with a document
|
|
44
77
|
are the same tool. Bodies come from `--file`, or from stdin:
|
|
45
78
|
|
package/bin/workover.mjs
CHANGED
|
@@ -17,8 +17,9 @@ import {
|
|
|
17
17
|
rmSync,
|
|
18
18
|
} from 'fs';
|
|
19
19
|
import { homedir } from 'os';
|
|
20
|
-
import { join } from 'path';
|
|
20
|
+
import { dirname, join } from 'path';
|
|
21
21
|
import { spawn } from 'child_process';
|
|
22
|
+
import { fileURLToPath } from 'url';
|
|
22
23
|
import {
|
|
23
24
|
normalizeApi,
|
|
24
25
|
browserCommand,
|
|
@@ -32,7 +33,9 @@ import {
|
|
|
32
33
|
renderRulesBlock,
|
|
33
34
|
threadComments,
|
|
34
35
|
docRef,
|
|
36
|
+
environmentMismatch,
|
|
35
37
|
imagesInHtml,
|
|
38
|
+
signInHelp,
|
|
36
39
|
} from '../lib.mjs';
|
|
37
40
|
|
|
38
41
|
/*
|
|
@@ -49,8 +52,11 @@ import {
|
|
|
49
52
|
* https://api.workover.test for local dev).
|
|
50
53
|
*/
|
|
51
54
|
const API = normalizeApi(process.env.WORKOVER_API || 'https://api.workover.io');
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
// WORKOVER_CONFIG points the CLI at another sign-in file, so a second environment (staging, a PR
|
|
56
|
+
// preview) can be used without replacing the one in ~/.workover. The MCP server reads the same
|
|
57
|
+
// variable, so both see the same sign-in.
|
|
58
|
+
const CONFIG_FILE = process.env.WORKOVER_CONFIG || join(homedir(), '.workover', 'config.json');
|
|
59
|
+
const CONFIG_DIR = dirname(CONFIG_FILE);
|
|
54
60
|
|
|
55
61
|
const saveConfig = (cfg) => {
|
|
56
62
|
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
@@ -129,7 +135,7 @@ const flagValue = (name) => {
|
|
|
129
135
|
const requireSignIn = (hint) => {
|
|
130
136
|
const cfg = loadConfig();
|
|
131
137
|
if (!cfg?.token) {
|
|
132
|
-
console.log(
|
|
138
|
+
console.log(signInHelp(hint, CONFIG_FILE));
|
|
133
139
|
process.exit(1);
|
|
134
140
|
}
|
|
135
141
|
return cfg;
|
|
@@ -229,9 +235,29 @@ async function login() {
|
|
|
229
235
|
|
|
230
236
|
async function logout() {
|
|
231
237
|
const cfg = loadConfig();
|
|
238
|
+
let revoked = true;
|
|
232
239
|
if (cfg?.token) {
|
|
233
|
-
|
|
234
|
-
|
|
240
|
+
/*
|
|
241
|
+
* Revoke on the api this sign-in BELONGS to, which login recorded as `cfg.api`.
|
|
242
|
+
*
|
|
243
|
+
* This used to post to WORKOVER_API, defaulting to production. So signing out of a staging or
|
|
244
|
+
* PR-preview sign-in (WORKOVER_CONFIG pointing at its own file, WORKOVER_API unset in the new
|
|
245
|
+
* shell) sent the token to production, which did not know it, and the real token stayed valid
|
|
246
|
+
* on the api that issued it while the local file was deleted and "Signed out." was printed.
|
|
247
|
+
* Possessing the token authorizes revoking it; best-effort, but no longer silent when it fails.
|
|
248
|
+
*/
|
|
249
|
+
const base = cfg.api ? normalizeApi(cfg.api) : API;
|
|
250
|
+
revoked = await fetch(`${base}/cli-auth/logout`, {
|
|
251
|
+
method: 'POST',
|
|
252
|
+
headers: { 'content-type': 'application/json' },
|
|
253
|
+
body: JSON.stringify({ token: cfg.token }),
|
|
254
|
+
})
|
|
255
|
+
.then((res) => res.ok)
|
|
256
|
+
.catch(() => false);
|
|
257
|
+
if (!revoked) {
|
|
258
|
+
console.log(` ! Could not reach ${base} to revoke this device's token.`);
|
|
259
|
+
console.log(' It is removed from this computer; it stops working when it expires.');
|
|
260
|
+
}
|
|
235
261
|
}
|
|
236
262
|
if (existsSync(CONFIG_FILE)) rmSync(CONFIG_FILE);
|
|
237
263
|
console.log(' Signed out.');
|
|
@@ -602,15 +628,6 @@ const readBody = async (flags) => {
|
|
|
602
628
|
};
|
|
603
629
|
|
|
604
630
|
/** A document id from the first positional argument, or a usage error naming what to pass. */
|
|
605
|
-
const docIdArg = (positionals, usage) => {
|
|
606
|
-
const id = rowId(positionals[0]);
|
|
607
|
-
if (id === null) {
|
|
608
|
-
console.log(`\n Usage: ${usage}`);
|
|
609
|
-
console.log(' The numeric document id — `workover doc list` prints it as "#123".\n');
|
|
610
|
-
process.exit(1);
|
|
611
|
-
}
|
|
612
|
-
return id;
|
|
613
|
-
};
|
|
614
631
|
|
|
615
632
|
/**
|
|
616
633
|
* What the api said about house style after a write, printed to STDERR.
|
|
@@ -752,32 +769,36 @@ const DOC_USAGE = [
|
|
|
752
769
|
' Usage: workover doc <command>',
|
|
753
770
|
'',
|
|
754
771
|
' list --project <id> [--json] documents in a project',
|
|
755
|
-
' tabs <
|
|
756
|
-
' tab-new <
|
|
772
|
+
' tabs <doc> [--json] the document’s tabs',
|
|
773
|
+
' tab-new <doc> --title "<t>" add an empty tab',
|
|
757
774
|
' [--parent <tabId>]',
|
|
758
|
-
' read <
|
|
775
|
+
' read <doc> [--json] [--html] a document’s current text',
|
|
759
776
|
' [--tab <tabId>] one tab of it',
|
|
760
777
|
' create --project <id> --title "<t>" a new document, content written in',
|
|
761
778
|
' [--file <path> | piped stdin] [--json]',
|
|
762
|
-
' propose <
|
|
779
|
+
' propose <doc> [--note "<why>"] suggest a rewrite for review',
|
|
763
780
|
' [--file <path> | piped stdin] [--json] [--tab <tabId>]',
|
|
764
781
|
' [--why "<what was wrong>"] recorded as its reasoning',
|
|
765
|
-
' write <
|
|
782
|
+
' write <doc> [--note "<why>"] REPLACE the body, no review step',
|
|
766
783
|
' [--file <path> | piped stdin] [--json] [--tab <tabId>]',
|
|
767
784
|
' needs `workover login --write`; use it only when asked to',
|
|
768
|
-
' reshoot <
|
|
785
|
+
' reshoot <doc> [--replace] [--write] Workover AI retakes the screenshots',
|
|
769
786
|
' from the text; --replace drops the old ones; applied as',
|
|
770
787
|
' suggestions, or directly with --write. Needs `login --draft`',
|
|
771
|
-
' verify <
|
|
788
|
+
' verify <doc> [--write] Workover AI checks the text against',
|
|
772
789
|
' the linked repository and corrects what it finds wrong;',
|
|
773
790
|
' applied as suggestions, or directly with --write. Needs',
|
|
774
791
|
' `login --draft`',
|
|
775
|
-
' images <doc> [--tab <tabId>] [--json]
|
|
776
|
-
' image <doc> <n | --src <url>>
|
|
792
|
+
' images <doc> [--tab <tabId>] [--json] the images in it: file name, alt',
|
|
793
|
+
' image <doc> <n | --src <url>> set an image’s file name and/or',
|
|
777
794
|
' [--name <file>] [--alt "<text>"] alt text; needs `login --write`',
|
|
778
795
|
' [--tab <tabId>]',
|
|
779
796
|
' search "<query>" [--limit N] [--json] find documents by title/content',
|
|
780
|
-
' activity <
|
|
797
|
+
' activity <doc> [--limit N] [--json] who changed this document, and how',
|
|
798
|
+
'',
|
|
799
|
+
' <doc> is the document link as the browser shows it',
|
|
800
|
+
' (https://workover.io/app/<workspace>/docs/<id>), the id at the end of it, or',
|
|
801
|
+
' the number `doc list` prints. `get` and `edit` work as `read` and `write`.',
|
|
781
802
|
'',
|
|
782
803
|
' `workover projects` lists the project ids.',
|
|
783
804
|
'',
|
|
@@ -794,29 +815,59 @@ const DOC_USAGE = [
|
|
|
794
815
|
' lists or change bullet markers.',
|
|
795
816
|
'',
|
|
796
817
|
' Tabs: a document can hold several separate bodies. read and write act on ONE',
|
|
797
|
-
' of them, so run `workover doc tabs <
|
|
818
|
+
' of them, so run `workover doc tabs <doc>` first and pass --tab; without it',
|
|
798
819
|
' you get the main body, which on a multi-tab document is not the whole thing.',
|
|
799
820
|
'',
|
|
800
821
|
].join('\n');
|
|
801
822
|
|
|
802
823
|
/**
|
|
803
|
-
* The document a `<doc>` argument names
|
|
804
|
-
*
|
|
824
|
+
* The document a `<doc>` argument names, as a row id.
|
|
825
|
+
*
|
|
826
|
+
* Takes what people actually have: the URL out of the browser, the UUID in it, or the number
|
|
827
|
+
* `doc list` prints. A URL or UUID is resolved through `GET /project/doc/by-handle/<uuid>`, which
|
|
828
|
+
* applies the same access rules as reading the document by id. Every failure says what to do next,
|
|
829
|
+
* because an agent handed a link that "does not work" will otherwise go looking for another way in.
|
|
805
830
|
*/
|
|
806
831
|
const resolveDocArg = async (cfg, positionals, usage) => {
|
|
807
832
|
const ref = docRef(positionals[0]);
|
|
808
833
|
if (!ref) {
|
|
809
834
|
console.log(`\n Usage: ${usage}`);
|
|
810
|
-
console.log('
|
|
835
|
+
console.log(' <doc> is the document link (https://workover.io/app/<workspace>/docs/<id>),');
|
|
836
|
+
console.log(' the id at the end of it, or the number `workover doc list` prints ("#123").\n');
|
|
837
|
+
process.exit(1);
|
|
838
|
+
}
|
|
839
|
+
const mismatch = environmentMismatch(ref, cfg.api);
|
|
840
|
+
if (mismatch) {
|
|
841
|
+
console.error(`\n ✗ ${mismatch}\n`);
|
|
811
842
|
process.exit(1);
|
|
812
843
|
}
|
|
813
844
|
if (ref.id) return ref.id;
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
845
|
+
|
|
846
|
+
let res;
|
|
847
|
+
try {
|
|
848
|
+
res = await fetch(`${cfg.api}/project/doc/by-handle/${encodeURIComponent(ref.handle)}`, {
|
|
849
|
+
headers: { authorization: `Bearer ${cfg.token}` },
|
|
850
|
+
});
|
|
851
|
+
} catch {
|
|
852
|
+
console.error(`\n ✗ Couldn't reach Workover at ${cfg.api}\n`);
|
|
817
853
|
process.exit(1);
|
|
818
854
|
}
|
|
819
|
-
|
|
855
|
+
if (res.ok) {
|
|
856
|
+
const doc = await res.json().catch(() => null);
|
|
857
|
+
if (doc?.id) return doc.id;
|
|
858
|
+
}
|
|
859
|
+
const where = new URL(cfg.api).host;
|
|
860
|
+
const why =
|
|
861
|
+
res.status === 401
|
|
862
|
+
? 'Your Workover sign-in has expired or was revoked. Run `workover login`.'
|
|
863
|
+
: res.status === 410
|
|
864
|
+
? 'That document is in the Trash. Restore it in Workover first.'
|
|
865
|
+
: res.status === 403 || res.status === 404
|
|
866
|
+
? `No document at that link that this sign-in can open (${where}). Either it does not exist, ` +
|
|
867
|
+
'or this account has no access to it: ask its owner to share it, or check `workover whoami`.'
|
|
868
|
+
: `Workover answered ${res.status} resolving that link.`;
|
|
869
|
+
console.error(`\n ✗ ${why}\n`);
|
|
870
|
+
process.exit(1);
|
|
820
871
|
};
|
|
821
872
|
|
|
822
873
|
/**
|
|
@@ -921,7 +972,8 @@ async function imagesCommand(cfg, sub, positionals, flags, tabId, asJson) {
|
|
|
921
972
|
}
|
|
922
973
|
|
|
923
974
|
async function docCommand() {
|
|
924
|
-
|
|
975
|
+
// `get` and `edit` are what people (and agents) guess first; they are `read` and `write`.
|
|
976
|
+
const sub = { get: 'read', edit: 'write' }[process.argv[3]] || process.argv[3];
|
|
925
977
|
// Usage before sign-in: someone who typed the command wrong is asking what the commands are, and
|
|
926
978
|
// answering "not signed in" sends them to fix the wrong thing.
|
|
927
979
|
if (
|
|
@@ -954,7 +1006,7 @@ async function docCommand() {
|
|
|
954
1006
|
// what every one of these commands meant before tabs were addressable.
|
|
955
1007
|
const tabId = flags.tab == null ? null : rowId(flags.tab);
|
|
956
1008
|
if (flags.tab != null && tabId === null) {
|
|
957
|
-
console.log(`\n ✗ --tab must be a tab id. List them: workover doc tabs <
|
|
1009
|
+
console.log(`\n ✗ --tab must be a tab id. List them: workover doc tabs <doc>\n`);
|
|
958
1010
|
process.exit(1);
|
|
959
1011
|
}
|
|
960
1012
|
|
|
@@ -969,7 +1021,7 @@ async function docCommand() {
|
|
|
969
1021
|
};
|
|
970
1022
|
|
|
971
1023
|
if (sub === 'tabs') {
|
|
972
|
-
const docId =
|
|
1024
|
+
const docId = await resolveDocArg(cfg, positionals, 'workover doc tabs <doc>');
|
|
973
1025
|
const tabs = (await authedCall(cfg, `/project/doc/${docId}/tabs`)) || [];
|
|
974
1026
|
if (asJson) return console.log(JSON.stringify(tabs, null, 2));
|
|
975
1027
|
if (!tabs.length) {
|
|
@@ -995,8 +1047,8 @@ async function docCommand() {
|
|
|
995
1047
|
}
|
|
996
1048
|
|
|
997
1049
|
if (sub === 'tab-new') {
|
|
998
|
-
const usage = 'workover doc tab-new <
|
|
999
|
-
const docId =
|
|
1050
|
+
const usage = 'workover doc tab-new <doc> --title "<title>" [--parent <tabId>]';
|
|
1051
|
+
const docId = await resolveDocArg(cfg, positionals, usage);
|
|
1000
1052
|
const title = typeof flags.title === 'string' ? flags.title.trim() : '';
|
|
1001
1053
|
if (!title) {
|
|
1002
1054
|
console.log(`\n Usage: ${usage}\n`);
|
|
@@ -1042,7 +1094,7 @@ async function docCommand() {
|
|
|
1042
1094
|
}
|
|
1043
1095
|
|
|
1044
1096
|
if (sub === 'read') {
|
|
1045
|
-
const docId =
|
|
1097
|
+
const docId = await resolveDocArg(cfg, positionals, 'workover doc read <doc>');
|
|
1046
1098
|
const doc = await authedCall(cfg, `/project/doc/${docId}`);
|
|
1047
1099
|
if (!doc?.id) {
|
|
1048
1100
|
console.error(`\n ✗ Document ${docId} not found (or no access).\n`);
|
|
@@ -1163,8 +1215,8 @@ async function docCommand() {
|
|
|
1163
1215
|
|
|
1164
1216
|
if (sub === 'propose') {
|
|
1165
1217
|
const usage =
|
|
1166
|
-
'workover doc propose <
|
|
1167
|
-
const docId =
|
|
1218
|
+
'workover doc propose <doc> --file <path> [--note "<summary>"] [--why "<what was wrong>"]';
|
|
1219
|
+
const docId = await resolveDocArg(cfg, positionals, usage);
|
|
1168
1220
|
const markdown = (await readBody(flags)).trim();
|
|
1169
1221
|
if (!markdown) {
|
|
1170
1222
|
console.log(`\n Usage: ${usage}`);
|
|
@@ -1196,8 +1248,8 @@ async function docCommand() {
|
|
|
1196
1248
|
}
|
|
1197
1249
|
|
|
1198
1250
|
if (sub === 'write') {
|
|
1199
|
-
const usage = 'workover doc write <
|
|
1200
|
-
const docId =
|
|
1251
|
+
const usage = 'workover doc write <doc> --file <path> [--note "<why>"]';
|
|
1252
|
+
const docId = await resolveDocArg(cfg, positionals, usage);
|
|
1201
1253
|
const markdown = (await readBody(flags)).trim();
|
|
1202
1254
|
if (!markdown) {
|
|
1203
1255
|
console.log(`\n Usage: ${usage}`);
|
|
@@ -1230,9 +1282,10 @@ async function docCommand() {
|
|
|
1230
1282
|
// Workover AI plans and captures this document's screenshots from its current text, signed in
|
|
1231
1283
|
// to the workspace's connected app with the stored credential (which never reaches this
|
|
1232
1284
|
// machine). Needs `draft`. The result is applied as suggestions, or written with --write.
|
|
1233
|
-
const docId =
|
|
1285
|
+
const docId = await resolveDocArg(
|
|
1286
|
+
cfg,
|
|
1234
1287
|
positionals,
|
|
1235
|
-
'workover doc reshoot <
|
|
1288
|
+
'workover doc reshoot <doc> [--replace] [--write] [--note "<why>"]',
|
|
1236
1289
|
);
|
|
1237
1290
|
const res = await authedCall(cfg, `/ai/documents/${docId}/screenshots`, {
|
|
1238
1291
|
replace: flags.replace === true,
|
|
@@ -1275,7 +1328,7 @@ async function docCommand() {
|
|
|
1275
1328
|
// Workover AI reads the project's linked repository and corrects what the document gets wrong.
|
|
1276
1329
|
// Nothing is passed in but the id: the corrections have to come from the source, not from us.
|
|
1277
1330
|
// The result is applied as suggestions (or written with --write), like `reshoot`.
|
|
1278
|
-
const docId =
|
|
1331
|
+
const docId = await resolveDocArg(cfg, positionals, 'workover doc verify <doc> [--write] [--note "<why>"]');
|
|
1279
1332
|
// Started in the background and polled: the check reads the repository for minutes, and a
|
|
1280
1333
|
// single request is cut at 100 seconds by Cloudflare (a 524 whose answer never arrives).
|
|
1281
1334
|
let state = await authedCall(cfg, `/ai/documents/${docId}/verify`, {
|
|
@@ -1332,7 +1385,7 @@ async function docCommand() {
|
|
|
1332
1385
|
}
|
|
1333
1386
|
|
|
1334
1387
|
if (sub === 'activity') {
|
|
1335
|
-
const docId =
|
|
1388
|
+
const docId = await resolveDocArg(cfg, positionals, 'workover doc activity <doc>');
|
|
1336
1389
|
const limit = rowId(flags.limit) ?? 20;
|
|
1337
1390
|
const rows = (await authedCall(cfg, `/project/doc/${docId}/activity`)) || [];
|
|
1338
1391
|
const shown = rows.slice(0, limit);
|
|
@@ -1384,16 +1437,16 @@ const COMMENTS_USAGE = [
|
|
|
1384
1437
|
'',
|
|
1385
1438
|
' Usage: workover comments <command>',
|
|
1386
1439
|
'',
|
|
1387
|
-
' list <
|
|
1440
|
+
' list <doc> [--all] [--json] the feedback on a document,',
|
|
1388
1441
|
' open threads only unless --all',
|
|
1389
|
-
' add <
|
|
1442
|
+
' add <doc> "<text>" leave a comment',
|
|
1390
1443
|
' [--to <commentId>] ...as a reply in that thread',
|
|
1391
1444
|
' [--quote "<text>"] ...against the passage it is about',
|
|
1392
1445
|
' resolve <commentId> [--json] mark a thread dealt with',
|
|
1393
1446
|
' reopen <commentId> [--json] put it back',
|
|
1394
1447
|
'',
|
|
1395
1448
|
' Resolve the thread you actually answered, and say what you did first —',
|
|
1396
|
-
' `comments add <
|
|
1449
|
+
' `comments add <doc> --to <commentId> "..."` then `comments resolve`. A',
|
|
1397
1450
|
' thread that closes with no reply tells the person who raised it nothing,',
|
|
1398
1451
|
' and reopening is the only way back.',
|
|
1399
1452
|
'',
|
|
@@ -1446,7 +1499,7 @@ async function commentsCommand() {
|
|
|
1446
1499
|
const commentId = rowId(positionals[0]);
|
|
1447
1500
|
if (commentId === null) {
|
|
1448
1501
|
console.log(`\n Usage: workover comments ${sub} <commentId>`);
|
|
1449
|
-
console.log(' The comment id — `workover comments list <
|
|
1502
|
+
console.log(' The comment id — `workover comments list <doc>` prints it.\n');
|
|
1450
1503
|
process.exit(1);
|
|
1451
1504
|
}
|
|
1452
1505
|
const res = await authedCall(
|
|
@@ -1476,8 +1529,8 @@ async function commentsCommand() {
|
|
|
1476
1529
|
}
|
|
1477
1530
|
|
|
1478
1531
|
if (sub === 'add') {
|
|
1479
|
-
const usage = 'workover comments add <
|
|
1480
|
-
const docId =
|
|
1532
|
+
const usage = 'workover comments add <doc> "<text>" [--to <commentId>]';
|
|
1533
|
+
const docId = await resolveDocArg(cfg, positionals, usage);
|
|
1481
1534
|
// The text is everything after the document id, so an unquoted sentence still arrives whole.
|
|
1482
1535
|
let body = positionals.slice(1).join(' ').trim();
|
|
1483
1536
|
// `--file` only when asked for. `doc` reads piped stdin without being told, which is right for
|
|
@@ -1491,7 +1544,7 @@ async function commentsCommand() {
|
|
|
1491
1544
|
}
|
|
1492
1545
|
const parentId = flags.to == null ? null : rowId(flags.to);
|
|
1493
1546
|
if (flags.to != null && parentId === null) {
|
|
1494
|
-
console.log('\n ✗ --to must be a comment id. List them: workover comments list <
|
|
1547
|
+
console.log('\n ✗ --to must be a comment id. List them: workover comments list <doc>\n');
|
|
1495
1548
|
process.exit(1);
|
|
1496
1549
|
}
|
|
1497
1550
|
const created = await authedCall(cfg, `/project/doc/${docId}/comments`, {
|
|
@@ -1509,7 +1562,7 @@ async function commentsCommand() {
|
|
|
1509
1562
|
}
|
|
1510
1563
|
|
|
1511
1564
|
// list
|
|
1512
|
-
const docId =
|
|
1565
|
+
const docId = await resolveDocArg(cfg, positionals, 'workover comments list <doc>');
|
|
1513
1566
|
const rows = (await authedCall(cfg, `/project/doc/${docId}/comments`)) || [];
|
|
1514
1567
|
const all = threadComments(rows, { includeResolved: true });
|
|
1515
1568
|
const threads = flags.all === true ? all : all.filter((t) => !t.resolved);
|
|
@@ -1569,6 +1622,31 @@ async function projects() {
|
|
|
1569
1622
|
console.log('');
|
|
1570
1623
|
}
|
|
1571
1624
|
|
|
1625
|
+
/**
|
|
1626
|
+
* Teach Claude Code to use Workover: install the `workover` skill into ~/.claude/skills.
|
|
1627
|
+
*
|
|
1628
|
+
* A skill is listed to Claude Code in every session by its description, so a pasted
|
|
1629
|
+
* workover.io/app/.../docs/... link matches it and the agent reaches for these commands instead of
|
|
1630
|
+
* writing its own client around the token file (which is what happened on 2026-10-16, in a project
|
|
1631
|
+
* where the MCP server was not registered and this CLI was not installed).
|
|
1632
|
+
*
|
|
1633
|
+
* The MCP server is a separate, optional step, printed rather than run: registering it changes the
|
|
1634
|
+
* user's Claude Code configuration, and they should see the command that does that.
|
|
1635
|
+
*/
|
|
1636
|
+
function installClaude() {
|
|
1637
|
+
const root = process.env.CLAUDE_CONFIG_DIR || join(homedir(), '.claude');
|
|
1638
|
+
const target = join(root, 'skills', 'workover', 'SKILL.md');
|
|
1639
|
+
const source = join(dirname(fileURLToPath(import.meta.url)), '..', 'skill', 'SKILL.md');
|
|
1640
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
1641
|
+
writeFileSync(target, readFileSync(source, 'utf8'));
|
|
1642
|
+
console.log(`\n \x1b[32m✓\x1b[0m Installed the Workover skill for Claude Code: ${target}`);
|
|
1643
|
+
console.log(' New Claude Code sessions will open a pasted Workover link with `workover doc get`.');
|
|
1644
|
+
console.log('\n Optional, to give Claude Code the Workover tools directly (all projects):');
|
|
1645
|
+
console.log(' claude mcp add --scope user workover -- npx -y @workover/mcp@latest');
|
|
1646
|
+
if (!loadConfig()?.token) console.log('\n You are not signed in yet: run `workover login`.');
|
|
1647
|
+
console.log('');
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1572
1650
|
const cmd = process.argv[2];
|
|
1573
1651
|
if (cmd === 'login') await login();
|
|
1574
1652
|
else if (cmd === 'logout') await logout();
|
|
@@ -1580,6 +1658,7 @@ else if (cmd === 'doc') await docCommand();
|
|
|
1580
1658
|
else if (cmd === 'rules') await rulesCommand();
|
|
1581
1659
|
else if (cmd === 'comments') await commentsCommand();
|
|
1582
1660
|
else if (cmd === 'projects') await projects();
|
|
1661
|
+
else if (cmd === 'install-claude') installClaude();
|
|
1583
1662
|
else {
|
|
1584
1663
|
console.log('\n Workover CLI\n');
|
|
1585
1664
|
console.log(' Usage: workover <command>\n');
|
|
@@ -1594,7 +1673,9 @@ else {
|
|
|
1594
1673
|
console.log(' plus tabs and tab-new for documents with several bodies');
|
|
1595
1674
|
console.log(' plus images and image, for image file names and alt text');
|
|
1596
1675
|
console.log(' workover doc create --project 11 --title "Billing" --file b.md');
|
|
1597
|
-
console.log('
|
|
1676
|
+
console.log(' <doc> is the link from the browser, its UUID, or the number');
|
|
1677
|
+
console.log(' workover doc get https://workover.io/app/acme/docs/<id>');
|
|
1678
|
+
console.log(' workover doc propose <doc> --file new.md · doc edit <doc> --file new.md');
|
|
1598
1679
|
console.log(' comments Read, answer and resolve feedback on a document');
|
|
1599
1680
|
console.log(' workover comments list 123 · workover comments resolve 45');
|
|
1600
1681
|
console.log(' rules The style guide agents should write by: list, export, add');
|
|
@@ -1606,5 +1687,6 @@ else {
|
|
|
1606
1687
|
console.log(' eval Score a project’s documentation against the editorial rubric');
|
|
1607
1688
|
console.log(' --org <id> --project <id> [--limit N] [--json]');
|
|
1608
1689
|
console.log(' logout Sign out and revoke this device’s token');
|
|
1609
|
-
console.log(' whoami Show the current sign-in
|
|
1690
|
+
console.log(' whoami Show the current sign-in');
|
|
1691
|
+
console.log(' install-claude Teach Claude Code to open Workover links (installs a skill)\n');
|
|
1610
1692
|
}
|
package/lib.mjs
CHANGED
|
@@ -272,19 +272,96 @@ export const threadComments = (comments, { includeResolved = false } = {}) => {
|
|
|
272
272
|
.map((r) => ({ ...r, replies: (repliesByRoot.get(r.id) || []).sort(order) }));
|
|
273
273
|
};
|
|
274
274
|
|
|
275
|
+
const UUID_RE = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
|
|
276
|
+
const FULL_UUID_RE = new RegExp(`^${UUID_RE.source}$`, 'i');
|
|
277
|
+
|
|
275
278
|
/**
|
|
276
|
-
* Which document
|
|
277
|
-
*
|
|
279
|
+
* Which document somebody meant, from whatever they pasted.
|
|
280
|
+
*
|
|
281
|
+
* 1234 / #1234 → { id: 1234 }
|
|
282
|
+
* https://workover.io/app/pellio/docs/<uuid> → { handle, host, workspace }
|
|
283
|
+
* …/docs/<uuid>/anything?tab=3#heading, workover.dev, → the same, with that host
|
|
284
|
+
* a preview host, or no scheme at all
|
|
285
|
+
* https://workover.io/app/projects/1234 → { id: 1234, host } (the old editor URL)
|
|
286
|
+
* <uuid> on its own → { handle }
|
|
278
287
|
*
|
|
279
|
-
* The URL is what people paste
|
|
280
|
-
*
|
|
288
|
+
* Returns null for anything else. The URL is what people paste because it is what the browser shows
|
|
289
|
+
* them, and on 2026-10-16 an agent handed one went digging through the source to turn it into a row
|
|
290
|
+
* id. Every command that names a document takes all of these, so nobody has to.
|
|
291
|
+
*
|
|
292
|
+
* `host` is kept so a link to one environment opened with a sign-in for another can be named as
|
|
293
|
+
* that, rather than reported as a missing document (see `environmentMismatch`).
|
|
281
294
|
*/
|
|
282
295
|
export const docRef = (value) => {
|
|
283
|
-
|
|
296
|
+
// Trim the wrapping that pasted links arrive in: <angle brackets>, quotes, a trailing full stop.
|
|
297
|
+
const s = String(value ?? '')
|
|
298
|
+
.trim()
|
|
299
|
+
.replace(/^[<"'([]+/, '')
|
|
300
|
+
.replace(/[>"')\].,;]+$/, '');
|
|
301
|
+
if (!s) return null;
|
|
284
302
|
const id = rowId(s);
|
|
285
303
|
if (id !== null) return { id };
|
|
286
|
-
|
|
287
|
-
|
|
304
|
+
if (FULL_UUID_RE.test(s)) return { handle: s.toLowerCase() };
|
|
305
|
+
|
|
306
|
+
const hasScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(s);
|
|
307
|
+
if (hasScheme || /^[a-z0-9-]+(\.[a-z0-9-]+)+(:\d+)?\//i.test(s)) {
|
|
308
|
+
let url;
|
|
309
|
+
try {
|
|
310
|
+
url = new URL(hasScheme ? s : `https://${s}`);
|
|
311
|
+
} catch {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
const host = url.hostname.toLowerCase();
|
|
315
|
+
const segs = url.pathname.split('/').filter(Boolean);
|
|
316
|
+
const at = segs.findIndex((seg) => FULL_UUID_RE.test(seg));
|
|
317
|
+
if (at !== -1) {
|
|
318
|
+
// /app/<workspace>/docs/<uuid>: the canonical document URL.
|
|
319
|
+
const workspace =
|
|
320
|
+
segs[0] === 'app' && segs[2] === 'docs' && at === 3 ? decodeURIComponent(segs[1]) : null;
|
|
321
|
+
return { handle: segs[at].toLowerCase(), host, ...(workspace ? { workspace } : {}) };
|
|
322
|
+
}
|
|
323
|
+
// /app/projects/<id>: the numeric editor route, kept for old links and bookmarks.
|
|
324
|
+
if (segs[0] === 'app' && segs[1] === 'projects' && rowId(segs[2] ?? '') !== null) {
|
|
325
|
+
return { id: rowId(segs[2]), host };
|
|
326
|
+
}
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Free text with a handle in it ("the doc 7cd7…"): take the handle.
|
|
331
|
+
const m = UUID_RE.exec(s);
|
|
332
|
+
return m ? { handle: m[0].toLowerCase() } : null;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
/** The web host each known API serves, for telling a user which environment a link belongs to. */
|
|
336
|
+
const WEB_FOR_API = {
|
|
337
|
+
'api.workover.io': 'workover.io',
|
|
338
|
+
'api.workover.dev': 'workover.dev',
|
|
339
|
+
'api.workover.test': 'workover.test',
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* A sentence when a document link is for a different Workover than the one signed in to, else null.
|
|
344
|
+
*
|
|
345
|
+
* Only for hosts we know. A preview deploy's web and api hosts are not related by name, so they are
|
|
346
|
+
* left alone rather than guessed at — a wrong warning here would send someone to sign in somewhere
|
|
347
|
+
* they did not need to.
|
|
348
|
+
*/
|
|
349
|
+
export const environmentMismatch = (ref, api) => {
|
|
350
|
+
if (!ref?.host || !api) return null;
|
|
351
|
+
let apiHost;
|
|
352
|
+
try {
|
|
353
|
+
apiHost = new URL(String(api)).hostname.toLowerCase();
|
|
354
|
+
} catch {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
const signedInWeb = WEB_FOR_API[apiHost];
|
|
358
|
+
const linkHost = ref.host.replace(/^www\./, '');
|
|
359
|
+
const linkApi = Object.keys(WEB_FOR_API).find((k) => WEB_FOR_API[k] === linkHost);
|
|
360
|
+
if (!signedInWeb || !linkApi || signedInWeb === linkHost) return null;
|
|
361
|
+
return (
|
|
362
|
+
`That link is to ${linkHost}, but you are signed in to ${apiHost}. ` +
|
|
363
|
+
`Sign in there first (it replaces your current sign-in): WORKOVER_API=https://${linkApi} workover login`
|
|
364
|
+
);
|
|
288
365
|
};
|
|
289
366
|
|
|
290
367
|
const decodeAttr = (v) =>
|
|
@@ -326,3 +403,23 @@ export const imagesInHtml = (html) => {
|
|
|
326
403
|
}
|
|
327
404
|
return out;
|
|
328
405
|
};
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* What to do when there is no sign-in, as printed lines.
|
|
409
|
+
*
|
|
410
|
+
* Spelled out because the reader is often an agent, and an agent told only "not signed in" goes
|
|
411
|
+
* looking for a token somewhere else. Signing in needs a person to approve it in a browser, so the
|
|
412
|
+
* agent's next move is to ask for that, and the text says so.
|
|
413
|
+
*/
|
|
414
|
+
export const signInHelp = (hint, configFile) =>
|
|
415
|
+
[
|
|
416
|
+
'',
|
|
417
|
+
' Not signed in to Workover.',
|
|
418
|
+
'',
|
|
419
|
+
` Run \`${`workover login ${hint || ''}`.trim()}\`. It opens a browser where a person approves`,
|
|
420
|
+
' this machine, so an agent should ask its user to run it rather than look for a token.',
|
|
421
|
+
' Add --write to allow editing documents directly (without it, changes are proposed).',
|
|
422
|
+
' Staging instead of production: WORKOVER_API=https://api.workover.dev workover login',
|
|
423
|
+
...(configFile ? [` The sign-in is saved to ${configFile}.`] : []),
|
|
424
|
+
'',
|
|
425
|
+
].join('\n');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workover/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "Workover command line — sign in and cowork on your documents from the terminal.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "ScaleMath",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"files": [
|
|
23
23
|
"bin/",
|
|
24
24
|
"lib.mjs",
|
|
25
|
+
"skill/",
|
|
25
26
|
"README.md"
|
|
26
27
|
],
|
|
27
28
|
"engines": {
|
package/skill/SKILL.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: workover
|
|
3
|
+
description: Read, edit, comment on or propose changes to a Workover document. Use whenever the user pastes a Workover doc link (workover.io/app/<workspace>/docs/<id>, workover.dev/app/..., a Workover PR preview link), a Workover document UUID or id, or asks to work on "my Workover doc". Covers reading the doc, writing it, proposing edits, tabs, comments and the team style guide, through the Workover MCP tools or the `workover` CLI.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Working on a Workover document
|
|
7
|
+
|
|
8
|
+
A Workover link such as `https://workover.io/app/pellio/docs/7cd7e9ec-28af-4a2a-bb7c-668548380a08`
|
|
9
|
+
IS the document reference. Pass it as it is. The tools take a full link, the UUID at the end of
|
|
10
|
+
it, or the numeric id, and resolve it themselves.
|
|
11
|
+
|
|
12
|
+
**Do not** read `~/.workover/config.json`, call the Workover REST API with curl or a script, or
|
|
13
|
+
search the Workover source code for routes. The tools below already do all of that, with the
|
|
14
|
+
right access checks and error messages.
|
|
15
|
+
|
|
16
|
+
## 1. Use the Workover MCP tools when they are loaded
|
|
17
|
+
|
|
18
|
+
If tools named `workover_*` are available:
|
|
19
|
+
|
|
20
|
+
- Read: `workover_read_doc` with `docId` set to the link. The result includes the style guide.
|
|
21
|
+
- Tabs: `workover_list_tabs`. Reading or editing acts on ONE tab, so check before editing.
|
|
22
|
+
- Propose a change (the default): `workover_propose_edit` with the FULL revised markdown.
|
|
23
|
+
- Edit directly (only when the user asked for the change to be made): `workover_edit_doc`.
|
|
24
|
+
- Comments are CLI-only for now; see below.
|
|
25
|
+
|
|
26
|
+
## 2. Otherwise use the `workover` CLI
|
|
27
|
+
|
|
28
|
+
Run `workover` if it is on PATH. If it is not, run `npx -y @workover/cli@latest` instead (same
|
|
29
|
+
commands).
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
workover doc get <link> # the body as markdown; title + tabs go to stderr
|
|
33
|
+
workover doc tabs <link> # the tabs, if any
|
|
34
|
+
workover doc propose <link> --file new.md --note "what changed" # suggestions to accept
|
|
35
|
+
workover doc edit <link> --file new.md --note "what changed" # replace the body now
|
|
36
|
+
workover comments list <link> # open comment threads
|
|
37
|
+
workover comments add <link> "reply" --to <commentId>
|
|
38
|
+
workover doc search "query" # find a doc when you have no link
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`get` / `edit` are the same as `read` / `write`. Add `--tab <tabId>` to read or write one tab.
|
|
42
|
+
|
|
43
|
+
## Editing rules
|
|
44
|
+
|
|
45
|
+
- Read the document first. `propose` and `edit` take the COMPLETE document and replace the
|
|
46
|
+
body of one tab, so anything left out is deleted.
|
|
47
|
+
- The title is the H1. Start the body at `##` and never add a `#` heading.
|
|
48
|
+
- Change only what you mean to. Do not reflow paragraphs or renumber lists. Tables come back as
|
|
49
|
+
HTML; edit inside the cells.
|
|
50
|
+
- `propose` is the default. Use `edit` (or `workover_edit_doc`) only when the user asked for the
|
|
51
|
+
change to be made, and it needs a sign-in made with `workover login --write`.
|
|
52
|
+
- Follow the style guide that comes back with the read.
|
|
53
|
+
|
|
54
|
+
## When something fails
|
|
55
|
+
|
|
56
|
+
- **Not signed in**: signing in needs a person to approve it in a browser. Ask the user to run
|
|
57
|
+
`workover login` (`workover login --write` to allow direct edits). Do not look for a token.
|
|
58
|
+
- **"That link is to workover.dev, but you are signed in to api.workover.io"**: the link is for a
|
|
59
|
+
different environment. Tell the user and give them the command the error prints.
|
|
60
|
+
- **"No document at that link that this sign-in can open"**: it does not exist, or this account
|
|
61
|
+
has no access. Ask the user to check the link or to get the document shared. Do not try other
|
|
62
|
+
routes.
|
|
63
|
+
- **A permission error mentioning `--write`**: propose instead, or ask the user to sign in again
|
|
64
|
+
with `workover login --write`.
|