@workover/cli 0.14.4 → 0.25.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/feedback.mjs ADDED
@@ -0,0 +1,123 @@
1
+ // Telling Workover what its tools could not do: the MCP server's `workover_report_feedback` and the
2
+ // CLI's `workover feedback` (WO-1435).
3
+ //
4
+ // THE SAME FILE ships in @workover/cli (apps/cli/feedback.mjs) and @workover/mcp
5
+ // (apps/mcp/feedback.mjs), as site-setup.mjs does, because the two packages are published
6
+ // separately and neither may depend on the other. `apps/mcp/feedback.test.mjs` fails when the
7
+ // copies differ.
8
+ //
9
+ // WHY THIS EXISTS. Usage telemetry (telemetry.mjs) says which tools were called and leaves us to
10
+ // guess what the agent wanted. The agent knows: it was asked for something, reached for a tool, and
11
+ // found the argument missing or the answer wrong. So it can say so, with the fix it would make, and
12
+ // the report lands as an issue in Workover's own Linear Triage, where accepting it and handing it to
13
+ // an agent for a PR is one step. Fix the tool, and the next agent does not hit the wall.
14
+ //
15
+ // WHAT IS SENT, and only when an agent or a person calls this: the fields below, as written, plus
16
+ // this package's version and the client's name. The api attributes it to the signed-in account and
17
+ // redacts anything that looks like a token. It is NOT a channel for the person's documents, and the
18
+ // tool description says so to the agent before it writes a word.
19
+ //
20
+ // No ANSI and no side effects beyond the one request: `call(path, { method, body })` resolves the
21
+ // parsed JSON or throws an Error carrying the API's own sentence, as in site-setup.mjs.
22
+
23
+ export const FEEDBACK_KINDS = ['missing_capability', 'bug', 'confusing', 'docs', 'other'];
24
+
25
+ /** What the tool tells the agent. The when-to and the never-include are the important half. */
26
+ export const FEEDBACK_TOOL_DESCRIPTION =
27
+ "Tell the Workover team that one of these tools fell short, so it gets fixed. Call it when a Workover tool could not do what the task needed (a missing filter, argument or tool), returned something wrong, failed with an error you could not act on, or when you had to work around it (reading many documents to answer one question, say). Write it as an issue: what you were trying to do, what got in the way, and the change to the tool that would have let you do it. It becomes an issue in Workover's tracker. Never include the person's document text, customer data, tokens or passwords: describe the shape of the problem, not its contents. Do not call it for problems outside Workover (your own environment, another service). Mention to the person that you sent it.";
28
+
29
+ export const FEEDBACK_INPUT_SCHEMA = {
30
+ type: 'object',
31
+ properties: {
32
+ summary: {
33
+ type: 'string',
34
+ description: 'One line naming the gap, like an issue title: "workover_search_docs cannot filter by project".',
35
+ },
36
+ intent: {
37
+ type: 'string',
38
+ description: 'What you, or the person you work for, were trying to do. The goal, not the tool call.',
39
+ },
40
+ problem: {
41
+ type: 'string',
42
+ description: 'What the Workover tools could not do or did wrong, and what you did instead. Quote an error message if there was one.',
43
+ },
44
+ proposedFix: {
45
+ type: 'string',
46
+ description: 'The change that would have let you do it: a new argument, a new tool, a clearer error. Concrete enough to build.',
47
+ },
48
+ tool: {
49
+ type: 'string',
50
+ description: 'The Workover tool this is about, e.g. "workover_search_docs". Leave it out when no single tool is at fault.',
51
+ },
52
+ kind: {
53
+ type: 'string',
54
+ enum: FEEDBACK_KINDS,
55
+ description: 'missing_capability (the tool cannot do it), bug (it did it wrong), confusing (an error or description misled you), docs (the tool description is wrong or missing), other.',
56
+ },
57
+ },
58
+ required: ['summary', 'intent', 'problem'],
59
+ };
60
+
61
+ /** Trimmed strings only; anything else the caller sent stays behind. */
62
+ const str = (v) => (typeof v === 'string' && v.trim() ? v.trim() : undefined);
63
+
64
+ /**
65
+ * Send one report. `meta` is { surface: 'mcp' | 'cli', version, client }.
66
+ * Resolves the api's answer: { status: 'filed' | 'queued' | 'duplicate', id, issue }.
67
+ */
68
+ export async function submitFeedback(call, args = {}, meta = {}) {
69
+ const missing = ['summary', 'intent', 'problem'].filter((k) => !str(args[k]));
70
+ if (missing.length) {
71
+ const e = new Error(
72
+ `Missing ${missing.join(', ')}. A report needs a one-line summary, what you were trying to do (intent) and what got in the way (problem).`,
73
+ );
74
+ e.status = 400;
75
+ throw e;
76
+ }
77
+ const body = {
78
+ summary: str(args.summary),
79
+ intent: str(args.intent),
80
+ problem: str(args.problem),
81
+ ...(str(args.proposedFix) ? { proposedFix: str(args.proposedFix) } : {}),
82
+ ...(str(args.tool) ? { tool: str(args.tool) } : {}),
83
+ kind: FEEDBACK_KINDS.includes(args.kind) ? args.kind : 'other',
84
+ surface: meta.surface === 'cli' ? 'cli' : 'mcp',
85
+ ...(str(meta.version) ? { version: str(meta.version) } : {}),
86
+ ...(str(meta.client) ? { client: str(meta.client) } : {}),
87
+ };
88
+ try {
89
+ return await call('/mcp/feedback', { method: 'POST', body });
90
+ } catch (e) {
91
+ // An api from before this route existed answers 404. Say that, rather than a bare "API error",
92
+ // so the agent tells the person the report did not go anywhere instead of retrying forever.
93
+ if (e?.status === 404 || /\(404\)/.test(String(e?.message))) {
94
+ const old = new Error(
95
+ "This Workover API does not accept feedback yet, so the report was not sent. Tell the person what you found instead; they can pass it on.",
96
+ );
97
+ old.status = 404;
98
+ throw old;
99
+ }
100
+ throw e;
101
+ }
102
+ }
103
+
104
+ /** The answer, as lines for a terminal or an MCP text result. */
105
+ export function renderFeedbackResult(res) {
106
+ if (res?.status === 'duplicate') {
107
+ return [
108
+ res.issue
109
+ ? `Already reported: this is ${res.issue.identifier} (${res.issue.url}). Nothing new was filed.`
110
+ : `Already reported (report #${res.id}). Nothing new was filed.`,
111
+ ];
112
+ }
113
+ if (res?.issue) {
114
+ return [
115
+ `Sent. Filed for the Workover team as ${res.issue.identifier}: ${res.issue.url}`,
116
+ 'Thank you. Tell the person you reported it.',
117
+ ];
118
+ }
119
+ return [
120
+ `Sent (report #${res?.id ?? '?'}). The Workover team will see it; it is filed in their tracker shortly.`,
121
+ 'Thank you. Tell the person you reported it.',
122
+ ];
123
+ }
package/lib.mjs CHANGED
@@ -3,6 +3,52 @@
3
3
  import { mkdirSync, writeFileSync, renameSync, chmodSync, rmSync } from 'fs';
