@link-assistant/agent 0.16.2 → 0.16.4

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
@@ -194,9 +194,8 @@ echo '{"message":"run command","tools":[{"name":"bash","params":{"command":"ls -
194
194
  echo "hi" | agent
195
195
 
196
196
  # Other free models (in order of recommendation)
197
- echo "hi" | agent --model opencode/minimax-m2.1-free
197
+ echo "hi" | agent --model opencode/minimax-m2.5-free
198
198
  echo "hi" | agent --model opencode/gpt-5-nano
199
- echo "hi" | agent --model opencode/glm-4.7-free
200
199
  echo "hi" | agent --model opencode/big-pickle
201
200
 
202
201
  # Premium models (OpenCode Zen subscription)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/agent",
3
- "version": "0.16.2",
3
+ "version": "0.16.4",
4
4
  "description": "A minimal, public domain AI CLI agent compatible with OpenCode's JSON interface. Bun-only runtime.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -0,0 +1,33 @@
1
+ /**
2
+ * CLI argument utilities for parsing process.argv directly
3
+ * These provide safeguards against yargs caching issues (#192)
4
+ */
5
+
6
+ /**
7
+ * Extract model argument directly from process.argv
8
+ * This is a safeguard against yargs caching issues (#192)
9
+ * @returns The model argument from CLI or null if not found
10
+ */
11
+ export function getModelFromProcessArgv(): string | null {
12
+ const args = process.argv;
13
+ for (let i = 0; i < args.length; i++) {
14
+ const arg = args[i];
15
+ // Handle --model=value format
16
+ if (arg.startsWith('--model=')) {
17
+ return arg.substring('--model='.length);
18
+ }
19
+ // Handle --model value format
20
+ if (arg === '--model' && i + 1 < args.length) {
21
+ return args[i + 1];
22
+ }
23
+ // Handle -m=value format
24
+ if (arg.startsWith('-m=')) {
25
+ return arg.substring('-m='.length);
26
+ }
27
+ // Handle -m value format (but not if it looks like another flag)
28
+ if (arg === '-m' && i + 1 < args.length && !args[i + 1].startsWith('-')) {
29
+ return args[i + 1];
30
+ }
31
+ }
32
+ return null;
33
+ }
package/src/index.js CHANGED
@@ -5,6 +5,7 @@ setProcessName('agent');
5
5
  import { Server } from './server/server.ts';
6
6
  import { Instance } from './project/instance.ts';
7
7
  import { Log } from './util/log.ts';
8
+ import { getModelFromProcessArgv } from './cli/argv.ts';
8
9
  // Bus is used via createBusEventSubscription in event-handler.js
9
10
  import { Session } from './session/index.ts';
10
11
  import { SessionPrompt } from './session/prompt.ts';
@@ -134,24 +135,20 @@ function readStdinWithTimeout(timeout = null) {
134
135
  });
135
136
  }
136
137
 
137
- // outputStatus is now imported from './cli/output.ts'
138
- // It outputs to stdout for non-error messages, stderr for errors
139
-
140
- /**
141
- * Parse model configuration from argv
142
- * Supports both explicit provider/model format and short model names.
143
- *
144
- * Format examples:
145
- * - "kilo/glm-5-free" -> uses kilo provider with glm-5-free model (explicit)
146
- * - "opencode/kimi-k2.5-free" -> uses opencode provider (explicit)
147
- * - "glm-5-free" -> resolved to kilo provider (unique free model)
148
- * - "kimi-k2.5-free" -> resolved to opencode provider (shared model, opencode preferred)
149
- *
150
- * @param {object} argv - Command line arguments
151
- * @returns {object} - { providerID, modelID }
152
- */
138
+ /** Parse model config from argv. Supports "provider/model" or short "model" format. */
153
139
  async function parseModelConfig(argv) {
154
- const modelArg = argv.model;
140
+ // Safeguard: validate argv.model against process.argv to detect yargs/cache mismatch (#192)
141
+ const cliModelArg = getModelFromProcessArgv();
142
+ let modelArg = argv.model;
143
+ if (cliModelArg && cliModelArg !== modelArg) {
144
+ Log.Default.warn(() => ({
145
+ message: 'model argument mismatch detected - using CLI value',
146
+ yargsModel: modelArg,
147
+ cliModel: cliModelArg,
148
+ processArgv: process.argv.join(' '),
149
+ }));
150
+ modelArg = cliModelArg;
151
+ }
155
152
 
156
153
  let providerID;
157
154
  let modelID;
@@ -1397,9 +1397,8 @@ export namespace Provider {
1397
1397
  if (providerID === 'opencode' || providerID === 'local') {
1398
1398
  priority = [
1399
1399
  'kimi-k2.5-free',
1400
- 'minimax-m2.1-free',
1400
+ 'minimax-m2.5-free',
1401
1401
  'gpt-5-nano',
1402
- 'glm-4.7-free',
1403
1402
  'big-pickle',
1404
1403
  ];
1405
1404
  }
@@ -1430,9 +1429,8 @@ export namespace Provider {
1430
1429
  const priority = [
1431
1430
  'glm-5-free',
1432
1431
  'kimi-k2.5-free',
1433
- 'minimax-m2.1-free',
1432
+ 'minimax-m2.5-free',
1434
1433
  'gpt-5-nano',
1435
- 'glm-4.7-free',
1436
1434
  'big-pickle',
1437
1435
  'gpt-5',
1438
1436
  'claude-sonnet-4',