reviw 0.22.0 → 0.22.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/cli.cjs +55 -17
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Multiple files can be specified. Each file opens on a separate port.
|
|
9
9
|
* Click cells in the browser to add comments.
|
|
10
|
-
*
|
|
10
|
+
* Click "Submit & Exit" to send comments to the server.
|
|
11
11
|
* When all files are closed, outputs combined YAML to stdout and exits.
|
|
12
12
|
*/
|
|
13
13
|
|
|
@@ -1871,7 +1871,7 @@ function diffHtmlTemplate(diffData, history = []) {
|
|
|
1871
1871
|
<aside class="comment-list collapsed">
|
|
1872
1872
|
<h3>Comments</h3>
|
|
1873
1873
|
<ol id="comment-list"></ol>
|
|
1874
|
-
<p class="hint">Click "Submit & Exit" to finish review.</p>
|
|
1874
|
+
<p class="hint">Click "Submit & Exit" to finish review and output results.</p>
|
|
1875
1875
|
</aside>
|
|
1876
1876
|
|
|
1877
1877
|
<div class="modal-overlay" id="submit-modal">
|
|
@@ -4967,7 +4967,7 @@ function htmlTemplate(dataRows, cols, projectRoot, relativePath, mode, previewHt
|
|
|
4967
4967
|
<aside class="comment-list collapsed">
|
|
4968
4968
|
<h3>Comments</h3>
|
|
4969
4969
|
<ol id="comment-list"></ol>
|
|
4970
|
-
<p class="hint">
|
|
4970
|
+
<p class="hint">Click "Submit & Exit" to send comments and stop the server.</p>
|
|
4971
4971
|
</aside>
|
|
4972
4972
|
<div class="filter-menu" id="filter-menu">
|
|
4973
4973
|
<label class="menu-check"><input type="checkbox" id="freeze-col-check" /> Freeze up to this column</label>
|
|
@@ -9702,6 +9702,7 @@ function checkExistingServer(filePath) {
|
|
|
9702
9702
|
|
|
9703
9703
|
// --- History File Management ---
|
|
9704
9704
|
const HISTORY_DIR = path.join(os.homedir(), '.reviw', 'history');
|
|
9705
|
+
const OUTPUT_DIR = path.join(os.homedir(), '.reviw', 'outputs');
|
|
9705
9706
|
const HISTORY_MAX = 50;
|
|
9706
9707
|
|
|
9707
9708
|
function getHistoryFilePath(filePath) {
|
|
@@ -9720,6 +9721,16 @@ function ensureHistoryDir() {
|
|
|
9720
9721
|
}
|
|
9721
9722
|
}
|
|
9722
9723
|
|
|
9724
|
+
function ensureOutputDir() {
|
|
9725
|
+
try {
|
|
9726
|
+
if (!fs.existsSync(OUTPUT_DIR)) {
|
|
9727
|
+
fs.mkdirSync(OUTPUT_DIR, { recursive: true, mode: 0o700 });
|
|
9728
|
+
}
|
|
9729
|
+
} catch (err) {
|
|
9730
|
+
// Ignore errors
|
|
9731
|
+
}
|
|
9732
|
+
}
|
|
9733
|
+
|
|
9723
9734
|
function loadHistoryFromFile(filePath) {
|
|
9724
9735
|
try {
|
|
9725
9736
|
const historyPath = getHistoryFilePath(filePath);
|
|
@@ -9748,6 +9759,16 @@ function saveHistoryToFile(filePath, historyEntry) {
|
|
|
9748
9759
|
}
|
|
9749
9760
|
}
|
|
9750
9761
|
|
|
9762
|
+
function shouldSaveHistory(payload) {
|
|
9763
|
+
if (!payload || typeof payload !== "object") return false;
|
|
9764
|
+
if (Array.isArray(payload.comments) && payload.comments.length > 0) return true;
|
|
9765
|
+
if (typeof payload.summary === "string" && payload.summary.trim().length > 0) return true;
|
|
9766
|
+
if (Array.isArray(payload.reviwAnswers) && payload.reviwAnswers.length > 0) return true;
|
|
9767
|
+
if (Array.isArray(payload.summaryImages) && payload.summaryImages.length > 0) return true;
|
|
9768
|
+
if (Array.isArray(payload.prompts) && payload.prompts.length > 0) return true;
|
|
9769
|
+
return false;
|
|
9770
|
+
}
|
|
9771
|
+
|
|
9751
9772
|
// Try to activate an existing browser tab with the given URL (macOS only)
|
|
9752
9773
|
// Returns true if a tab was activated, false otherwise
|
|
9753
9774
|
function tryActivateExistingTab(url) {
|
|
@@ -9874,14 +9895,14 @@ function openBrowser(url, delay = 0) {
|
|
|
9874
9895
|
}
|
|
9875
9896
|
|
|
9876
9897
|
function outputAllResults() {
|
|
9877
|
-
|
|
9898
|
+
const outLines = ["/do"];
|
|
9878
9899
|
if (allResults.length === 1) {
|
|
9879
9900
|
const yamlOut = yaml.dump(allResults[0], { noRefs: true, lineWidth: 120 });
|
|
9880
|
-
|
|
9901
|
+
outLines.push(yamlOut.trim());
|
|
9881
9902
|
} else {
|
|
9882
9903
|
const combined = { files: allResults };
|
|
9883
9904
|
const yamlOut = yaml.dump(combined, { noRefs: true, lineWidth: 120 });
|
|
9884
|
-
|
|
9905
|
+
outLines.push(yamlOut.trim());
|
|
9885
9906
|
}
|
|
9886
9907
|
|
|
9887
9908
|
// Output answered questions if any
|
|
@@ -9892,10 +9913,27 @@ function outputAllResults() {
|
|
|
9892
9913
|
}
|
|
9893
9914
|
}
|
|
9894
9915
|
if (allAnswers.length > 0) {
|
|
9895
|
-
|
|
9916
|
+
outLines.push("");
|
|
9917
|
+
outLines.push("[REVIW_ANSWERS]");
|
|
9896
9918
|
const answersYaml = yaml.dump(allAnswers, { noRefs: true, lineWidth: 120 });
|
|
9897
|
-
|
|
9898
|
-
|
|
9919
|
+
outLines.push(answersYaml.trim());
|
|
9920
|
+
outLines.push("[/REVIW_ANSWERS]");
|
|
9921
|
+
}
|
|
9922
|
+
|
|
9923
|
+
const outputText = outLines.join("\n");
|
|
9924
|
+
console.log(outputText);
|
|
9925
|
+
|
|
9926
|
+
// Durable fallback: persist final output to file for recovery.
|
|
9927
|
+
try {
|
|
9928
|
+
ensureOutputDir();
|
|
9929
|
+
const latestPath = path.join(OUTPUT_DIR, "latest.yaml");
|
|
9930
|
+
fs.writeFileSync(latestPath, outputText + "\n", { mode: 0o600 });
|
|
9931
|
+
|
|
9932
|
+
const ts = new Date().toISOString().replace(/[:.]/g, "-");
|
|
9933
|
+
const archivePath = path.join(OUTPUT_DIR, `output-${ts}.yaml`);
|
|
9934
|
+
fs.writeFileSync(archivePath, outputText + "\n", { mode: 0o600 });
|
|
9935
|
+
} catch (err) {
|
|
9936
|
+
// Keep stdout behavior even if file backup fails.
|
|
9899
9937
|
}
|
|
9900
9938
|
}
|
|
9901
9939
|
|
|
@@ -10041,8 +10079,8 @@ function createFileServer(filePath, fileIndex = 0) {
|
|
|
10041
10079
|
if (payload) {
|
|
10042
10080
|
payload = processPayloadImages(payload, ctx.baseDir);
|
|
10043
10081
|
}
|
|
10044
|
-
// Save to file-based history
|
|
10045
|
-
if (
|
|
10082
|
+
// Save to file-based history when review includes any meaningful submission.
|
|
10083
|
+
if (shouldSaveHistory(payload)) {
|
|
10046
10084
|
saveHistoryToFile(ctx.filePath, payload);
|
|
10047
10085
|
}
|
|
10048
10086
|
res.writeHead(200, { "Content-Type": "text/plain" });
|
|
@@ -10397,9 +10435,9 @@ function createDiffServer(diffContent) {
|
|
|
10397
10435
|
if (payload) {
|
|
10398
10436
|
payload = processPayloadImages(payload, process.cwd());
|
|
10399
10437
|
}
|
|
10400
|
-
// Save to file-based history
|
|
10401
|
-
// For diff mode, use relativePath as identifier
|
|
10402
|
-
if (
|
|
10438
|
+
// Save to file-based history when review includes any meaningful submission.
|
|
10439
|
+
// For diff mode, use relativePath as identifier.
|
|
10440
|
+
if (shouldSaveHistory(payload)) {
|
|
10403
10441
|
const filePath = ctx.diffData?.relativePath || 'stdin-diff';
|
|
10404
10442
|
saveHistoryToFile(filePath, payload);
|
|
10405
10443
|
}
|
|
@@ -10516,7 +10554,7 @@ if (require.main === module) {
|
|
|
10516
10554
|
console.log("Starting diff viewer from stdin...");
|
|
10517
10555
|
serversRunning = 1;
|
|
10518
10556
|
await createDiffServer(stdinContent);
|
|
10519
|
-
console.log("
|
|
10557
|
+
console.log('Click "Submit & Exit" to finish.');
|
|
10520
10558
|
} else {
|
|
10521
10559
|
// Treat as plain text
|
|
10522
10560
|
console.log("Starting text viewer from stdin...");
|
|
@@ -10553,7 +10591,7 @@ if (require.main === module) {
|
|
|
10553
10591
|
for (let i = 0; i < filesToStart.length; i++) {
|
|
10554
10592
|
await createFileServer(filesToStart[i], i);
|
|
10555
10593
|
}
|
|
10556
|
-
console.log("
|
|
10594
|
+
console.log('Click "Submit & Exit" in each opened viewer to finish.');
|
|
10557
10595
|
} else {
|
|
10558
10596
|
// No files and no stdin: try auto git diff
|
|
10559
10597
|
console.log(`reviw v${VERSION}`);
|
|
@@ -10575,7 +10613,7 @@ if (require.main === module) {
|
|
|
10575
10613
|
console.log("Starting diff viewer...");
|
|
10576
10614
|
serversRunning = 1;
|
|
10577
10615
|
await createDiffServer(gitDiff);
|
|
10578
|
-
console.log("
|
|
10616
|
+
console.log('Click "Submit & Exit" to finish.');
|
|
10579
10617
|
} catch (err) {
|
|
10580
10618
|
console.error(err.message);
|
|
10581
10619
|
console.log("");
|