@aaronjmars/openroutercli 0.1.2 → 0.1.3

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/SKILL.md CHANGED
@@ -318,7 +318,7 @@ openrouter --json keys get <hash> | jq '.data | {usage, usage_daily, limit_remai
318
318
  | --- | --- | --- |
319
319
  | `-k, --key` | `OPENROUTER_API_KEY` / `OPENROUTER_MANAGEMENT_KEY` | from config |
320
320
  | `--base-url` | `OPENROUTER_BASE_URL` | `https://openrouter.ai/api/v1` |
321
- | `--referer` | `OPENROUTER_REFERER` | `https://github.com/openrouter-cli` |
321
+ | `--referer` | `OPENROUTER_REFERER` | `https://github.com/aaronjmars/openroutercli` |
322
322
  | `--title` | `OPENROUTER_TITLE` | `openrouter-cli` |
323
323
  | `--json` | — | off |
324
324
  | `-q, --quiet` | — | off |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aaronjmars/openroutercli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Command-line interface for the OpenRouter API. Built for humans and LLM agents.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -14,8 +14,18 @@ import { requestCommand } from './commands/request.js';
14
14
  import { guardrailsCommand } from './commands/guardrails.js';
15
15
  import { workspacesCommand } from './commands/workspaces.js';
16
16
  import { orgCommand, zdrCommand, authCodeCommand } from './commands/misc.js';
17
-
18
- const VERSION = '0.1.0';
17
+ import { readFileSync } from 'node:fs';
18
+ import { fileURLToPath } from 'node:url';
19
+ import { dirname, join } from 'node:path';
20
+
21
+ const VERSION = (() => {
22
+ try {
23
+ const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
24
+ return JSON.parse(readFileSync(pkgPath, 'utf8')).version;
25
+ } catch {
26
+ return 'unknown';
27
+ }
28
+ })();
19
29
 
20
30
  const COMMANDS = {
21
31
  login: loginCommand,
@@ -17,9 +17,14 @@ Options:
17
17
  --no-stream Disable streaming
18
18
  --temperature <n>
19
19
  --top-p <n>
20
+ --top-k <n>
20
21
  --max-tokens <n>
21
22
  --seed <n>
22
23
  --stop <text> Stop sequence (repeatable via comma)
24
+ --frequency-penalty <n> -2.0 to 2.0
25
+ --presence-penalty <n> -2.0 to 2.0
26
+ --repetition-penalty <n> 0.0 to 2.0
27
+ --min-p <n> 0.0 to 1.0
23
28
  --json-output Ask the model for JSON (response_format=json_object)
24
29
  --schema <file|json> JSON schema for structured output
25
30
  --tool <file|json> Tool definition (repeatable). JSON object or @file.json
@@ -78,6 +83,21 @@ async function imageToContent(value) {
78
83
  };
79
84
  }
80
85
 
