refineo-cli 0.1.1 → 0.1.5

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/README.md CHANGED
@@ -49,6 +49,7 @@ refineo humanize "text" --model enhanced # Use enhanced model (default)
49
49
  refineo humanize "text" --model standard # Use standard model
50
50
  refineo humanize --file input.txt # Read from file
51
51
  refineo humanize --file input.txt --output output.txt # Write to file
52
+ refineo humanize "text" --verbose # Show debug output
52
53
  echo "text" | refineo humanize # Read from stdin
53
54
  ```
54
55
 
package/dist/cjs/api.js CHANGED
@@ -23,6 +23,7 @@ __export(api_exports, {
23
23
  getUsage: () => getUsage,
24
24
  humanize: () => humanize,
25
25
  pollForToken: () => pollForToken,
26
+ refreshToken: () => refreshToken,
26
27
  startDeviceCodeFlow: () => startDeviceCodeFlow
27
28
  });
28
29
  module.exports = __toCommonJS(api_exports);
@@ -74,9 +75,11 @@ function getPlatformInfo() {
74
75
 
75
76
  // src/api.ts
76
77
  var USER_AGENT = getPlatformInfo();
77
- var DEBUG = process.env.REFINEO_DEBUG === "1" || process.env.REFINEO_DEBUG === "true";
78
+ function isDebug() {
79
+ return process.env.REFINEO_DEBUG === "1" || process.env.REFINEO_DEBUG === "true";
80
+ }
78
81
  function debug(...args) {
79
- if (DEBUG) {
82
+ if (isDebug()) {
80
83
  console.error("[refineo-debug]", ...args);
81
84
  }
82
85
  }
@@ -121,7 +124,14 @@ async function apiRequest(path, options = {}) {
121
124
  } catch {
122
125
  error = { error: errorText || "Unknown error" };
123
126
  }
124
- throw new Error(error.message || error.error_description || error.error || `HTTP ${response.status}`);
127
+ let errorMessage = "";
128
+ if (Array.isArray(error.details) && error.details.length > 0) {
129
+ errorMessage = error.details.map((d) => d.message).filter(Boolean).join("; ");
130
+ }
131
+ if (!errorMessage) {
132
+ errorMessage = error.message || error.error_description || error.error || `HTTP ${response.status}`;
133
+ }
134
+ throw new Error(errorMessage);
125
135
  }
126
136
  return response.json();
127
137
  }
@@ -254,5 +264,6 @@ async function getUsage() {
254
264
  getUsage,
255
265
  humanize,
256
266
  pollForToken,
267
+ refreshToken,
257
268
  startDeviceCodeFlow
258
269
  });
package/dist/cjs/cli.js CHANGED
@@ -81,9 +81,11 @@ function getPlatformInfo() {
81
81
 
82
82
  // src/api.ts
83
83
  var USER_AGENT = getPlatformInfo();
84
- var DEBUG = process.env.REFINEO_DEBUG === "1" || process.env.REFINEO_DEBUG === "true";
84
+ function isDebug() {
85
+ return process.env.REFINEO_DEBUG === "1" || process.env.REFINEO_DEBUG === "true";
86
+ }
85
87
  function debug(...args) {
86
- if (DEBUG) {
88
+ if (isDebug()) {
87
89
  console.error("[refineo-debug]", ...args);
88
90
  }
89
91
  }
@@ -128,7 +130,14 @@ async function apiRequest(path, options = {}) {
128
130
  } catch {
129
131
  error = { error: errorText || "Unknown error" };
130
132
  }
131
- throw new Error(error.message || error.error_description || error.error || `HTTP ${response.status}`);
133
+ let errorMessage = "";
134
+ if (Array.isArray(error.details) && error.details.length > 0) {
135
+ errorMessage = error.details.map((d) => d.message).filter(Boolean).join("; ");
136
+ }
137
+ if (!errorMessage) {
138
+ errorMessage = error.message || error.error_description || error.error || `HTTP ${response.status}`;
139
+ }
140
+ throw new Error(errorMessage);
132
141
  }
133
142
  return response.json();
134
143
  }
@@ -258,7 +267,7 @@ async function getUsage() {
258
267
  }
259
268
 
260
269
  // src/cli.ts
261
- var VERSION = "0.1.0";
270
+ var VERSION = "0.1.5";
262
271
  var colors = {
263
272
  reset: "\x1B[0m",
264
273
  bold: "\x1B[1m",
@@ -297,14 +306,29 @@ async function openBrowser(url) {
297
306
  print(`Please open this URL in your browser: ${url}`);
298
307
  }
299
308
  }
300
- async function loginCommand() {
309
+ async function loginCommand(args = []) {
310
+ const force = args.includes("--force");
301
311
  const existing = loadCredentials();
302
- if (existing) {
303
- print(`Already logged in as ${colors.cyan}${existing.user.email}${colors.reset}`);
304
- print(`Tier: ${colors.bold}${existing.user.tier}${colors.reset}`);
305
- print(`
312
+ if (existing && !force) {
313
+ if (isTokenExpired(existing)) {
314
+ const refreshed = await refreshToken(existing.refreshToken);
315
+ if (refreshed) {
316
+ printSuccess(`Session refreshed for ${colors.cyan}${refreshed.user.email}${colors.reset}`);
317
+ print(`Tier: ${colors.bold}${refreshed.user.tier}${colors.reset}`);
318
+ return;
319
+ }
320
+ print(`Session expired, re-authenticating...`);
321
+ clearCredentials();
322
+ } else {
323
+ print(`Already logged in as ${colors.cyan}${existing.user.email}${colors.reset}`);
324
+ print(`Tier: ${colors.bold}${existing.user.tier}${colors.reset}`);
325
+ print(`
306
326
  Run ${colors.dim}refineo logout${colors.reset} to switch accounts.`);
307
- return;
327
+ return;
328
+ }
329
+ }
330
+ if (force && existing) {
331
+ clearCredentials();
308
332
  }
