@link-assistant/agent 0.1.2 → 0.1.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.1.2",
3
+ "version": "0.1.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",
@@ -43,6 +43,7 @@
43
43
  },
44
44
  "files": [
45
45
  "src/",
46
+ "package.json",
46
47
  "README.md",
47
48
  "MODELS.md",
48
49
  "TOOLS.md",
package/src/index.js CHANGED
@@ -18,6 +18,22 @@ import { AuthCommand } from './cli/cmd/auth.ts';
18
18
  import { Flag } from './flag/flag.ts';
19
19
  import { FormatError } from './cli/error.ts';
20
20
  import { UI } from './cli/ui.ts';
21
+ import { createRequire } from 'module';
22
+ import { readFileSync } from 'fs';
23
+ import { dirname, join } from 'path';
24
+ import { fileURLToPath } from 'url';
25
+
26
+ const require = createRequire(import.meta.url);
27
+ let pkg;
28
+ try {
29
+ pkg = require('../package.json');
30
+ } catch (_e) {
31
+ // Fallback: read package.json directly
32
+ const __dirname = dirname(fileURLToPath(import.meta.url));
33
+ const pkgPath = join(__dirname, '../package.json');
34
+ const pkgContent = readFileSync(pkgPath, 'utf8');
35
+ pkg = JSON.parse(pkgContent);
36
+ }
21
37
 
22
38
  // Track if any errors occurred during execution
23
39
  let hasError = false;
@@ -86,6 +102,14 @@ async function runAgentMode(argv) {
86
102
  // Note: verbose flag and logging are now initialized in middleware
87
103
  // See main() function for the middleware that sets up Flag and Log.init()
88
104
 
105
+ // Log version and command info in verbose mode
106
+ if (Flag.OPENCODE_VERBOSE) {
107
+ console.error(`Agent version: ${pkg.version}`);
108
+ console.error(`Command: ${process.argv.join(' ')}`);
109
+ console.error(`Working directory: ${process.cwd()}`);
110
+ console.error(`Script path: ${import.meta.path}`);
111
+ }
112
+
89
113
  // Parse model argument (handle model IDs with slashes like groq/qwen/qwen3-32b)
90
114
  const modelParts = argv.model.split('/');
91
115
  let providerID = modelParts[0] || 'opencode';
@@ -505,6 +529,7 @@ async function main() {
505
529
  const argv = await yargs(hideBin(process.argv))
506
530
  .scriptName('agent')
507
531
  .usage('$0 [command] [options]')
532
+ .version(pkg.version)
508
533
  // MCP subcommand
509
534
  .command(McpCommand)
510
535
  // Auth subcommand
@@ -704,7 +704,30 @@ export namespace SessionPrompt {
704
704
  // When --system-message is provided, use it exclusively without any
705
705
  // additional context (no environment, no custom instructions, no header).
706
706
  // This is critical for models with low token limits (e.g., qwen3-32b with 6K TPM).
707
+ //
708
+ // Exception: For Anthropic providers using OAuth credentials, we must preserve
709
+ // the "You are Claude Code" header when the system message doesn't contain it.
710
+ // This header is required for OAuth token authorization.
711
+ // See: https://github.com/link-assistant/agent/issues/62
707
712
  if (input.system !== undefined) {
713
+ // Filter out empty strings to prevent cache_control errors
714
+ if (input.system.trim() === '') {
715
+ // For Anthropic providers with empty system message, preserve the OAuth header
716
+ if (input.providerID.includes('anthropic')) {
717
+ return SystemPrompt.header(input.providerID);
718
+ }
719
+ return [];
720
+ }
721
+
722
+ // For Anthropic providers, ensure "Claude Code" header is present
723
+ if (input.providerID.includes('anthropic')) {
724
+ const hasClaudeCode = input.system.includes('Claude Code');
725
+ if (!hasClaudeCode) {
726
+ // Prepend the OAuth header if not present
727
+ return [...SystemPrompt.header(input.providerID), input.system];
728
+ }
729
+ }
730
+
708
731
  return [input.system];
709
732
  }
710
733