9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
54 lines
2.6 KiB
JavaScript
54 lines
2.6 KiB
JavaScript
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
import { CliError } from '@jackwener/opencli/errors';
|
|
import { PAPERREVIEW_DOMAIN, ensureSuccess, parseYesNo, requestJson, summarizeFeedback, validateHelpfulness, } from './utils.js';
|
|
cli({
|
|
site: 'paperreview',
|
|
name: 'feedback',
|
|
access: 'write',
|
|
description: 'Submit feedback for a paperreview.ai review token',
|
|
domain: PAPERREVIEW_DOMAIN,
|
|
strategy: Strategy.PUBLIC,
|
|
browser: false,
|
|
args: [
|
|
{ name: 'token', positional: true, required: true, help: 'Review token returned by paperreview.ai' },
|
|
{ name: 'helpfulness', required: true, type: 'int', help: 'Helpfulness score from 1 to 5' },
|
|
{ name: 'critical-error', required: true, choices: ['yes', 'no'], help: 'Whether the review contains a critical error' },
|
|
{ name: 'actionable-suggestions', required: true, choices: ['yes', 'no'], help: 'Whether the review contains actionable suggestions' },
|
|
{ name: 'additional-comments', help: 'Optional free-text feedback' },
|
|
{ name: 'timeout', type: 'int', required: false, default: 30, help: 'Max seconds for the overall command (default: 30)' },
|
|
],
|
|
columns: ['status', 'token', 'helpfulness', 'critical_error', 'actionable_suggestions', 'message'],
|
|
func: async (kwargs) => {
|
|
const token = String(kwargs.token ?? '').trim();
|
|
if (!token) {
|
|
throw new CliError('ARGUMENT', 'A review token is required.');
|
|
}
|
|
const helpfulness = validateHelpfulness(kwargs.helpfulness);
|
|
const criticalError = parseYesNo(kwargs['critical-error'], 'critical-error');
|
|
const actionableSuggestions = parseYesNo(kwargs['actionable-suggestions'], 'actionable-suggestions');
|
|
const comments = String(kwargs['additional-comments'] ?? '').trim();
|
|
const payload = {
|
|
helpfulness,
|
|
has_critical_error: criticalError,
|
|
has_actionable_suggestions: actionableSuggestions,
|
|
};
|
|
if (comments) {
|
|
payload.additional_comments = comments;
|
|
}
|
|
const { response, payload: responsePayload } = await requestJson(`/api/feedback/${encodeURIComponent(token)}`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(payload),
|
|
});
|
|
ensureSuccess(response, responsePayload, 'Failed to submit feedback.', 'Check the token and try again');
|
|
return summarizeFeedback({
|
|
token,
|
|
helpfulness,
|
|
criticalError,
|
|
actionableSuggestions,
|
|
comments,
|
|
payload: responsePayload,
|
|
});
|
|
},
|
|
});
|