309
333
  print(`${colors.bold}Refineo CLI Login${colors.reset}
310
334
  `);
@@ -386,6 +410,7 @@ async function humanizeCommand(args) {
386
410
  let model = "enhanced";
387
411
  let inputFile = "";
388
412
  let outputFile = "";
413
+ let verbose = false;
389
414
  for (let i = 0; i < args.length; i++) {
390
415
  const arg = args[i];
391
416
  if (arg === "--model" || arg === "-m") {
@@ -400,10 +425,15 @@ async function humanizeCommand(args) {
400
425
  inputFile = args[++i];
401
426
  } else if (arg === "--output" || arg === "-o") {
402
427
  outputFile = args[++i];
428
+ } else if (arg === "--verbose" || arg === "-v") {
429
+ verbose = true;
403
430
  } else if (!arg.startsWith("-")) {
404
431
  text = arg;
405
432
  }
406
433
  }
434
+ if (verbose) {
435
+ process.env.REFINEO_DEBUG = "1";
436
+ }
407
437
  if (inputFile) {
408
438
  if (!(0, import_fs2.existsSync)(inputFile)) {
409
439
  printError(`File not found: ${inputFile}`);
@@ -454,10 +484,14 @@ ${colors.bold}Commands:${colors.reset}
454
484
  stats Show usage statistics
455
485
  humanize <text> Humanize AI-generated text
456
486
 
487
+ ${colors.bold}Login Options:${colors.reset}
488
+ --force Force re-authentication even if already logged in
489
+
457
490
  ${colors.bold}Humanize Options:${colors.reset}
458
491
  -m, --model <model> Model: "standard" or "enhanced" (default: enhanced)
459
492
  -f, --file <path> Read input from file
460
493
  -o, --output <path> Write output to file
494
+ -v, --verbose Show debug output
461
495
 
462
496
  ${colors.bold}Examples:${colors.reset}
463
497
  ${colors.dim}# Login to your account${colors.reset}
@@ -490,7 +524,7 @@ async function main() {
490
524
  const command = args[0];
491
525
  switch (command) {
492
526
  case "login":
493
- await loginCommand();
527
+ await loginCommand(args.slice(1));
494
528
  break;
495
529
  case "logout":
496
530
  logoutCommand();
package/dist/cjs/index.js CHANGED
@@ -28,6 +28,7 @@ __export(index_exports, {
28
28
  isTokenExpired: () => isTokenExpired,
29
29
  loadCredentials: () => loadCredentials,
30
30
  pollForToken: () => pollForToken,
31
+ refreshToken: () => refreshToken,
31
32
  saveCredentials: () => saveCredentials,
32
33
  startDeviceCodeFlow: () => startDeviceCodeFlow
33
34
  });
@@ -88,9 +89,11 @@ function getPlatformInfo() {
88
89
 
89
90
  // src/api.ts
90
91
  var USER_AGENT = getPlatformInfo();
91
- var DEBUG = process.env.REFINEO_DEBUG === "1" || process.env.REFINEO_DEBUG === "true";
92
+ function isDebug() {
93
+ return process.env.REFINEO_DEBUG === "1" || process.env.REFINEO_DEBUG === "true";
94
+ }
92
95
  function debug(...args) {
93
- if (DEBUG) {
96
+ if (isDebug()) {
94
97
  console.error("[refineo-debug]", ...args);
95
98
  }
96
99
  }
@@ -135,7 +138,14 @@ async function apiRequest(path, options = {}) {
135
138
  } catch {
136
139
  error = { error: errorText || "Unknown error" };
137
140
  }
138
- throw new Error(error.message || error.error_description || error.error || `HTTP ${response.status}`);
141
+ let errorMessage = "";
142
+ if (Array.isArray(error.details) && error.details.length > 0) {
143
+ errorMessage = error.details.map((d) => d.message).filter(Boolean).join("; ");
144
+ }
145
+ if (!errorMessage) {
146
+ errorMessage = error.message || error.error_description || error.error || `HTTP ${response.status}`;
147
+ }
148
+ throw new Error(errorMessage);
139
149
  }
140
150
  return response.json();
141
151
  }
@@ -273,6 +283,7 @@ async function getUsage() {
273
283
  isTokenExpired,
274
284
  loadCredentials,
275
285
  pollForToken,
286
+ refreshToken,
276
287
  saveCredentials,
277
288
  startDeviceCodeFlow
278
289
  });
package/dist/esm/api.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import type { Credentials, DeviceCodeResponse, HumanizeResult, UsageStats } from './types.js';
2
+ /**
3
+ * Refresh access token
4
+ */
5
+ export declare function refreshToken(refreshTokenValue: string): Promise<Credentials | null>;
2
6
  /**
3
7
  * Start device code flow
4
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAGlB,cAAc,EACd,UAAU,EACX,MAAM,YAAY,CAAC;AAuHpB;;GAEG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAcvE;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,IAAI,GAClB,OAAO,CAAC,WAAW,CAAC,CA8DtB;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,UAAU,GAAG,UAAuB,GAC1C,OAAO,CAAC,cAAc,CAAC,CAqBzB;AAED;;GAEG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,CAoBpD"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAGlB,cAAc,EACd,UAAU,EACX,MAAM,YAAY,CAAC;AAsFpB;;GAEG;AACH,wBAAsB,YAAY,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAwCzF;AAED;;GAEG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAcvE;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,IAAI,GAClB,OAAO,CAAC,WAAW,CAAC,CA8DtB;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,UAAU,GAAG,UAAuB,GAC1C,OAAO,CAAC,cAAc,CAAC,CAqBzB;AAED;;GAEG;AACH,wBAAsB,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,CAoBpD"}
package/dist/esm/api.js CHANGED
@@ -45,9 +45,11 @@ function getPlatformInfo() {
45
45
 
46
46
  // src/api.ts
47
47
  var USER_AGENT = getPlatformInfo();
48
- var DEBUG = process.env.REFINEO_DEBUG === "1" || process.env.REFINEO_DEBUG === "true";
48
+ function isDebug() {
49
+ return process.env.REFINEO_DEBUG === "1" || process.env.REFINEO_DEBUG === "true";
50
+ }
49
51
  function debug(...args) {
50
- if (DEBUG) {
52
+ if (isDebug()) {
51
53
  console.error("[refineo-debug]", ...args);
52
54
  }
53
55
  }
@@ -92,7 +94,14 @@ async function apiRequest(path, options = {}) {
92
94
  } catch {
93
95
  error = { error: errorText || "Unknown error" };
94
96
  }
95
- throw new Error(error.message || error.error_description || error.error || `HTTP ${response.status}`);
97
+ let errorMessage = "";
98
+ if (Array.isArray(error.details) && error.details.length > 0) {
99
+ errorMessage = error.details.map((d) => d.message).filter(Boolean).join("; ");
100
+ }
101
+ if (!errorMessage) {
102
+ errorMessage = error.message || error.error_description || error.error || `HTTP ${response.status}`;
103
+ }
104
+ throw new Error(errorMessage);
96
105
  }
97
106
  return response.json();
98
107
  }
@@ -224,5 +233,6 @@ export {
224
233
  getUsage,
225
234
  humanize,
226
235
  pollForToken,
236
+ refreshToken,
227
237
  startDeviceCodeFlow
228
238
  };
package/dist/esm/cli.js CHANGED
@@ -58,9 +58,11 @@ function getPlatformInfo() {
58
58
 
59
59
  // src/api.ts
60
60
  var USER_AGENT = getPlatformInfo();
61
- var DEBUG = process.env.REFINEO_DEBUG === "1" || process.env.REFINEO_DEBUG === "true";
61
+ function isDebug() {
62
+ return process.env.REFINEO_DEBUG === "1" || process.env.REFINEO_DEBUG === "true";
63
+ }
62
64
  function debug(...args) {
63
- if (DEBUG) {
65
+ if (isDebug()) {
64
66
  console.error("[refineo-debug]", ...args);
65
67
  }
66
68
  }
@@ -105,7 +107,14 @@ async function apiRequest(path, options = {}) {
105
107
  } catch {
106
108
  error = { error: errorText || "Unknown error" };
107
109
  }
108
- throw new Error(error.message || error.error_description || error.error || `HTTP ${response.status}`);
110
+ let errorMessage = "";
111
+ if (Array.isArray(error.details) && error.details.length > 0) {
112
+ errorMessage = error.details.map((d) => d.message).filter(Boolean).join("; ");
113
+ }
114
+ if (!errorMessage) {
115
+ errorMessage = error.message || error.error_description || error.error || `HTTP ${response.status}`;
116
+ }
117
+ throw new Error(errorMessage);
109
118
  }
110
119
  return response.json();
111
120
  }
@@ -235,7 +244,7 @@ async function getUsage() {
235
244
  }
236
245
 
237
246
  // src/cli.ts
238
- var VERSION = "0.1.0";
247
+ var VERSION = "0.1.5";
239
248
  var colors = {
240
249
  reset: "\x1B[0m",
241
250
  bold: "\x1B[1m",
@@ -274,14 +283,29 @@ async function openBrowser(url) {
274
283
  print(`Please open this URL in your browser: ${url}`);
275
284
  }
276
285
  }
277
- async function loginCommand() {
286
+ async function loginCommand(args = []) {
287
+ const force = args.includes("--force");
278
288
  const existing = loadCredentials();
279
- if (existing) {
280
- print(`Already logged in as ${colors.cyan}${existing.user.email}${colors.reset}`);
281
- print(`Tier: ${colors.bold}${existing.user.tier}${colors.reset}`);
282
- print(`
289
+ if (existing && !force) {
290
+ if (isTokenExpired(existing)) {
291
+ const refreshed = await refreshToken(existing.refreshToken);
292
+ if (refreshed) {
293
+ printSuccess(`Session refreshed for ${colors.cyan}${refreshed.user.email}${colors.reset}`);
294
+ print(`Tier: ${colors.bold}${refreshed.user.tier}${colors.reset}`);
295
+ return;
296
+ }
297
+ print(`Session expired, re-authenticating...`);
298
+ clearCredentials();
299
+ } else {
300
+ print(`Already logged in as ${colors.cyan}${existing.user.email}${colors.reset}`);
301
+ print(`Tier: ${colors.bold}${existing.user.tier}${colors.reset}`);
302
+ print(`
283
303
  Run ${colors.dim}refineo logout${colors.reset} to switch accounts.`);
284
- return;
304
+ return;
305
+ }
306
+ }
307
+ if (force && existing) {
308
+ clearCredentials();
285
309
  }
286
310
  print(`${colors.bold}Refineo CLI Login${colors.reset}
287
311
  `);
@@ -363,6 +387,7 @@ async function humanizeCommand(args) {
363
387
  let model = "enhanced";
364
388
  let inputFile = "";
365
389
  let outputFile = "";
390
+ let verbose = false;
366
391
  for (let i = 0; i < args.length; i++) {
367
392
  const arg = args[i];
368
393
  if (arg === "--model" || arg === "-m") {
@@ -377,10 +402,15 @@ async function humanizeCommand(args) {
377
402
  inputFile = args[++i];
378
403
  } else if (arg === "--output" || arg === "-o") {
379
404
  outputFile = args[++i];
405
+ } else if (arg === "--verbose" || arg === "-v") {
406
+ verbose = true;
380
407
  } else if (!arg.startsWith("-")) {
381
408
  text = arg;
382
409
  }
383
410
  }
411
+ if (verbose) {
412
+ process.env.REFINEO_DEBUG = "1";
413
+ }
384
414
  if (inputFile) {
385
415
  if (!existsSync2(inputFile)) {
386
416
  printError(`File not found: ${inputFile}`);
@@ -431,10 +461,14 @@ ${colors.bold}Commands:${colors.reset}
431
461
  stats Show usage statistics
432
462
  humanize <text> Humanize AI-generated text
433
463
 
464
+ ${colors.bold}Login Options:${colors.reset}
465
+ --force Force re-authentication even if already logged in
466
+
434
467
  ${colors.bold}Humanize Options:${colors.reset}
435
468
  -m, --model <model> Model: "standard" or "enhanced" (default: enhanced)
436
469
  -f, --file <path> Read input from file
437
470
  -o, --output <path> Write output to file
471
+ -v, --verbose Show debug output
438
472
 
439
473
  ${colors.bold}Examples:${colors.reset}
440
474
  ${colors.dim}# Login to your account${colors.reset}
@@ -467,7 +501,7 @@ async function main() {
467
501
  const command = args[0];
468
502
  switch (command) {
469
503
  case "login":
470
- await loginCommand();
504
+ await loginCommand(args.slice(1));
471
505
  break;
472
506
  case "logout":
473
507
  logoutCommand();
package/dist/esm/index.js CHANGED
@@ -53,9 +53,11 @@ function getPlatformInfo() {
53
53
 
54
54
  // src/api.ts
55
55
  var USER_AGENT = getPlatformInfo();
56
- var DEBUG = process.env.REFINEO_DEBUG === "1" || process.env.REFINEO_DEBUG === "true";
56
+ function isDebug() {
57
+ return process.env.REFINEO_DEBUG === "1" || process.env.REFINEO_DEBUG === "true";
58
+ }
57
59
  function debug(...args) {
58
- if (DEBUG) {
60
+ if (isDebug()) {
59
61
  console.error("[refineo-debug]", ...args);
60
62
  }
61
63
  }
@@ -100,7 +102,14 @@ async function apiRequest(path, options = {}) {
100
102
  } catch {
101
103
  error = { error: errorText || "Unknown error" };
102
104
  }
103
- throw new Error(error.message || error.error_description || error.error || `HTTP ${response.status}`);
105
+ let errorMessage = "";
106
+ if (Array.isArray(error.details) && error.details.length > 0) {
107
+ errorMessage = error.details.map((d) => d.message).filter(Boolean).join("; ");
108
+ }
109
+ if (!errorMessage) {
110
+ errorMessage = error.message || error.error_description || error.error || `HTTP ${response.status}`;
111
+ }
112
+ throw new Error(errorMessage);
104
113
  }
105
114
  return response.json();
106
115
  }
@@ -237,6 +246,7 @@ export {
237
246
  isTokenExpired,
238
247
  loadCredentials,
239
248
  pollForToken,
249
+ refreshToken,
240
250
  saveCredentials,
241
251
  startDeviceCodeFlow
242
252
  };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "refineo-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.5",
4
4
  "description": "Refineo AI Text Humanizer CLI - Transform AI-generated text into natural human writing",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
7
7
  "module": "./dist/esm/index.js",
8
8
  "types": "./dist/esm/index.d.ts",
9
9
  "bin": {
10
- "refineo": "./dist/esm/cli.js"
10
+ "refineo": "dist/esm/cli.js"
11
11
  },
12
12
  "exports": {
13
13
  ".": {
@@ -45,6 +45,10 @@
45
45
  "author": "Refineo",
46
46
  "license": "MIT",
47
47
  "homepage": "https://www.refineo.app",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "https://github.com/DADAExperiments/refineo-ai-tools.git"
51
+ },
48
52
  "engines": {
49
53
  "node": ">=18.0.0"
50
54
  },