4
4
  import { dirname, join, basename } from 'path';
5
5
 
6
+ /**
7
+ * The Mintlify components a docs-site document reads and writes as themselves (WO-1299).
8
+ *
9
+ * A test in apps/api (agent-docs.spec.ts) holds this list equal to the converter's own and to the
10
+ * editor's, so the syntax `doc --help` and the skill describe cannot drift from what round-trips.
11
+ */
12
+ export const MDX_COMPONENTS = [
13
+ 'Accordion', 'AccordionGroup', 'Badge', 'Callout', 'Card', 'CardGroup', 'Check', 'CodeGroup',
14
+ 'Color', 'Color.Item', 'Color.Row', 'Column', 'Columns', 'Danger', 'Expandable', 'FileTree',
15
+ 'Frame', 'GitHub.Repo', 'Icon', 'Info', 'MDX', 'Note', 'Panel', 'ParamField', 'Prompt',
16
+ 'RequestExample', 'ResponseExample', 'ResponseField', 'Step', 'Steps', 'Tab', 'Tabs', 'Tile',
17
+ 'Tip', 'Tooltip', 'Tree', 'Tree.File', 'Tree.Folder', 'Update', 'View', 'Visibility', 'Visible',
18
+ 'Warning',
19
+ ];
20
+
21
+ /** `items` joined with ", " and wrapped to `width` columns, each line prefixed with `indent`. */
22
+ export const wrapList = (items, width = 78, indent = ' ') => {
23
+ const lines = [];
24
+ let line = '';
25
+ for (const [i, item] of items.entries()) {
26
+ const word = item + (i < items.length - 1 ? ',' : '.');
27
+ if (line && indent.length + line.length + 1 + word.length > width) {
28
+ lines.push(indent + line);
29
+ line = word;
30
+ } else line = line ? `${line} ${word}` : word;
31
+ }
32
+ if (line) lines.push(indent + line);
33
+ return lines;
34
+ };
35
+
36
+ /** The MDX section of `workover doc --help`. */
37
+ export const mdxHelpLines = () => [
38
+ ' Docs sites: a document in a project with a published site or a Git sync is',
39
+ ' Mintlify MDX, not plain markdown, and `doc read` says "Format: Mintlify MDX".',
40
+ ' Write back the MDX you read: components as JSX (<Note>text</Note>,',
41
+ ' <Card title="Setup" icon="gear" href="/setup">text</Card>, <Steps><Step',
42
+ ' title="Install">text</Step></Steps>), math as $x^2$ or a $$ block, a snippet',
43
+ ' as <Snippet file="snippets/x.mdx" />, {{name}} for a Workover variable.',
44
+ ' Keep every block you are not changing exactly as printed. The components:',
45
+ ...wrapList(MDX_COMPONENTS, 78, ' '),
46
+ ' A write that would delete a component, snippet, math or embed is refused',
47
+ ' and names them; pass --allow-block-removal to `doc write` when that is the',
48
+ ' point. In any other project documents are plain markdown, and a body with',
49
+ ' components is refused rather than written without them.',
50
+ ];
51
+
6
52
  /**
7
53
  * Strip trailing slashes from the API base URL (so `${API}${path}` never doubles up).
8
54
  *
@@ -472,10 +518,336 @@ export const signInHelp = (hint, configFile) =>
472
518
  '',
473
519
  ' Not signed in to Workover.',
474
520
  '',
475
- ` Run \`${`workover login ${hint || ''}`.trim()}\`. It opens a browser where a person approves`,
476
- ' this machine, so an agent should ask its user to run it rather than look for a token.',
521
+ ` Run \`${`workover login ${hint || ''}`.trim()}\`. It prints a link where a person approves this`,
522
+ ' machine, so an agent should never look for a token. An agent adds --no-wait, sends the',
523
+ ' person the link, and runs `workover login --resume` once they have approved.',
477
524
  ' Add --write to allow editing documents directly (without it, changes are proposed).',
478
525
  ' Staging instead of production: WORKOVER_API=https://api.workover.dev workover login',
479
526
  ...(configFile ? [` The sign-in is saved to ${configFile}.`] : []),
480
527
  '',
481
528
  ].join('\n');
529
+
530
+ /**
531
+ * A flag that carries a JSON object, such as `--taxonomies '{"changelog_product":[50]}'`.
532
+ *
533
+ * Returns `undefined` when the flag is absent, the object when it parses to one, and `null` when it
534
+ * is present but not a JSON object (an array, a number, or broken JSON), so the caller can say so
535
+ * rather than sending something the API would misread.
536
+ */
537
+ export const jsonObjectFlag = (value) => {
538
+ if (value == null) return undefined;
539
+ try {
540
+ const v = JSON.parse(String(value));
541
+ return v && typeof v === 'object' && !Array.isArray(v) ? v : null;
542
+ } catch {
543
+ return null;
544
+ }
545
+ };
546
+
547
+ /** The image types the API's media upload accepts, and its size cap (apps/api multer config). */
548
+ export const UPLOAD_IMAGE_EXT = ['png', 'jpg', 'jpeg', 'gif', 'webp'];
549
+ export const UPLOAD_IMAGE_MAX_BYTES = 5 * 1024 * 1024;
550
+
551
+ /**
552
+ * Whether `workover doc upload` may send a file. Takes the REAL path (symlinks already resolved, so a
553
+ * `shot.png` that points at a key is judged by its target) and its size. Refuses anything inside a dot
554
+ * file or dot directory (~/.ssh, ~/.workover), anything that is not an image type the API takes, and
555
+ * anything over the API's cap, so a scheduled agent cannot be talked into uploading a secret into a
556
+ * document the whole team can open. Returns `{ ext, mime }` or `{ error }`.
557
+ */
558
+ export const vetImageUpload = (realPath, size) => {
559
+ const parts = String(realPath).split(/[\\/]/).filter(Boolean);
560
+ if (parts.some((part) => part.startsWith('.')))
561
+ return { error: 'Refusing a file inside a hidden (dot) file or directory.' };
562
+ const ext = (parts.at(-1) || '').split('.').pop().toLowerCase();
563
+ if (!UPLOAD_IMAGE_EXT.includes(ext))
564
+ return { error: `Only ${UPLOAD_IMAGE_EXT.join(', ')} images can be uploaded.` };
565
+ if (!(size > 0)) return { error: 'The file is empty.' };
566
+ if (size > UPLOAD_IMAGE_MAX_BYTES) return { error: 'The image is larger than 5 MB.' };
567
+ const mime = ext === 'jpg' || ext === 'jpeg' ? 'image/jpeg' : `image/${ext}`;
568
+ return { ext, mime };
569
+ };
570
+
571
+
572
+ /**
573
+ * `workover doc status <doc>`: the answer of `GET /project/doc/:id/status` as lines a person (or an
574
+ * agent) reads. Each status says whether THIS sign-in may move the document there and, if not, the
575
+ * API's reason, so "why can't I publish this?" is answered here rather than by trying.
576
+ *
577
+ * The WordPress line is on purpose: the Workover status and the WordPress post's status are two
578
+ * different things, and a document marked Published in Workover with its post still a draft is the
579
+ * exact confusion of 13 Nov 2026 (WO-1264).
580
+ */
581
+ export const renderStatusList = (r) => {
582
+ const lines = [''];
583
+ lines.push(` #${r.documentId} ${r.title || 'Untitled'}`);
584
+ lines.push(` Status: ${r.statusLabel} (${r.status}) Workflow: ${r.workflow}`);
585
+ if (r.pendingApproval) {
586
+ lines.push(` Waiting on approval for "${r.pendingApproval.statusKey}" (request #${r.pendingApproval.id}).`);
587
+ }
588
+ lines.push(wordpressLine(r));
589
+ lines.push('');
590
+ const width = Math.max(...r.statuses.map((s) => s.key.length), 6);
591
+ const labelWidth = Math.max(...r.statuses.map((s) => s.label.length), 6);
592
+ for (const s of r.statuses) {
593
+ const mark = s.key === r.status ? '●' : s.allowed ? ' ' : '✗';
594
+ const note =
595
+ s.key === r.status
596
+ ? 'current'
597
+ : !s.allowed
598
+ ? s.reason || 'not allowed'
599
+ : s.needsApproval
600
+ ? 'opens an approval request when entered'
601
+ : '';
602
+ lines.push(` ${mark} ${s.key.padEnd(width)} ${s.label.padEnd(labelWidth)} ${note}`.trimEnd());
603
+ }
604
+ lines.push('', ` Set one: workover doc status ${r.documentId} <status>`, '');
605
+ return lines;
606
+ };
607
+
608
+ /** What a WordPress-linked document's post is doing, said next to the Workover status. */
609
+ const wordpressLine = (r) =>
610
+ r.wordpress
611
+ ? ` WordPress post #${r.wordpress.postId}: ${r.wordpress.liveStatus || 'unknown status'}. The Workover status does not change it; publish from the document's WordPress tab.`
612
+ : ' Not linked to a WordPress post.';
613
+
614
+ /**
615
+ * `workover doc status <doc> <status>`: what happened, plainly. Exactly one of: it moved, it moved
616
+ * and is now waiting on an approval, or nothing changed because it was already there. A refusal
617
+ * never reaches this (see `statusRefusal`).
618
+ */
619
+ export const renderStatusChange = (r) => {
620
+ const label = (key) => r.statuses.find((s) => s.key === key)?.label || key;
621
+ const lines = [''];
622
+ if (!r.changed) {
623
+ lines.push(` Already ${label(r.status)} (${r.status}). Nothing changed.`);
624
+ } else {
625
+ lines.push(` \x1b[32m✓\x1b[0m Moved #${r.documentId} from ${label(r.previous)} to ${label(r.status)}.`);
626
+ if (r.pendingApproval && r.pendingApproval.statusKey === r.status) {
627
+ lines.push(
628
+ ` It is now waiting on approval (request #${r.pendingApproval.id}); the approvers have been asked. It moves on once they approve.`,
629
+ );
630
+ }
631
+ }
632
+ lines.push(wordpressLine(r), '');
633
+ return lines;
634
+ };
635
+
636
+ /**
637
+ * A refused status change, as one sentence that starts with "Refused" and carries the API's reason:
638
+ * the role (`role_forbidden`), the workflow (`workflow_gate`), the token (`token_scope`) or an
639
+ * unknown status. `status` is the HTTP status, `body` the parsed JSON (or null).
640
+ */
641
+ export const statusRefusal = (status, body) => {
642
+ const message = Array.isArray(body?.message) ? body.message.join('; ') : body?.message;
643
+ const why = typeof message === 'string' && message ? message : `Workover answered ${status}.`;
644
+ if (status === 401) return 'Your Workover sign-in has expired or was revoked. Run `workover login`.';
645
+ if (status === 400 || status === 403) return `Refused: ${why}`;
646
+ // Nest's own 404 for a route it does not have: a server older than this command (WO-1264).
647
+ if (status === 404 && /^Cannot (GET|PATCH) /.test(why))
648
+ return 'This Workover server does not have `doc status` yet. It arrives with the next release.';
649
+ if (status === 404) return 'No document with that id that this sign-in can open.';
650
+ return `Workover answered ${status}: ${why}`;
651
+ };
652
+
653
+ /**
654
+ * `workover doc rename <doc> --title "..."`: what happened. The body is never sent, so the answer
655
+ * says it is unchanged, and that a linked WordPress post keeps its title and slug until a push.
656
+ */
657
+ export const renderRename = (r) => {
658
+ if (r?.changed === false) return ['', ` Already called "${r.title}". Nothing changed.`, ''];
659
+ const lines = [
660
+ '',
661
+ ` \x1b[32m✓\x1b[0m Renamed #${r?.documentId} from "${r?.previous || 'Untitled'}" to "${r?.title}".`,
662
+ ' The body was not changed, and neither was any linked WordPress post or its slug.',
663
+ ];
664
+ if (r?.documentUrl) lines.push(` ${r.documentUrl}`);
665
+ lines.push('');
666
+ return lines;
667
+ };
668
+
669
+ /** A refused rename, as one sentence with the API's reason (scope, role, empty or long title). */
670
+ export const renameRefusal = (status, body) => {
671
+ const message = Array.isArray(body?.message) ? body.message.join('; ') : body?.message;
672
+ const why = typeof message === 'string' && message ? message : `Workover answered ${status}.`;
673
+ if (status === 401) return 'Your Workover sign-in has expired or was revoked. Run `workover login`.';
674
+ if (status === 400 || status === 403) return `Refused: ${why}`;
675
+ // Nest's own 404 for a route it does not have: a server older than this command.
676
+ if (status === 404 && /^Cannot PATCH /.test(why))
677
+ return 'This Workover server does not have `doc rename` yet. It arrives with the next release; until then, rename it in the editor.';
678
+ if (status === 404) return 'No document with that id that this sign-in can open.';
679
+ return `Workover answered ${status}: ${why}`;
680
+ };
681
+
682
+ /* ------------------------------------------------------------------ setup, for agents (WO-1284)
683
+ *
684
+ * setup.md hands a coding agent the job of setting Workover up with a person. On 2026-11-14 an agent
685
+ * run of it could not get past `workover login` (it waits up to ten minutes, and an agent's shell
686
+ * gives up long before), could not tell which account the person had approved with, and could not
687
+ * check any later step without asking. These are the pieces that fix that; the commands that use
688
+ * them are in bin/workover.mjs.
689
+ */
690
+
691
+ /** The web app's origin for a known API, e.g. https://workover.io for https://api.workover.io. */
692
+ export const webForApi = (api) => {
693
+ try {
694
+ const web = WEB_FOR_API[new URL(String(api)).hostname.toLowerCase()];
695
+ return web ? `https://${web}` : null;
696
+ } catch {
697
+ return null;
698
+ }
699
+ };
700
+
701
+ /**
702
+ * Whether opening a browser here would put it in front of the person. Not on a Linux box with no
703
+ * display (an agent's container, a CI runner, a server), and not over SSH on any platform, where it
704
+ * would open on the remote machine's screen, if anywhere. The link is printed either way.
705
+ */
706
+ export const canOpenBrowser = (platform, env = {}) => {
707
+ if (env.SSH_CONNECTION || env.SSH_TTY) return false;
708
+ if (platform === 'darwin' || platform === 'win32') return true;
709
+ return !!(env.DISPLAY || env.WAYLAND_DISPLAY);
710
+ };
711
+
712
+ /**
713
+ * What `login --no-wait` saves so that `login --resume` can finish the same sign-in later. The
714
+ * device code can claim the token once the person approves, so it is stored like the token is
715
+ * (owner-only, writePrivateFile), and dropped as soon as the sign-in completes, fails or expires.
716
+ */
717
+ export const pendingLogin = (start, { api, scopes, client, now = Date.now() }) => ({
718
+ api,
719
+ scopes,
720
+ client,
721
+ device_code: start.device_code,
722
+ user_code: start.user_code,
723
+ verification_uri_complete: start.verification_uri_complete,
724
+ interval: start.interval || 5,
725
+ expires_at: new Date(now + (start.expires_in || 600) * 1000).toISOString(),
726
+ });
727
+
728
+ /**
729
+ * Whether a saved pending sign-in can still be finished: `none` (nothing saved), `expired`,
730
+ * `elsewhere` (it was started against another API than the one this command would use), or `ok`.
731
+ */
732
+ export const pendingLoginState = (pending, { api, now = Date.now() }) => {
733
+ if (!pending?.device_code) return 'none';
734
+ if (pending.api && api && normalizeApi(pending.api) !== normalizeApi(api)) return 'elsewhere';
735
+ const exp = Date.parse(pending.expires_at || '');
736
+ if (!Number.isFinite(exp) || exp <= now) return 'expired';
737
+ return 'ok';
738
+ };
739
+
740
+ /** The account, as a person recognizes it: `Sam <sam@acme.test>`, or the email alone. */
741
+ export const accountLabel = (user) => {
742
+ if (!user?.email) return user?.name || 'an account with no email';
743
+ return user.name ? `${user.name} <${user.email}>` : user.email;
744
+ };
745
+
746
+ /**
747
+ * WRONG ACCOUNT. Twice on WO-1401's run, the person approved the device code in a browser signed in
748
+ * to another account, and the agent only noticed when the workspace list looked wrong. So the
749
+ * account is named the moment the sign-in completes, with what to do when it is not the one meant.
750
+ */
751
+ const WRONG_ACCOUNT =
752
+ ' Not the account you meant? Run `workover logout`, sign in to the right account in the browser, then `workover login` again.';
753
+
754
+ /** The line `workover login` and `login --resume` end on: where, as whom, and which workspaces. */
755
+ export const renderSignedIn = (me, { api }) => {
756
+ if (!me?.user) return ['', ` ✓ Signed in to ${api}. \`workover whoami\` shows the account.`, ''];
757
+ const ws = (me.workspaces || []).map((w) => w.slug ?? w.id);
758
+ return [
759
+ '',
760
+ ` ✓ Signed in to ${api} as ${accountLabel(me.user)}.`,
761
+ ws.length ? ` Workspaces: ${ws.join(', ')}` : ' No workspaces yet. The person creates one when they sign up in the browser.',
762
+ WRONG_ACCOUNT,
763
+ '',
764
+ ];
765
+ };
766
+
767
+ /** `workover login --json` / `login --resume --json` once it completes: the account, for an agent to check. */
768
+ export const signedInJson = (me, { api }) => ({
769
+ signedIn: true,
770
+ api,
771
+ user: me?.user ? { id: me.user.id, name: me.user.name ?? null, email: me.user.email } : null,
772
+ workspaces: (me?.workspaces || []).map((w) => ({ id: w.id, slug: w.slug ?? null, name: w.name, role: w.role })),
773
+ });
774
+
775
+ /** `workover whoami`: the account, how it signed in, and its workspaces. */
776
+ export const renderWhoami = (me, { api, token }) => {
777
+ const lines = [''];
778
+ lines.push(` Signed in as ${accountLabel(me.user)}`);
779
+ lines.push(` on ${api}`);
780
+ if (me.client) lines.push(` Token: ${me.client}${token ? ` (${token.slice(0, 12)}…)` : ''}`);
781
+ if (Array.isArray(me.scopes)) lines.push(` Can: ${me.scopes.join(', ') || 'nothing'}`);
782
+ const ws = me.workspaces || [];
783
+ if (!ws.length) {
784
+ lines.push('', ' No workspaces yet. The person creates one when they sign up in the browser.');
785
+ } else {
786
+ lines.push('', ` Workspaces (${ws.length}):`);
787
+ for (const w of ws) lines.push(` ${String(w.slug ?? '-').padEnd(24)} ${w.name} · ${w.role}`);
788
+ }
789
+ lines.push('', WRONG_ACCOUNT, ' Revoke it in Workover, Settings, Developer.', '');
790
+ return lines;
791
+ };
792
+
793
+ /** `workover projects`: grouped by workspace, with the slug a Workover URL needs. */
794
+ export const renderProjects = (list) => {
795
+ if (!list.length) return ['', ' No projects.', ''];
796
+ const groups = new Map();
797
+ for (const p of list) {
798
+ const key = p.organization?.slug ?? p.organization?.id ?? '';
799
+ if (!groups.has(key)) groups.set(key, { org: p.organization, projects: [] });
800
+ groups.get(key).projects.push(p);
801
+ }
802
+ const lines = [''];
803
+ for (const { org, projects } of groups.values()) {
804
+ if (org) lines.push(` ${org.name} (workspace ${org.slug ?? org.id})`);
805
+ for (const p of projects) {
806
+ const kind = p.hasSite ? 'Help Center' : '';
807
+ lines.push(` #${String(p.id).padEnd(6)} ${String(p.name || p.title || 'Project').padEnd(32)} ${kind}`.trimEnd());
808
+ }
809
+ lines.push('');
810
+ }
811
+ lines.push(' `workover status <id>` shows where a project’s setup has got to.', '');
812
+ return lines;
813
+ };
814
+
815
+ const tick = (ok) => (ok ? '✓' : '·');
816
+
817
+ /** `workover status <project>`: what is set up, what is waiting, and what is left for the person. */
818
+ export const renderSetupStatus = (s, { web } = {}) => {
819
+ const link = (path) => (path ? (web ? `${web}${path}` : path) : null);
820
+ const lines = ['', ` ${s.project.name} (#${s.project.id}, workspace ${s.workspace.slug ?? s.workspace.id})`];
821
+ const publish = link(s.paths?.publish);
822
+ if (publish) lines.push(` ${publish}`);
823
+ lines.push('');
824
+ if (!s.site) {
825
+ lines.push(` ${tick(false)} Site none: this project does not publish to a Workover Help Center`);
826
+ } else {
827
+ lines.push(
828
+ ` ${tick(s.site.published)} Site ${s.site.published ? `live at ${s.site.url}` : `not published yet (${s.site.address ?? 'no address'})`}`,
829
+ );
830
+ const d = s.site.domain;
831
+ lines.push(
832
+ ` ${tick(d?.status === 'active')} Domain ${
833
+ d ? `${d.hostname}${d.basePath ?? ''}: ${d.status}${d.message ? ` (${d.message})` : ''}` : 'none (optional)'
834
+ }`,
835
+ );
836
+ }
837
+ const repos = s.github.repositories || [];
838
+ lines.push(
839
+ ` ${tick(s.github.connected)} GitHub ${s.github.connected ? 'connected' : 'not connected'}${
840
+ s.github.connected ? `, ${repos.length ? repos.map((r) => r.repo).join(', ') : 'no repository linked'}` : ''
841
+ }`,
842
+ );
843
+ lines.push(` ${tick(s.reviewer.aiConfigured)} AI ${s.reviewer.aiConfigured ? 'ready' : 'no provider key'}`);
844
+ lines.push(` ${tick(s.reviewer.enabled)} Reviewer ${s.reviewer.enabled ? 'on' : 'off'}`);
845
+ const w = s.waiting || {};
846
+ lines.push(` Waiting ${w.changeRequests ?? 0} change request(s), ${w.suggestions ?? 0} suggestion(s)`);
847
+ if (s.next?.length) {
848
+ lines.push('', ' Left for the person, in the browser:');
849
+ for (const n of s.next) lines.push(` - ${n}`);
850
+ } else lines.push('', ' Nothing left to set up.');
851
+ lines.push('');
852
+ return lines;
853
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workover/cli",
3
- "version": "0.14.4",
3
+ "version": "0.25.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",
@@ -22,6 +22,10 @@
22
22
  "files": [
23
23
  "bin/",
24
24
  "lib.mjs",
25
+ "site-setup.mjs",
26
+ "site-proxy.mjs",
27
+ "site-folder.mjs",
28
+ "feedback.mjs",
25
29
  "skill/",
26
30
  "README.md"
27
31
  ],