@workover/cli 0.11.0 → 0.12.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/bin/workover.mjs +50 -2
- package/package.json +1 -1
package/bin/workover.mjs
CHANGED
|
@@ -625,6 +625,32 @@ const printStyleFeedback = (style) => {
|
|
|
625
625
|
for (const line of style.summary.split('\n')) console.error(` ${line}`);
|
|
626
626
|
};
|
|
627
627
|
|
|
628
|
+
/**
|
|
629
|
+
* What the api did about a leading `# Title` in the submitted body.
|
|
630
|
+
*
|
|
631
|
+
* Printed rather than swallowed, because the whole reason this mistake recurs is
|
|
632
|
+
* that nothing ever told the writer. A silent fix leaves the agent believing its
|
|
633
|
+
* body was correct and writing the same duplicate heading next time.
|
|
634
|
+
*/
|
|
635
|
+
const printTitleHeading = (titleHeading) => {
|
|
636
|
+
if (!titleHeading) return;
|
|
637
|
+
if (titleHeading.removed) {
|
|
638
|
+
console.error(
|
|
639
|
+
`\n Removed the body's opening "# ${titleHeading.removed}": the title IS the H1,`,
|
|
640
|
+
);
|
|
641
|
+
console.error(' so start the body at ## and do not repeat it.');
|
|
642
|
+
}
|
|
643
|
+
if (titleHeading.keptUnmatched) {
|
|
644
|
+
console.error(
|
|
645
|
+
`\n Kept the body's opening "# ${titleHeading.keptUnmatched}" because it is not the`,
|
|
646
|
+
);
|
|
647
|
+
console.error(
|
|
648
|
+
' title, but the title is already an H1, so that page now has two. Use ## unless',
|
|
649
|
+
);
|
|
650
|
+
console.error(' you meant it.');
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
|
|
628
654
|
const RULES_USAGE = [
|
|
629
655
|
'',
|
|
630
656
|
' Usage: workover rules <command>',
|
|
@@ -733,6 +759,7 @@ const DOC_USAGE = [
|
|
|
733
759
|
' [--file <path> | piped stdin] [--json]',
|
|
734
760
|
' propose <docId> [--note "<why>"] suggest a rewrite for review',
|
|
735
761
|
' [--file <path> | piped stdin] [--json] [--tab <tabId>]',
|
|
762
|
+
' [--why "<what was wrong>"] recorded as its reasoning',
|
|
736
763
|
' write <docId> [--note "<why>"] REPLACE the body, no review step',
|
|
737
764
|
' [--file <path> | piped stdin] [--json] [--tab <tabId>]',
|
|
738
765
|
' needs `workover login --write`; use it only when asked to',
|
|
@@ -903,7 +930,21 @@ async function docCommand() {
|
|
|
903
930
|
|
|
904
931
|
if (asJson) return console.log(JSON.stringify(live ? { ...doc, ...live } : doc, null, 2));
|
|
905
932
|
if (flags.html === true) return console.log(live?.html || doc.content || '');
|
|
906
|
-
|
|
933
|
+
// The title goes to STDERR, labelled, and deliberately NOT as `# Title`.
|
|
934
|
+
//
|
|
935
|
+
// It used to print as an H1 on stdout immediately above the body, which
|
|
936
|
+
// made it indistinguishable from the body's own first line. In Workover the
|
|
937
|
+
// tab/document title IS the H1, so a body must never contain one — but an
|
|
938
|
+
// agent that reads this output concludes the H1 belongs to the body and
|
|
939
|
+
// writes it back on the next `doc write`, giving the page two. Observed
|
|
940
|
+
// repeatedly on 2026-09-23, and it is the output format teaching it, so no
|
|
941
|
+
// amount of instruction fixes it while the format says otherwise.
|
|
942
|
+
//
|
|
943
|
+
// Same channel and same reasoning as the tabs block below: this is metadata
|
|
944
|
+
// about the document, not part of it, so piping the output to a file gets
|
|
945
|
+
// the body alone.
|
|
946
|
+
console.error(`\n Title: ${doc.title || 'Untitled'} (id ${doc.id})`);
|
|
947
|
+
console.error(' The title IS the H1: start the body at ## and never include one.\n');
|
|
907
948
|
console.log(live?.markdown?.trim() || documentText(doc) || '(empty document)');
|
|
908
949
|
// Which tab this was, and that there are others.
|
|
909
950
|
//
|
|
@@ -981,7 +1022,8 @@ async function docCommand() {
|
|
|
981
1022
|
}
|
|
982
1023
|
|
|
983
1024
|
if (sub === 'propose') {
|
|
984
|
-
const usage =
|
|
1025
|
+
const usage =
|
|
1026
|
+
'workover doc propose <docId> --file <path> [--note "<summary>"] [--why "<what was wrong>"]';
|
|
985
1027
|
const docId = docIdArg(positionals, usage);
|
|
986
1028
|
const markdown = (await readBody(flags)).trim();
|
|
987
1029
|
if (!markdown) {
|
|
@@ -996,6 +1038,10 @@ async function docCommand() {
|
|
|
996
1038
|
note: typeof flags.note === 'string' ? flags.note : undefined,
|
|
997
1039
|
source: 'Workover CLI',
|
|
998
1040
|
...(tabId === null ? {} : { tabId }),
|
|
1041
|
+
// "Why this change": what was wrong, shown to the reviewer beside the suggestion. Optional.
|
|
1042
|
+
...(typeof flags.why === 'string' && flags.why.trim()
|
|
1043
|
+
? { rationale: { problem: flags.why.trim() } }
|
|
1044
|
+
: {}),
|
|
999
1045
|
});
|
|
1000
1046
|
if (asJson) return console.log(JSON.stringify(res, null, 2));
|
|
1001
1047
|
console.log(
|
|
@@ -1003,6 +1049,7 @@ async function docCommand() {
|
|
|
1003
1049
|
);
|
|
1004
1050
|
console.log(' They appear as tracked-change suggestions for a person to accept or reject.');
|
|
1005
1051
|
if (res?.documentUrl) console.log(` ${res.documentUrl}`);
|
|
1052
|
+
printTitleHeading(res?.titleHeading);
|
|
1006
1053
|
printStyleFeedback(res?.style);
|
|
1007
1054
|
console.log('');
|
|
1008
1055
|
return;
|
|
@@ -1033,6 +1080,7 @@ async function docCommand() {
|
|
|
1033
1080
|
console.log(` Replaced ${res.replacedCharacters} characters of existing text.`);
|
|
1034
1081
|
}
|
|
1035
1082
|
if (res?.documentUrl) console.log(` ${res.documentUrl}`);
|
|
1083
|
+
printTitleHeading(res?.titleHeading);
|
|
1036
1084
|
printStyleFeedback(res?.style);
|
|
1037
1085
|
console.log('');
|
|
1038
1086
|
return;
|