@workover/cli 0.10.0 → 0.11.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/bin/workover.mjs +65 -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>',
|
|
@@ -903,7 +929,21 @@ async function docCommand() {
|
|
|
903
929
|
|
|
904
930
|
if (asJson) return console.log(JSON.stringify(live ? { ...doc, ...live } : doc, null, 2));
|
|
905
931
|
if (flags.html === true) return console.log(live?.html || doc.content || '');
|
|
906
|
-
|
|
932
|
+
// The title goes to STDERR, labelled, and deliberately NOT as `# Title`.
|
|
933
|
+
//
|
|
934
|
+
// It used to print as an H1 on stdout immediately above the body, which
|
|
935
|
+
// made it indistinguishable from the body's own first line. In Workover the
|
|
936
|
+
// tab/document title IS the H1, so a body must never contain one — but an
|
|
937
|
+
// agent that reads this output concludes the H1 belongs to the body and
|
|
938
|
+
// writes it back on the next `doc write`, giving the page two. Observed
|
|
939
|
+
// repeatedly on 2026-09-23, and it is the output format teaching it, so no
|
|
940
|
+
// amount of instruction fixes it while the format says otherwise.
|
|
941
|
+
//
|
|
942
|
+
// Same channel and same reasoning as the tabs block below: this is metadata
|
|
943
|
+
// about the document, not part of it, so piping the output to a file gets
|
|
944
|
+
// the body alone.
|
|
945
|
+
console.error(`\n Title: ${doc.title || 'Untitled'} (id ${doc.id})`);
|
|
946
|
+
console.error(' The title IS the H1: start the body at ## and never include one.\n');
|
|
907
947
|
console.log(live?.markdown?.trim() || documentText(doc) || '(empty document)');
|
|
908
948
|
// Which tab this was, and that there are others.
|
|
909
949
|
//
|
|
@@ -1003,6 +1043,7 @@ async function docCommand() {
|
|
|
1003
1043
|
);
|
|
1004
1044
|
console.log(' They appear as tracked-change suggestions for a person to accept or reject.');
|
|
1005
1045
|
if (res?.documentUrl) console.log(` ${res.documentUrl}`);
|
|
1046
|
+
printTitleHeading(res?.titleHeading);
|
|
1006
1047
|
printStyleFeedback(res?.style);
|
|
1007
1048
|
console.log('');
|
|
1008
1049
|
return;
|
|
@@ -1033,6 +1074,7 @@ async function docCommand() {
|
|
|
1033
1074
|
console.log(` Replaced ${res.replacedCharacters} characters of existing text.`);
|
|
1034
1075
|
}
|
|
1035
1076
|
if (res?.documentUrl) console.log(` ${res.documentUrl}`);
|
|
1077
|
+
printTitleHeading(res?.titleHeading);
|
|
1036
1078
|
printStyleFeedback(res?.style);
|
|
1037
1079
|
console.log('');
|
|
1038
1080
|
return;
|
|
@@ -1088,7 +1130,28 @@ async function docCommand() {
|
|
|
1088
1130
|
// Nothing is passed in but the id: the corrections have to come from the source, not from us.
|
|
1089
1131
|
// The result is applied as suggestions (or written with --write), like `reshoot`.
|
|
1090
1132
|
const docId = docIdArg(positionals, 'workover doc verify <docId> [--write] [--note "<why>"]');
|
|
1091
|
-
|
|
1133
|
+
// Started in the background and polled: the check reads the repository for minutes, and a
|
|
1134
|
+
// single request is cut at 100 seconds by Cloudflare (a 524 whose answer never arrives).
|
|
1135
|
+
let state = await authedCall(cfg, `/ai/documents/${docId}/verify`, {
|
|
1136
|
+
background: true,
|
|
1137
|
+
});
|
|
1138
|
+
const started = Date.now();
|
|
1139
|
+
if (!asJson) process.stdout.write('\n Workover AI is reading the repository');
|
|
1140
|
+
while (state?.status === 'running' && Date.now() - started < 30 * 60 * 1000) {
|
|
1141
|
+
await new Promise((r) => setTimeout(r, 10_000));
|
|
1142
|
+
if (!asJson) process.stdout.write('.');
|
|
1143
|
+
state = await authedCall(cfg, `/ai/documents/${docId}/verify`);
|
|
1144
|
+
}
|
|
1145
|
+
if (!asJson) process.stdout.write('\n');
|
|
1146
|
+
if (state?.status === 'failed') {
|
|
1147
|
+
console.error(`\n \x1b[31m✗\x1b[0m ${state.error}\n`);
|
|
1148
|
+
process.exit(1);
|
|
1149
|
+
}
|
|
1150
|
+
if (state?.status !== 'done') {
|
|
1151
|
+
console.error('\n \x1b[31m✗\x1b[0m The check did not finish in 30 minutes.\n');
|
|
1152
|
+
process.exit(1);
|
|
1153
|
+
}
|
|
1154
|
+
const res = state.result;
|
|
1092
1155
|
const list = Array.isArray(res?.corrections) ? res.corrections : null;
|
|
1093
1156
|
if (asJson && !res?.changed) return console.log(JSON.stringify(res, null, 2));
|
|
1094
1157
|
if (!res?.changed) {
|