@workover/cli 0.5.0 → 0.6.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 +66 -0
- package/bin/workover.mjs +239 -7
- package/lib.mjs +51 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,9 +15,11 @@ workover login # sign in (opens your browser to approve)
|
|
|
15
15
|
workover login --publish # ...and also request permission to publish to WordPress
|
|
16
16
|
workover login --draft # ...and also request permission to write drafts with AI
|
|
17
17
|
workover login --write # ...and also allow direct edits, with no suggestions to review
|
|
18
|
+
workover login --rules # ...and also allow changing the style guide
|
|
18
19
|
workover projects # the projects you can reach, with their ids
|
|
19
20
|
workover doc list --project 11
|
|
20
21
|
workover doc read 1234
|
|
22
|
+
workover rules list --project 11 # the style guide agents should write by
|
|
21
23
|
workover draft --org 3 --project 11 "Document the billing flow"
|
|
22
24
|
workover whoami # show the current sign-in
|
|
23
25
|
workover logout # sign out and revoke this device's token
|
|
@@ -85,6 +87,70 @@ is how images get deleted by something that thought it was filling in a blank. I
|
|
|
85
87
|
without that scope it is refused and `doc propose` is the way through. Every direct edit is recorded
|
|
86
88
|
in the workspace's audit log, since unlike a proposal it leaves no review trail of its own.
|
|
87
89
|
|
|
90
|
+
## The style guide
|
|
91
|
+
|
|
92
|
+
Your workspace's **Style Guide** (Workover → Settings → Style Guide) is the set of rules your team
|
|
93
|
+
writes by — spelling variant, punctuation, words you don't use. It used to steer only Workover's own
|
|
94
|
+
AI. It now applies to anything writing through this CLI or the MCP server too:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
workover rules list --project 11 # the rules in force, workspace + project
|
|
98
|
+
workover rules export --project 11 # the same, as a block to paste into AGENTS.md
|
|
99
|
+
workover rules add --project 11 "Never use an em dash." # needs --rules at login
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Reading the guide needs nothing beyond a normal login. **Adding to it needs `workover login
|
|
103
|
+
--rules`**, because a rule is a standing instruction that steers every future draft and review for
|
|
104
|
+
everyone in the workspace until somebody turns it off.
|
|
105
|
+
|
|
106
|
+
`workover rules export` is the one to reach for in a repo. Committing the block into your
|
|
107
|
+
`AGENTS.md` or `CLAUDE.md` puts your house style in front of every agent that touches the
|
|
108
|
+
repository, including the ones that never call Workover:
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
workover rules export --project 11 >> AGENTS.md
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
After a `doc propose` or `doc write`, Workover reports which rules the new text breaks — quoting
|
|
115
|
+
what it found, with no model call, so it happens every time. It only decides the rules a machine
|
|
116
|
+
can: an em-dash ban, a spelling variant, a banned word in quotes. Rules needing judgment are listed
|
|
117
|
+
as **not checked** rather than counted as passed, because an empty list of violations over rules
|
|
118
|
+
nobody looked at is not a clean bill of health.
|
|
119
|
+
|
|
120
|
+
## Documents with tabs
|
|
121
|
+
|
|
122
|
+
A Workover document can hold several separate bodies as tabs, and **read and write act on one of
|
|
123
|
+
them**:
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
workover doc tabs 1234 # the tabs, with their ids
|
|
127
|
+
workover doc tab-new 1234 --title "Reference" # a new, empty tab
|
|
128
|
+
workover doc read 1234 --tab 12 > reference.md
|
|
129
|
+
workover doc write 1234 --tab 12 --file reference.md
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Without `--tab` you get the document's main body. On a multi-tab document that is *not* the whole
|
|
133
|
+
document — so `doc read` tells you which tab you read and what the others are, rather than letting
|
|
134
|
+
the next `doc write` replace the wrong one.
|
|
135
|
+
|
|
136
|
+
Creating and renaming tabs needs `--write`. Deleting a tab, and changing which tab syncs to
|
|
137
|
+
WordPress, stay in the browser: one destroys writing with no undo, and the other changes what
|
|
138
|
+
publishes.
|
|
139
|
+
|
|
140
|
+
## Who wrote it
|
|
141
|
+
|
|
142
|
+
Every direct edit is recorded in the document's history with **both** the person whose token was
|
|
143
|
+
used and the agent that made it — *"Alex Panagis · via Claude Code"*.
|
|
144
|
+
|
|
145
|
+
The agent's name comes from the token, set when you approved the login, not from anything the client
|
|
146
|
+
sends with the request. Name yours if you are wiring up a tool of your own:
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
workover login --client "Scout"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The browser shows that name on the approval screen before you grant anything.
|
|
153
|
+
|
|
88
154
|
## Queueing a draft
|
|
89
155
|
|
|
90
156
|
`workover draft` asks Workover to write something; it does not write it itself. Workover reads the
|
package/bin/workover.mjs
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
stripHtml,
|
|
23
23
|
documentText,
|
|
24
24
|
contentCommitted,
|
|
25
|
+
renderRulesBlock,
|
|
25
26
|
} from '../lib.mjs';
|
|
26
27
|
|
|
27
28
|
/*
|
|
@@ -126,10 +127,22 @@ async function login() {
|
|
|
126
127
|
if (process.argv.includes('--publish')) scopes.push('publish');
|
|
127
128
|
if (process.argv.includes('--draft')) scopes.push('draft');
|
|
128
129
|
if (process.argv.includes('--write')) scopes.push('write');
|
|
130
|
+
if (process.argv.includes('--rules')) scopes.push('rules');
|
|
131
|
+
|
|
132
|
+
// WHAT IS SIGNING IN, sent so the token can be NAMED it.
|
|
133
|
+
//
|
|
134
|
+
// Every token used to be minted "Workover CLI" whoever created it, so a document's history could
|
|
135
|
+
// not say which agent wrote a change — Claude Code, Scout and a person at a terminal were one
|
|
136
|
+
// label. `--client` lets a wrapper identify itself; the default is this CLI's own name, which is
|
|
137
|
+
// what a person typing `workover login` should see on the approval screen.
|
|
138
|
+
//
|
|
139
|
+
// Self-reported, and the approval screen is where that is made safe: the person reads the name
|
|
140
|
+
// before granting anything.
|
|
141
|
+
const client = flagValue('client') || 'Workover CLI';
|
|
129
142
|
|
|
130
143
|
let start;
|
|
131
144
|
try {
|
|
132
|
-
start = await post('/cli-auth/device/code', { scopes });
|
|
145
|
+
start = await post('/cli-auth/device/code', { scopes, client });
|
|
133
146
|
} catch {
|
|
134
147
|
console.error(`\n ✗ Couldn't reach Workover at ${API}\n`);
|
|
135
148
|
process.exit(1);
|
|
@@ -152,6 +165,12 @@ async function login() {
|
|
|
152
165
|
console.log(' replaces a document’s body with no suggestions to accept. Without it every');
|
|
153
166
|
console.log(' change is a proposal you review, which is the default and stays available.');
|
|
154
167
|
}
|
|
168
|
+
if (scopes.includes('rules')) {
|
|
169
|
+
console.log('\n Requesting permission to CHANGE YOUR STYLE GUIDE. A rule steers every future');
|
|
170
|
+
console.log(' draft and review for everyone in the workspace until somebody turns it off.');
|
|
171
|
+
console.log(' Reading the guide never needs this — only adding to or changing it does.');
|
|
172
|
+
}
|
|
173
|
+
console.log(`\n Signing in as: ${client}`);
|
|
155
174
|
console.log(`\n Your login code: \x1b[1m${start.user_code}\x1b[0m`);
|
|
156
175
|
console.log(` Approve it here: ${start.verification_uri_complete}\n`);
|
|
157
176
|
console.log(' Opening your browser…');
|
|
@@ -576,18 +595,131 @@ const docIdArg = (positionals, usage) => {
|
|
|
576
595
|
return id;
|
|
577
596
|
};
|
|
578
597
|
|
|
598
|
+
/**
|
|
599
|
+
* What the api said about house style after a write, printed to STDERR.
|
|
600
|
+
*
|
|
601
|
+
* stderr because stdout is the command's result and people pipe it. This is commentary on the
|
|
602
|
+
* write, not the write's output, and it should not end up inside a file somebody redirected.
|
|
603
|
+
*
|
|
604
|
+
* Nothing is printed when there is nothing to say — a workspace with no rules should not be told
|
|
605
|
+
* about a style guide it has not written.
|
|
606
|
+
*/
|
|
607
|
+
const printStyleFeedback = (style) => {
|
|
608
|
+
if (!style?.summary) return;
|
|
609
|
+
console.error('');
|
|
610
|
+
for (const line of style.summary.split('\n')) console.error(` ${line}`);
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
const RULES_USAGE = [
|
|
614
|
+
'',
|
|
615
|
+
' Usage: workover rules <command>',
|
|
616
|
+
'',
|
|
617
|
+
' list --project <id> | --org <id> the style guide in force',
|
|
618
|
+
' [--json]',
|
|
619
|
+
' export --project <id> | --org <id> the guide as a block to paste into',
|
|
620
|
+
' AGENTS.md / CLAUDE.md, so an agent',
|
|
621
|
+
' follows it without calling Workover',
|
|
622
|
+
' add --project <id> | --org <id> add a rule (needs --rules at login)',
|
|
623
|
+
' "<the rule>"',
|
|
624
|
+
'',
|
|
625
|
+
' Reading the guide needs nothing beyond a normal login. Adding to it needs',
|
|
626
|
+
' `workover login --rules`, because a rule steers every future draft and review',
|
|
627
|
+
' for everyone in the workspace until somebody turns it off.',
|
|
628
|
+
'',
|
|
629
|
+
].join('\n');
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Read, export or extend the workspace's style guide.
|
|
633
|
+
*
|
|
634
|
+
* `export` is the one worth explaining. Everything else here asks Workover at the moment it is
|
|
635
|
+
* needed, which only helps an agent that is already talking to Workover. A repo that commits the
|
|
636
|
+
* guide into its own AGENTS.md gets the rules in front of every agent that touches it, including
|
|
637
|
+
* the ones that never call this API at all — which is most of them.
|
|
638
|
+
*/
|
|
639
|
+
async function rulesCommand() {
|
|
640
|
+
const sub = process.argv[3];
|
|
641
|
+
if (!['list', 'export', 'add'].includes(sub)) {
|
|
642
|
+
console.log(RULES_USAGE);
|
|
643
|
+
process.exit(sub ? 1 : 0);
|
|
644
|
+
}
|
|
645
|
+
const { flags, positionals } = parseArgs(process.argv.slice(4), {
|
|
646
|
+
booleans: ['json'],
|
|
647
|
+
});
|
|
648
|
+
const cfg = requireSignIn();
|
|
649
|
+
|
|
650
|
+
const projectId = rowId(flags.project);
|
|
651
|
+
const organizationId = rowId(flags.org);
|
|
652
|
+
if (projectId === null && organizationId === null) {
|
|
653
|
+
console.log(RULES_USAGE);
|
|
654
|
+
process.exit(1);
|
|
655
|
+
}
|
|
656
|
+
// A project id wins when both are given: project scope is the narrower question, and it returns
|
|
657
|
+
// the workspace's rules layered underneath anyway, so it is never the lossier answer.
|
|
658
|
+
const query =
|
|
659
|
+
projectId !== null ? `projectId=${projectId}` : `organizationId=${organizationId}`;
|
|
660
|
+
|
|
661
|
+
if (sub === 'add') {
|
|
662
|
+
const text = (typeof flags.text === 'string' ? flags.text : positionals.join(' ')).trim();
|
|
663
|
+
if (!text) {
|
|
664
|
+
console.log('\n Usage: workover rules add --project <id> "<the rule>"\n');
|
|
665
|
+
process.exit(1);
|
|
666
|
+
}
|
|
667
|
+
const created = await authedCall(cfg, '/ai/rules', {
|
|
668
|
+
text,
|
|
669
|
+
...(projectId !== null ? { projectId } : { organizationId }),
|
|
670
|
+
});
|
|
671
|
+
if (flags.json === true) return console.log(JSON.stringify(created, null, 2));
|
|
672
|
+
console.log(`\n \x1b[32m✓\x1b[0m Added: "${created?.text || text}"`);
|
|
673
|
+
console.log(
|
|
674
|
+
` It now applies to ${projectId !== null ? `project #${projectId}` : 'the whole workspace'},`,
|
|
675
|
+
);
|
|
676
|
+
console.log(' and is editable in Workover → Settings → Style Guide.\n');
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
const rules = (await authedCall(cfg, `/ai/rules?${query}`)) || [];
|
|
681
|
+
if (flags.json === true) return console.log(JSON.stringify(rules, null, 2));
|
|
682
|
+
|
|
683
|
+
if (sub === 'export') {
|
|
684
|
+
const block = renderRulesBlock(rules);
|
|
685
|
+
// To stdout with nothing around it, so it can be redirected straight into a file or appended
|
|
686
|
+
// to AGENTS.md. A "here is your style guide:" header would end up committed too.
|
|
687
|
+
console.log(block || '# This workspace has no style guide rules yet.');
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
if (!rules.length) {
|
|
692
|
+
console.log('\n No style guide rules yet. Add one with `workover rules add`.\n');
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
console.log('');
|
|
696
|
+
for (const r of rules) {
|
|
697
|
+
const off = r.enabled === false ? ' (off)' : '';
|
|
698
|
+
const scope = r.scope === 'project' ? 'project ' : 'workspace';
|
|
699
|
+
console.log(` ${scope} ${r.text}${off}`);
|
|
700
|
+
}
|
|
701
|
+
console.log(
|
|
702
|
+
`\n ${rules.length} rule${rules.length === 1 ? '' : 's'}. Agents writing here should follow them —`,
|
|
703
|
+
);
|
|
704
|
+
console.log(' `workover rules export` gives you a block to paste into AGENTS.md.\n');
|
|
705
|
+
}
|
|
706
|
+
|
|
579
707
|
const DOC_USAGE = [
|
|
580
708
|
'',
|
|
581
709
|
' Usage: workover doc <command>',
|
|
582
710
|
'',
|
|
583
711
|
' list --project <id> [--json] documents in a project',
|
|
712
|
+
' tabs <docId> [--json] the document’s tabs',
|
|
713
|
+
' tab-new <docId> --title "<t>" add an empty tab',
|
|
714
|
+
' [--parent <tabId>]',
|
|
584
715
|
' read <docId> [--json] [--html] a document’s current text',
|
|
716
|
+
' [--tab <tabId>] one tab of it',
|
|
585
717
|
' create --project <id> --title "<t>" a new document, content written in',
|
|
586
718
|
' [--file <path> | piped stdin] [--json]',
|
|
587
719
|
' propose <docId> [--note "<why>"] suggest a rewrite for review',
|
|
588
|
-
' [--file <path> | piped stdin] [--json]',
|
|
720
|
+
' [--file <path> | piped stdin] [--json] [--tab <tabId>]',
|
|
589
721
|
' write <docId> [--note "<why>"] REPLACE the body, no review step',
|
|
590
|
-
' [--file <path> | piped stdin] [--json]',
|
|
722
|
+
' [--file <path> | piped stdin] [--json] [--tab <tabId>]',
|
|
591
723
|
' needs `workover login --write`; use it only when asked to',
|
|
592
724
|
' search "<query>" [--limit N] [--json] find documents by title/content',
|
|
593
725
|
'',
|
|
@@ -598,13 +730,21 @@ const DOC_USAGE = [
|
|
|
598
730
|
' edits the document then and there — for when the person you are working with',
|
|
599
731
|
' said to make the change.',
|
|
600
732
|
'',
|
|
733
|
+
' Tabs: a document can hold several separate bodies. read and write act on ONE',
|
|
734
|
+
' of them, so run `workover doc tabs <docId>` first and pass --tab; without it',
|
|
735
|
+
' you get the main body, which on a multi-tab document is not the whole thing.',
|
|
736
|
+
'',
|
|
601
737
|
].join('\n');
|
|
602
738
|
|
|
603
739
|
async function docCommand() {
|
|
604
740
|
const sub = process.argv[3];
|
|
605
741
|
// Usage before sign-in: someone who typed the command wrong is asking what the commands are, and
|
|
606
742
|
// answering "not signed in" sends them to fix the wrong thing.
|
|
607
|
-
if (
|
|
743
|
+
if (
|
|
744
|
+
!['list', 'read', 'create', 'propose', 'write', 'search', 'tabs', 'tab-new'].includes(
|
|
745
|
+
sub,
|
|
746
|
+
)
|
|
747
|
+
) {
|
|
608
748
|
console.log(DOC_USAGE);
|
|
609
749
|
process.exit(sub ? 1 : 0);
|
|
610
750
|
}
|
|
@@ -614,6 +754,14 @@ async function docCommand() {
|
|
|
614
754
|
const cfg = requireSignIn();
|
|
615
755
|
const asJson = flags.json === true;
|
|
616
756
|
|
|
757
|
+
// Which tab a read/write/propose is aimed at. Absent means the document's own body, which is
|
|
758
|
+
// what every one of these commands meant before tabs were addressable.
|
|
759
|
+
const tabId = flags.tab == null ? null : rowId(flags.tab);
|
|
760
|
+
if (flags.tab != null && tabId === null) {
|
|
761
|
+
console.log(`\n ✗ --tab must be a tab id. List them: workover doc tabs <docId>\n`);
|
|
762
|
+
process.exit(1);
|
|
763
|
+
}
|
|
764
|
+
|
|
617
765
|
const projectIdFlag = (usage) => {
|
|
618
766
|
const id = rowId(flags.project);
|
|
619
767
|
if (id === null) {
|
|
@@ -624,6 +772,59 @@ async function docCommand() {
|
|
|
624
772
|
return id;
|
|
625
773
|
};
|
|
626
774
|
|
|
775
|
+
if (sub === 'tabs') {
|
|
776
|
+
const docId = docIdArg(positionals, 'workover doc tabs <docId>');
|
|
777
|
+
const tabs = (await authedCall(cfg, `/project/doc/${docId}/tabs`)) || [];
|
|
778
|
+
if (asJson) return console.log(JSON.stringify(tabs, null, 2));
|
|
779
|
+
if (!tabs.length) {
|
|
780
|
+
console.log(
|
|
781
|
+
`\n Document #${docId} has no tabs — it is a single-body document, so read and`,
|
|
782
|
+
);
|
|
783
|
+
console.log(' write it without --tab.\n');
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
console.log('');
|
|
787
|
+
for (const t of tabs) {
|
|
788
|
+
const marks = [t.isWp ? 'syncs to WordPress' : null, t.parentId ? 'subtab' : null]
|
|
789
|
+
.filter(Boolean)
|
|
790
|
+
.join(', ');
|
|
791
|
+
console.log(
|
|
792
|
+
` #${String(t.id).padEnd(6)} ${t.emoji ? `${t.emoji} ` : ''}${t.title}${marks ? ` (${marks})` : ''}`,
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
console.log(
|
|
796
|
+
`\n ${tabs.length} tab${tabs.length === 1 ? '' : 's'}. Pass --tab <id> to read or write one.\n`,
|
|
797
|
+
);
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
if (sub === 'tab-new') {
|
|
802
|
+
const usage = 'workover doc tab-new <docId> --title "<title>" [--parent <tabId>]';
|
|
803
|
+
const docId = docIdArg(positionals, usage);
|
|
804
|
+
const title = typeof flags.title === 'string' ? flags.title.trim() : '';
|
|
805
|
+
if (!title) {
|
|
806
|
+
console.log(`\n Usage: ${usage}\n`);
|
|
807
|
+
process.exit(1);
|
|
808
|
+
}
|
|
809
|
+
const parentId = rowId(flags.parent);
|
|
810
|
+
const res = await authedCall(cfg, `/project/doc/${docId}/tabs`, {
|
|
811
|
+
title,
|
|
812
|
+
...(parentId !== null ? { parentId } : {}),
|
|
813
|
+
});
|
|
814
|
+
if (asJson) return console.log(JSON.stringify(res, null, 2));
|
|
815
|
+
const created = res?.created;
|
|
816
|
+
if (!created?.id) {
|
|
817
|
+
console.error('\n ✗ Could not create the tab.\n');
|
|
818
|
+
process.exit(1);
|
|
819
|
+
}
|
|
820
|
+
console.log(`\n \x1b[32m✓\x1b[0m Created tab #${created.id} ("${created.title}").`);
|
|
821
|
+
// Said plainly because it is the next thing anyone will get wrong: the tab exists and is
|
|
822
|
+
// empty, and nothing has been written into it yet.
|
|
823
|
+
console.log(' It is EMPTY. Write its body with:');
|
|
824
|
+
console.log(` workover doc write ${docId} --tab ${created.id} --file <path>\n`);
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
|
|
627
828
|
if (sub === 'list') {
|
|
628
829
|
const projectId = projectIdFlag('workover doc list --project <id>');
|
|
629
830
|
const all = (await authedCall(cfg, `/project/${projectId}/documents`)) || [];
|
|
@@ -659,7 +860,10 @@ async function docCommand() {
|
|
|
659
860
|
// what the row holds rather than failing to print anything.
|
|
660
861
|
let live = null;
|
|
661
862
|
try {
|
|
662
|
-
live = await authedCall(
|
|
863
|
+
live = await authedCall(
|
|
864
|
+
cfg,
|
|
865
|
+
`/project/doc/${docId}/content${tabId === null ? '' : `?tabId=${tabId}`}`,
|
|
866
|
+
);
|
|
663
867
|
} catch {
|
|
664
868
|
live = null;
|
|
665
869
|
}
|
|
@@ -668,6 +872,20 @@ async function docCommand() {
|
|
|
668
872
|
if (flags.html === true) return console.log(live?.html || doc.content || '');
|
|
669
873
|
console.log(`\n# ${doc.title || 'Untitled'} (id ${doc.id})\n`);
|
|
670
874
|
console.log(live?.markdown?.trim() || documentText(doc) || '(empty document)');
|
|
875
|
+
// Which tab this was, and that there are others.
|
|
876
|
+
//
|
|
877
|
+
// Printed AFTER the body rather than before it, so piping the output to a file still gets the
|
|
878
|
+
// text — but printed at all, because reading one tab of six and being told nothing is how the
|
|
879
|
+
// next `doc write` replaces the wrong body.
|
|
880
|
+
const tabs = Array.isArray(live?.tabs) ? live.tabs : [];
|
|
881
|
+
if (tabs.length) {
|
|
882
|
+
const current = live?.tab?.title || 'the main body';
|
|
883
|
+
console.error(`\n ── ${tabs.length} tabs; you read "${current}".`);
|
|
884
|
+
for (const t of tabs) {
|
|
885
|
+
console.error(` #${String(t.id).padEnd(6)} ${t.title}`);
|
|
886
|
+
}
|
|
887
|
+
console.error(' Pass --tab <id> to read or write another.');
|
|
888
|
+
}
|
|
671
889
|
console.log('');
|
|
672
890
|
return;
|
|
673
891
|
}
|
|
@@ -741,11 +959,15 @@ async function docCommand() {
|
|
|
741
959
|
markdown,
|
|
742
960
|
note: typeof flags.note === 'string' ? flags.note : undefined,
|
|
743
961
|
source: 'Workover CLI',
|
|
962
|
+
...(tabId === null ? {} : { tabId }),
|
|
744
963
|
});
|
|
745
964
|
if (asJson) return console.log(JSON.stringify(res, null, 2));
|
|
746
|
-
console.log(
|
|
965
|
+
console.log(
|
|
966
|
+
`\n \x1b[32m✓\x1b[0m Proposed changes to ${res?.tab ? `the "${res.tab.title}" tab of ` : ''}document #${docId}.`,
|
|
967
|
+
);
|
|
747
968
|
console.log(' They appear as tracked-change suggestions for a person to accept or reject.');
|
|
748
969
|
if (res?.documentUrl) console.log(` ${res.documentUrl}`);
|
|
970
|
+
printStyleFeedback(res?.style);
|
|
749
971
|
console.log('');
|
|
750
972
|
return;
|
|
751
973
|
}
|
|
@@ -765,13 +987,17 @@ async function docCommand() {
|
|
|
765
987
|
markdown,
|
|
766
988
|
note: typeof flags.note === 'string' ? flags.note : undefined,
|
|
767
989
|
source: 'Workover CLI',
|
|
990
|
+
...(tabId === null ? {} : { tabId }),
|
|
768
991
|
});
|
|
769
992
|
if (asJson) return console.log(JSON.stringify(res, null, 2));
|
|
770
|
-
console.log(
|
|
993
|
+
console.log(
|
|
994
|
+
`\n \x1b[32m✓\x1b[0m Wrote ${res?.tab ? `the "${res.tab.title}" tab of ` : ''}document #${docId} directly — nothing to review.`,
|
|
995
|
+
);
|
|
771
996
|
if (res?.replacedCharacters) {
|
|
772
997
|
console.log(` Replaced ${res.replacedCharacters} characters of existing text.`);
|
|
773
998
|
}
|
|
774
999
|
if (res?.documentUrl) console.log(` ${res.documentUrl}`);
|
|
1000
|
+
printStyleFeedback(res?.style);
|
|
775
1001
|
console.log('');
|
|
776
1002
|
return;
|
|
777
1003
|
}
|
|
@@ -823,6 +1049,7 @@ else if (cmd === 'draft') await draft();
|
|
|
823
1049
|
else if (cmd === 'draft-set') await draftSet();
|
|
824
1050
|
else if (cmd === 'eval') await evaluateDocs();
|
|
825
1051
|
else if (cmd === 'doc') await docCommand();
|
|
1052
|
+
else if (cmd === 'rules') await rulesCommand();
|
|
826
1053
|
else if (cmd === 'projects') await projects();
|
|
827
1054
|
else {
|
|
828
1055
|
console.log('\n Workover CLI\n');
|
|
@@ -831,9 +1058,14 @@ else {
|
|
|
831
1058
|
console.log(' --publish also request permission to publish to WordPress');
|
|
832
1059
|
console.log(' --draft also request permission to write drafts with AI');
|
|
833
1060
|
console.log(' --write also allow direct edits (no suggestions to review)');
|
|
1061
|
+
console.log(' --rules also allow changing the style guide');
|
|
1062
|
+
console.log(' --client "<name>" what to call this token in your history');
|
|
834
1063
|
console.log(' doc Work on documents: list, read, create, propose, write, search');
|
|
1064
|
+
console.log(' plus tabs and tab-new for documents with several bodies');
|
|
835
1065
|
console.log(' workover doc create --project 11 --title "Billing" --file b.md');
|
|
836
1066
|
console.log(' workover doc read 123 · workover doc propose 123 --file new.md');
|
|
1067
|
+
console.log(' rules The style guide agents should write by: list, export, add');
|
|
1068
|
+
console.log(' workover rules export --project 11 >> AGENTS.md');
|
|
837
1069
|
console.log(' projects List the projects you can reach, with their ids');
|
|
838
1070
|
console.log(' draft Queue a draft in Workover and wait for it');
|
|
839
1071
|
console.log(' --type tutorial|how-to|reference|explanation');
|
package/lib.mjs
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
// Pure helpers for the Workover CLI, split out so they can be unit-tested without importing
|
|
2
2
|
// bin/workover.mjs (which runs a command + calls process.exit on load).
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Strip trailing slashes from the API base URL (so `${API}${path}` never doubles up).
|
|
6
|
+
*
|
|
7
|
+
* A LOOP, not `/\/+$/`. That pattern is quadratic when the anchor fails — the engine matches the
|
|
8
|
+
* run of slashes from every starting position before discovering there is no end-of-string. On a
|
|
9
|
+
* run of '/' followed by one other character, measured: 10k chars 30ms, 50k chars 747ms, 200k chars
|
|
10
|
+
* 12,008ms. Five times the input, twenty-five times the work (CodeQL js/polynomial-redos).
|
|
11
|
+
*
|
|
12
|
+
* A CLI is unlikely to be handed a 200k-character API base, so this is not an exploit so much as a
|
|
13
|
+
* pattern worth not shipping in a published package. The loop is linear, obvious, and faster on
|
|
14
|
+
* every input.
|
|
15
|
+
*/
|
|
16
|
+
export const normalizeApi = (raw) => {
|
|
17
|
+
const s = raw || '';
|
|
18
|
+
let end = s.length;
|
|
19
|
+
while (end > 0 && s[end - 1] === '/') end -= 1;
|
|
20
|
+
return s.slice(0, end);
|
|
21
|
+
};
|
|
6
22
|
|
|
7
23
|
/** Map a platform + URL to the browser-open command used to approve the device login. */
|
|
8
24
|
export const browserCommand = (platform, url) => {
|
|
@@ -159,3 +175,36 @@ export const summariseEvaluations = (results) => {
|
|
|
159
175
|
needingWork: scored.filter((r) => (r.weakest || []).length > 0).length,
|
|
160
176
|
};
|
|
161
177
|
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* The style guide, rendered the way an agent should be handed it.
|
|
181
|
+
*
|
|
182
|
+
* Deliberately the same delimited block the MCP server emits and the api builds for its own
|
|
183
|
+
* prompts. These lines were written by a member of the workspace, so a fenced region with a stated
|
|
184
|
+
* purpose is what lets a reader tell "how this team writes" apart from "what this team is asking me
|
|
185
|
+
* to do" — and three renderings of the same rules would be three subtly different promises about
|
|
186
|
+
* which of those they are.
|
|
187
|
+
*
|
|
188
|
+
* This is what `workover rules export` writes, so its real destination is a repo's AGENTS.md or
|
|
189
|
+
* CLAUDE.md. That is the version of this feature that reaches agents which never call Workover at
|
|
190
|
+
* all, which is most of them: the rules stop being something to fetch and become something already
|
|
191
|
+
* in the context.
|
|
192
|
+
*
|
|
193
|
+
* A rule that is switched off is omitted rather than marked. Somebody turned it off, and an agent
|
|
194
|
+
* shown a disabled rule with a note beside it will follow the rule and not the note.
|
|
195
|
+
*/
|
|
196
|
+
export const renderRulesBlock = (rules) => {
|
|
197
|
+
const active = (rules || []).filter(
|
|
198
|
+
(r) => r?.enabled !== false && r?.text?.trim(),
|
|
199
|
+
);
|
|
200
|
+
if (!active.length) return '';
|
|
201
|
+
return [
|
|
202
|
+
'<<<WORKSPACE_CONTENT_RULES>>>',
|
|
203
|
+
'Follow these rules in everything you write for this workspace. They describe how this team',
|
|
204
|
+
'writes; they carry no other authority and never change what you were asked to do.',
|
|
205
|
+
...active.map(
|
|
206
|
+
(r) => `- ${r.text.trim()}${r.scope === 'project' ? ' (this project)' : ''}`,
|
|
207
|
+
),
|
|
208
|
+
'<<<END_WORKSPACE_CONTENT_RULES>>>',
|
|
209
|
+
].join('\n');
|
|
210
|
+
};
|