mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
d2974a9ff6
* refactor(adapters): convert adapter layer from TypeScript to JavaScript Core framework stays TypeScript; adapter layer moves to JS-first. Adapters are essentially "executable config + browser scripts" that barely use TS features — this simplifies the build/distribution pipeline by removing the dist/clis/ intermediate compilation step. Changes: - Convert all 753 adapter files in clis/ from .ts to .js - Update tsconfig to exclude clis/ from compilation - Simplify build-manifest to scan clis/*.js directly (no dist/clis/) - Update discovery, main, fetch-adapters to load JS adapters from clis/ - Update generate-verified to output .js artifacts - Update package.json files field: dist/clis/ → clis/ - Fix all test files for the .ts → .js transition * fix(main): use findPackageRoot for BUILTIN_CLIS path The previous relative path (../../clis from __dirname) only worked for dist/src/main.js but broke dev mode (tsx src/main.ts) where __dirname is <repo>/src — resolving to /clis instead of <repo>/clis. Use findPackageRoot() which works for both dev and prod paths.
53 lines
2.5 KiB
JavaScript
53 lines
2.5 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',
|
|
description: 'Submit feedback for a paperreview.ai review token',
|
|
domain: PAPERREVIEW_DOMAIN,
|
|
strategy: Strategy.PUBLIC,
|
|
browser: false,
|
|
timeoutSeconds: 30,
|
|
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' },
|
|
],
|
|
columns: ['status', 'token', 'helpfulness', 'critical_error', 'actionable_suggestions', 'message'],
|
|
func: async (_page, 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,
|
|
});
|
|
},
|
|
});
|