86
+ function applySamplingOptions(body, values) {
87
+ if (values.models) body.models = values.models.split(',').map((s) => s.trim());
88
+ if (values.temperature != null) body.temperature = Number(values.temperature);
89
+ if (values['top-p'] != null) body.top_p = Number(values['top-p']);
90
+ if (values['top-k'] != null) body.top_k = Number(values['top-k']);
91
+ if (values['max-tokens'] != null) body.max_tokens = Number(values['max-tokens']);
92
+ if (values.seed != null) body.seed = Number(values.seed);
93
+ if (values.stop) body.stop = values.stop.split(',');
94
+ if (values['frequency-penalty'] != null) body.frequency_penalty = Number(values['frequency-penalty']);
95
+ if (values['presence-penalty'] != null) body.presence_penalty = Number(values['presence-penalty']);
96
+ if (values['repetition-penalty'] != null) body.repetition_penalty = Number(values['repetition-penalty']);
97
+ if (values['min-p'] != null) body.min_p = Number(values['min-p']);
98
+ if (values.reasoning) body.reasoning = { effort: values.reasoning };
99
+ }
100
+
81
101
  async function buildBody(values, prompt) {
82
102
  const messages = [];
83
103
  if (values.system) messages.push({ role: 'system', content: values.system });
@@ -98,12 +118,7 @@ async function buildBody(values, prompt) {
98
118
  model: values.model || 'openrouter/auto',
99
119
  messages
100
120
  };
101
- if (values.models) body.models = values.models.split(',').map((s) => s.trim());
102
- if (values.temperature != null) body.temperature = Number(values.temperature);
103
- if (values['top-p'] != null) body.top_p = Number(values['top-p']);
104
- if (values['max-tokens'] != null) body.max_tokens = Number(values['max-tokens']);
105
- if (values.seed != null) body.seed = Number(values.seed);
106
- if (values.stop) body.stop = values.stop.split(',');
121
+ applySamplingOptions(body, values);
107
122
 
108
123
  if (values['json-output']) body.response_format = { type: 'json_object' };
109
124
  if (values.schema) {
@@ -127,7 +142,6 @@ async function buildBody(values, prompt) {
127
142
  if (['auto', 'none', 'required'].includes(v)) body.tool_choice = v;
128
143
  else body.tool_choice = { type: 'function', function: { name: v } };
129
144
  }
130
- if (values.reasoning) body.reasoning = { effort: values.reasoning };
131
145
  if (values.provider) body.provider = await loadJsonOrFile(values.provider);
132
146
  return body;
133
147
  }
@@ -180,9 +194,14 @@ export async function chatCommand(argv) {
180
194
  'no-stream': { type: 'boolean' },
181
195
  temperature: { type: 'string' },
182
196
  'top-p': { type: 'string' },
197
+ 'top-k': { type: 'string' },
183
198
  'max-tokens': { type: 'string' },
184
199
  seed: { type: 'string' },
185
200
  stop: { type: 'string' },
201
+ 'frequency-penalty': { type: 'string' },
202
+ 'presence-penalty': { type: 'string' },
203
+ 'repetition-penalty': { type: 'string' },
204
+ 'min-p': { type: 'string' },
186
205
  'json-output': { type: 'boolean' },
187
206
  schema: { type: 'string' },
188
207
  tool: { type: 'string', multiple: true },
@@ -286,6 +305,7 @@ async function repl(values, auth) {
286
305
  }
287
306
  history.push({ role: 'user', content: trimmed });
288
307
  const body = { model, messages: history, stream: true };
308
+ applySamplingOptions(body, values);
289
309
  try {
290
310
  const res = await api('POST', '/chat/completions', {
291
311
  auth,
@@ -300,11 +320,15 @@ async function repl(values, auth) {
300
320
  out(delta.content);
301
321
  assistant += delta.content;
302
322
  }
323
+ if (delta?.reasoning && process.stdout.isTTY) out(c.dim(delta.reasoning));
303
324
  }
304
325
  out('\n');
305
326
  history.push({ role: 'assistant', content: assistant });
306
327
  } catch (err) {
307
328
  outln(c.red(err.message));
329
+ // Drop the orphaned user message so the next turn doesn't send a
330
+ // [..., user, user] sequence the API will reject.
331
+ history.pop();
308
332
  }
309
333
  }
310
334
  } finally {
@@ -25,7 +25,13 @@ OpenAI-compatible /responses endpoint.
25
25
  Options:
26
26
  -m, --model <id> Model id (required)
27
27
  -s, --instructions <t> System / instructions
28
- --stream Stream tokens
28
+ --max-tokens <n> Sent as max_output_tokens
29
+ --temperature <n>
30
+ --top-p <n>
31
+ --seed <n>
32
+ --reasoning <effort> low | medium | high
33
+ --stream Stream tokens (default when TTY)
34
+ --no-stream Disable streaming
29
35
  --raw Print full JSON response
30
36
  --body <json|@file> Provide a fully-formed body (overrides flags)
31
37
  `;
@@ -117,7 +123,13 @@ export async function responsesCommand(argv) {
117
123
  const { values, positionals } = parseArgs(argv, {
118
124
  model: { type: 'string', short: 'm' },
119
125
  instructions: { type: 'string', short: 's' },
126
+ 'max-tokens': { type: 'string' },
127
+ temperature: { type: 'string' },
128
+ 'top-p': { type: 'string' },
129
+ seed: { type: 'string' },
130
+ reasoning: { type: 'string' },
120
131
  stream: { type: 'boolean' },
132
+ 'no-stream': { type: 'boolean' },
121
133
  raw: { type: 'boolean' },
122
134
  body: { type: 'string' }
123
135
  });
@@ -135,9 +147,18 @@ export async function responsesCommand(argv) {
135
147
  if (!prompt) throw new Error('No prompt.');
136
148
  body = { model: values.model, input: prompt };
137
149
  if (values.instructions) body.instructions = values.instructions;
150
+ if (values['max-tokens'] != null) body.max_output_tokens = Number(values['max-tokens']);
151
+ if (values.temperature != null) body.temperature = Number(values.temperature);
152
+ if (values['top-p'] != null) body.top_p = Number(values['top-p']);
153
+ if (values.seed != null) body.seed = Number(values.seed);
154
+ if (values.reasoning) body.reasoning = { effort: values.reasoning };
138
155
  }
139
156
 
140
- if (values.stream) {
157
+ const shouldStream =
158
+ values.stream ||
159
+ (!values['no-stream'] && !values.raw && !isJsonMode() && process.stdout.isTTY);
160
+
161
+ if (shouldStream) {
141
162
  body.stream = true;
142
163
  const res = await api('POST', '/responses', {
143
164
  auth: authFromValues(values),
package/src/config.js CHANGED
@@ -64,7 +64,7 @@ export async function resolveAuth(opts = {}) {
64
64
  opts.referer ||
65
65
  process.env.OPENROUTER_REFERER ||
66
66
  cfg.referer ||
67
- 'https://github.com/openrouter-cli';
67
+ 'https://github.com/aaronjmars/openroutercli';
68
68
  const title =
69
69
  opts.title || process.env.OPENROUTER_TITLE || cfg.title || 'openrouter-cli';
70
70
  return {