@link-assistant/agent 0.16.3 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@link-assistant/agent",
3
- "version": "0.16.3",
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;