berget 2.2.7 → 2.2.9

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.
Files changed (130) hide show
  1. package/.github/workflows/publish.yml +6 -6
  2. package/.github/workflows/test.yml +1 -1
  3. package/.prettierrc +5 -3
  4. package/dist/index.js +24 -25
  5. package/dist/package.json +7 -3
  6. package/dist/src/agents/app.js +8 -8
  7. package/dist/src/agents/backend.js +3 -3
  8. package/dist/src/agents/devops.js +8 -8
  9. package/dist/src/agents/frontend.js +3 -3
  10. package/dist/src/agents/fullstack.js +3 -3
  11. package/dist/src/agents/index.js +18 -18
  12. package/dist/src/agents/quality.js +8 -8
  13. package/dist/src/agents/security.js +8 -8
  14. package/dist/src/client.js +115 -127
  15. package/dist/src/commands/api-keys.js +181 -202
  16. package/dist/src/commands/auth.js +16 -25
  17. package/dist/src/commands/autocomplete.js +8 -8
  18. package/dist/src/commands/billing.js +10 -19
  19. package/dist/src/commands/chat.js +139 -170
  20. package/dist/src/commands/clusters.js +21 -30
  21. package/dist/src/commands/code/__tests__/auth-sync.test.js +189 -186
  22. package/dist/src/commands/code/__tests__/fake-api-key-service.js +3 -13
  23. package/dist/src/commands/code/__tests__/fake-auth-service.js +21 -29
  24. package/dist/src/commands/code/__tests__/fake-command-runner.js +22 -33
  25. package/dist/src/commands/code/__tests__/fake-file-store.js +19 -41
  26. package/dist/src/commands/code/__tests__/fake-prompter.js +81 -97
  27. package/dist/src/commands/code/__tests__/setup-flow.test.js +295 -295
  28. package/dist/src/commands/code/adapters/clack-prompter.js +15 -32
  29. package/dist/src/commands/code/adapters/fs-file-store.js +25 -44
  30. package/dist/src/commands/code/adapters/spawn-command-runner.js +27 -41
  31. package/dist/src/commands/code/auth-sync.js +215 -228
  32. package/dist/src/commands/code/errors.js +15 -12
  33. package/dist/src/commands/code/setup.js +390 -425
  34. package/dist/src/commands/code.js +279 -294
  35. package/dist/src/commands/index.js +5 -5
  36. package/dist/src/commands/models.js +16 -25
  37. package/dist/src/commands/users.js +9 -18
  38. package/dist/src/constants/command-structure.js +138 -138
  39. package/dist/src/services/api-key-service.js +132 -152
  40. package/dist/src/services/auth-service.js +81 -95
  41. package/dist/src/services/browser-auth.js +121 -131
  42. package/dist/src/services/chat-service.js +369 -386
  43. package/dist/src/services/cluster-service.js +47 -62
  44. package/dist/src/services/collaborator-service.js +9 -21
  45. package/dist/src/services/flux-service.js +13 -25
  46. package/dist/src/services/helm-service.js +9 -21
  47. package/dist/src/services/kubectl-service.js +15 -29
  48. package/dist/src/utils/config-checker.js +8 -8
  49. package/dist/src/utils/config-loader.js +109 -109
  50. package/dist/src/utils/default-api-key.js +129 -139
  51. package/dist/src/utils/env-manager.js +55 -66
  52. package/dist/src/utils/error-handler.js +62 -62
  53. package/dist/src/utils/logger.js +74 -67
  54. package/dist/src/utils/markdown-renderer.js +28 -28
  55. package/dist/src/utils/opencode-validator.js +67 -69
  56. package/dist/src/utils/token-manager.js +67 -65
  57. package/dist/tests/commands/chat.test.js +30 -39
  58. package/dist/tests/commands/code.test.js +186 -195
  59. package/dist/tests/utils/config-loader.test.js +107 -107
  60. package/dist/tests/utils/env-manager.test.js +81 -90
  61. package/dist/tests/utils/opencode-validator.test.js +42 -41
  62. package/dist/vitest.config.js +1 -1
  63. package/eslint.config.mjs +65 -30
  64. package/index.ts +30 -31
  65. package/package.json +7 -3
  66. package/src/agents/app.ts +9 -9
  67. package/src/agents/backend.ts +4 -4
  68. package/src/agents/devops.ts +9 -9
  69. package/src/agents/frontend.ts +4 -4
  70. package/src/agents/fullstack.ts +4 -4
  71. package/src/agents/index.ts +27 -25
  72. package/src/agents/quality.ts +9 -9
  73. package/src/agents/security.ts +9 -9
  74. package/src/agents/types.ts +10 -10
  75. package/src/client.ts +85 -77
  76. package/src/commands/api-keys.ts +180 -185
  77. package/src/commands/auth.ts +15 -14
  78. package/src/commands/autocomplete.ts +10 -10
  79. package/src/commands/billing.ts +13 -12
  80. package/src/commands/chat.ts +145 -142
  81. package/src/commands/clusters.ts +20 -19
  82. package/src/commands/code/__tests__/auth-sync.test.ts +176 -175
  83. package/src/commands/code/__tests__/fake-api-key-service.ts +2 -2
  84. package/src/commands/code/__tests__/fake-auth-service.ts +18 -18
  85. package/src/commands/code/__tests__/fake-command-runner.ts +28 -22
  86. package/src/commands/code/__tests__/fake-file-store.ts +15 -15
  87. package/src/commands/code/__tests__/fake-prompter.ts +86 -85
  88. package/src/commands/code/__tests__/setup-flow.test.ts +253 -251
  89. package/src/commands/code/adapters/clack-prompter.ts +32 -30
  90. package/src/commands/code/adapters/fs-file-store.ts +18 -17
  91. package/src/commands/code/adapters/spawn-command-runner.ts +20 -15
  92. package/src/commands/code/auth-sync.ts +210 -210
  93. package/src/commands/code/errors.ts +11 -11
  94. package/src/commands/code/ports/auth-services.ts +7 -7
  95. package/src/commands/code/ports/command-runner.ts +2 -2
  96. package/src/commands/code/ports/file-store.ts +3 -3
  97. package/src/commands/code/ports/prompter.ts +13 -13
  98. package/src/commands/code/setup.ts +408 -406
  99. package/src/commands/code.ts +288 -287
  100. package/src/commands/index.ts +11 -10
  101. package/src/commands/models.ts +19 -18
  102. package/src/commands/users.ts +11 -10
  103. package/src/constants/command-structure.ts +159 -159
  104. package/src/services/api-key-service.ts +85 -85
  105. package/src/services/auth-service.ts +55 -54
  106. package/src/services/browser-auth.ts +62 -62
  107. package/src/services/chat-service.ts +170 -171
  108. package/src/services/cluster-service.ts +28 -28
  109. package/src/services/collaborator-service.ts +6 -6
  110. package/src/services/flux-service.ts +17 -17
  111. package/src/services/helm-service.ts +11 -11
  112. package/src/services/kubectl-service.ts +12 -12
  113. package/src/types/api.d.ts +1933 -1933
  114. package/src/types/json.d.ts +1 -1
  115. package/src/utils/config-checker.ts +7 -7
  116. package/src/utils/config-loader.ts +130 -129
  117. package/src/utils/default-api-key.ts +81 -80
  118. package/src/utils/env-manager.ts +37 -37
  119. package/src/utils/error-handler.ts +64 -64
  120. package/src/utils/logger.ts +72 -66
  121. package/src/utils/markdown-renderer.ts +28 -28
  122. package/src/utils/opencode-validator.ts +72 -71
  123. package/src/utils/token-manager.ts +69 -68
  124. package/tests/commands/chat.test.ts +32 -31
  125. package/tests/commands/code.test.ts +182 -181
  126. package/tests/utils/config-loader.test.ts +111 -110
  127. package/tests/utils/env-manager.test.ts +83 -79
  128. package/tests/utils/opencode-validator.test.ts +43 -42
  129. package/tsconfig.json +2 -1
  130. package/vitest.config.ts +2 -2
@@ -1,192 +1,196 @@
1
- import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
2
- import fs from "fs";
3
- import { writeFile } from "fs/promises";
4
- import path from "path";
5
- import { updateEnvFile, hasEnvKey } from "../../src/utils/env-manager";
1
+ import fs from 'node:fs';
2
+ import { writeFile } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
6
5
 
7
- vi.mock("fs");
8
- vi.mock("fs/promises");
9
- vi.mock("path");
6
+ import {
7
+ hasEnvKey as hasEnvironmentKey,
8
+ updateEnvFile as updateEnvironmentFile,
9
+ } from '../../src/utils/env-manager';
10
+
11
+ vi.mock('fs');
12
+ vi.mock('fs/promises');
13
+ vi.mock('path');
10
14
 
11
15
  const mockFs = vi.mocked(fs);
12
16
  const mockWriteFile = vi.mocked(writeFile);
13
17
  const mockPath = vi.mocked(path);
14
18
 
15
- describe("env-manager", () => {
16
- const testEnvPath = "/test/.env";
17
- const testCwd = "/test";
19
+ describe('env-manager', () => {
20
+ const testEnvironmentPath = '/test/.env';
21
+ const testCwd = '/test';
18
22
 
19
23
  beforeEach(() => {
20
24
  vi.clearAllMocks();
21
- mockPath.join.mockReturnValue(testEnvPath);
22
- vi.spyOn(process, "cwd").mockReturnValue(testCwd);
25
+ mockPath.join.mockReturnValue(testEnvironmentPath);
26
+ vi.spyOn(process, 'cwd').mockReturnValue(testCwd);
23
27
  });
24
28
 
25
29
  afterEach(() => {
26
30
  vi.restoreAllMocks();
27
31
  });
28
32
 
29
- describe("updateEnvFile", () => {
30
- it("should create a new .env file with the key when file does not exist", async () => {
33
+ describe('updateEnvFile', () => {
34
+ it('should create a new .env file with the key when file does not exist', async () => {
31
35
  mockFs.existsSync.mockReturnValue(false);
32
36
 
33
- await updateEnvFile({
34
- key: "TEST_KEY",
35
- value: "test_value",
36
- comment: "Test comment",
37
+ await updateEnvironmentFile({
38
+ comment: 'Test comment',
39
+ key: 'TEST_KEY',
40
+ value: 'test_value',
37
41
  });
38
42
 
39
- expect(mockFs.existsSync).toHaveBeenCalledWith(testEnvPath);
43
+ expect(mockFs.existsSync).toHaveBeenCalledWith(testEnvironmentPath);
40
44
  expect(mockWriteFile).toHaveBeenCalledWith(
41
- testEnvPath,
42
- "# Test comment\nTEST_KEY=test_value\n"
45
+ testEnvironmentPath,
46
+ '# Test comment\nTEST_KEY=test_value\n',
43
47
  );
44
48
  });
45
49
 
46
- it("should append to existing .env file when key does not exist", async () => {
47
- const existingContent = "EXISTING_KEY=existing_value\n";
50
+ it('should append to existing .env file when key does not exist', async () => {
51
+ const existingContent = 'EXISTING_KEY=existing_value\n';
48
52
  mockFs.existsSync.mockReturnValue(true);
49
53
  mockFs.readFileSync.mockReturnValue(existingContent);
50
54
 
51
- await updateEnvFile({
52
- key: "NEW_KEY",
53
- value: "new_value",
54
- comment: "Test comment",
55
+ await updateEnvironmentFile({
56
+ comment: 'Test comment',
57
+ key: 'NEW_KEY',
58
+ value: 'new_value',
55
59
  });
56
60
 
57
61
  expect(mockWriteFile).toHaveBeenCalledWith(
58
- testEnvPath,
59
- "EXISTING_KEY=existing_value\nNEW_KEY=new_value\n"
62
+ testEnvironmentPath,
63
+ 'EXISTING_KEY=existing_value\nNEW_KEY=new_value\n',
60
64
  );
61
65
  });
62
66
 
63
- it("should not update when key already exists and force is false", async () => {
64
- const existingContent = "EXISTING_KEY=existing_value\nTEST_KEY=old_value\n";
67
+ it('should not update when key already exists and force is false', async () => {
68
+ const existingContent = 'EXISTING_KEY=existing_value\nTEST_KEY=old_value\n';
65
69
  mockFs.existsSync.mockReturnValue(true);
66
70
  mockFs.readFileSync.mockReturnValue(existingContent);
67
71
 
68
- const consoleSpy = vi.spyOn(console, "log").mockImplementation(() => {});
72
+ const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
69
73
 
70
- await updateEnvFile({
71
- key: "TEST_KEY",
72
- value: "new_value",
74
+ await updateEnvironmentFile({
75
+ key: 'TEST_KEY',
76
+ value: 'new_value',
73
77
  });
74
78
 
75
79
  expect(consoleSpy).toHaveBeenCalledWith(
76
- expect.stringContaining("TEST_KEY already exists in .env - leaving unchanged")
80
+ expect.stringContaining('TEST_KEY already exists in .env - leaving unchanged'),
77
81
  );
78
82
  expect(mockWriteFile).not.toHaveBeenCalled();
79
83
 
80
84
  consoleSpy.mockRestore();
81
85
  });
82
86
 
83
- it("should update existing key when force is true", async () => {
84
- const existingContent = "EXISTING_KEY=existing_value\nTEST_KEY=old_value\n";
87
+ it('should update existing key when force is true', async () => {
88
+ const existingContent = 'EXISTING_KEY=existing_value\nTEST_KEY=old_value\n';
85
89
  mockFs.existsSync.mockReturnValue(true);
86
90
  mockFs.readFileSync.mockReturnValue(existingContent);
87
91
 
88
- await updateEnvFile({
89
- key: "TEST_KEY",
90
- value: "new_value",
92
+ await updateEnvironmentFile({
91
93
  force: true,
94
+ key: 'TEST_KEY',
95
+ value: 'new_value',
92
96
  });
93
97
 
94
98
  expect(mockWriteFile).toHaveBeenCalledWith(
95
- testEnvPath,
96
- "EXISTING_KEY=existing_value\nTEST_KEY=new_value\n"
99
+ testEnvironmentPath,
100
+ 'EXISTING_KEY=existing_value\nTEST_KEY=new_value\n',
97
101
  );
98
102
  });
99
103
 
100
- it("should handle complex values with quotes and special characters", async () => {
104
+ it('should handle complex values with quotes and special characters', async () => {
101
105
  mockFs.existsSync.mockReturnValue(false);
102
106
 
103
- await updateEnvFile({
104
- key: "COMPLEX_KEY",
107
+ await updateEnvironmentFile({
108
+ comment: 'Complex test',
109
+ key: 'COMPLEX_KEY',
105
110
  value: 'value with "quotes" and $special',
106
- comment: "Complex test",
107
111
  });
108
112
 
109
113
  expect(mockWriteFile).toHaveBeenCalledWith(
110
- testEnvPath,
111
- '# Complex test\nCOMPLEX_KEY=value with "quotes" and $special\n'
114
+ testEnvironmentPath,
115
+ '# Complex test\nCOMPLEX_KEY=value with "quotes" and $special\n',
112
116
  );
113
117
  });
114
118
 
115
- it("should use custom env path when provided", async () => {
116
- const customPath = "/custom/.env";
119
+ it('should use custom env path when provided', async () => {
120
+ const customPath = '/custom/.env';
117
121
  mockFs.existsSync.mockReturnValue(false);
118
122
 
119
- await updateEnvFile({
123
+ await updateEnvironmentFile({
120
124
  envPath: customPath,
121
- key: "TEST_KEY",
122
- value: "test_value",
125
+ key: 'TEST_KEY',
126
+ value: 'test_value',
123
127
  });
124
128
 
125
129
  expect(mockFs.existsSync).toHaveBeenCalledWith(customPath);
126
- expect(mockWriteFile).toHaveBeenCalledWith(customPath, "TEST_KEY=test_value\n");
130
+ expect(mockWriteFile).toHaveBeenCalledWith(customPath, 'TEST_KEY=test_value\n');
127
131
  });
128
132
 
129
- it("should throw error when write fails", async () => {
133
+ it('should throw error when write fails', async () => {
130
134
  mockFs.existsSync.mockReturnValue(false);
131
- mockWriteFile.mockRejectedValue(new Error("Write error"));
135
+ mockWriteFile.mockRejectedValue(new Error('Write error'));
132
136
 
133
137
  await expect(
134
- updateEnvFile({
135
- key: "TEST_KEY",
136
- value: "test_value",
137
- })
138
- ).rejects.toThrow("Write error");
138
+ updateEnvironmentFile({
139
+ key: 'TEST_KEY',
140
+ value: 'test_value',
141
+ }),
142
+ ).rejects.toThrow('Write error');
139
143
  });
140
144
  });
141
145
 
142
- describe("hasEnvKey", () => {
143
- it("should return false when .env file does not exist", () => {
146
+ describe('hasEnvKey', () => {
147
+ it('should return false when .env file does not exist', () => {
144
148
  mockFs.existsSync.mockReturnValue(false);
145
149
 
146
- const result = hasEnvKey(testEnvPath, "TEST_KEY");
150
+ const result = hasEnvironmentKey(testEnvironmentPath, 'TEST_KEY');
147
151
 
148
152
  expect(result).toBe(false);
149
- expect(mockFs.existsSync).toHaveBeenCalledWith(testEnvPath);
153
+ expect(mockFs.existsSync).toHaveBeenCalledWith(testEnvironmentPath);
150
154
  expect(mockFs.readFileSync).not.toHaveBeenCalled();
151
155
  });
152
156
 
153
- it("should return true when key exists in .env file", () => {
154
- const existingContent = "KEY1=value1\nTEST_KEY=test_value\nKEY2=value2\n";
157
+ it('should return true when key exists in .env file', () => {
158
+ const existingContent = 'KEY1=value1\nTEST_KEY=test_value\nKEY2=value2\n';
155
159
  mockFs.existsSync.mockReturnValue(true);
156
160
  mockFs.readFileSync.mockReturnValue(existingContent);
157
161
 
158
- const result = hasEnvKey(testEnvPath, "TEST_KEY");
162
+ const result = hasEnvironmentKey(testEnvironmentPath, 'TEST_KEY');
159
163
 
160
164
  expect(result).toBe(true);
161
165
  });
162
166
 
163
- it("should return false when key does not exist in .env file", () => {
164
- const existingContent = "KEY1=value1\nKEY2=value2\n";
167
+ it('should return false when key does not exist in .env file', () => {
168
+ const existingContent = 'KEY1=value1\nKEY2=value2\n';
165
169
  mockFs.existsSync.mockReturnValue(true);
166
170
  mockFs.readFileSync.mockReturnValue(existingContent);
167
171
 
168
- const result = hasEnvKey(testEnvPath, "TEST_KEY");
172
+ const result = hasEnvironmentKey(testEnvironmentPath, 'TEST_KEY');
169
173
 
170
174
  expect(result).toBe(false);
171
175
  });
172
176
 
173
- it("should return false when .env file is malformed", () => {
177
+ it('should return false when .env file is malformed', () => {
174
178
  mockFs.existsSync.mockReturnValue(true);
175
179
  mockFs.readFileSync.mockImplementation(() => {
176
- throw new Error("Read error");
180
+ throw new Error('Read error');
177
181
  });
178
182
 
179
- const result = hasEnvKey(testEnvPath, "TEST_KEY");
183
+ const result = hasEnvironmentKey(testEnvironmentPath, 'TEST_KEY');
180
184
 
181
185
  expect(result).toBe(false);
182
186
  });
183
187
 
184
- it("should use default path when not provided", () => {
188
+ it('should use default path when not provided', () => {
185
189
  mockFs.existsSync.mockReturnValue(false);
186
190
 
187
- hasEnvKey(undefined, "TEST_KEY");
191
+ hasEnvironmentKey(undefined, 'TEST_KEY');
188
192
 
189
- expect(mockFs.existsSync).toHaveBeenCalledWith(testEnvPath);
193
+ expect(mockFs.existsSync).toHaveBeenCalledWith(testEnvironmentPath);
190
194
  });
191
195
  });
192
196
  });
@@ -1,25 +1,26 @@
1
- import { describe, it, expect } from "vitest";
2
- import { validateOpenCodeConfig, fixOpenCodeConfig } from "../../src/utils/opencode-validator";
3
- import { readFileSync } from "fs";
1
+ import { readFileSync } from 'node:fs';
2
+ import { describe, expect, it } from 'vitest';
4
3
 
5
- describe("OpenCode Validator", () => {
6
- it("should validate a correct OpenCode configuration", () => {
4
+ import { fixOpenCodeConfig, validateOpenCodeConfig } from '../../src/utils/opencode-validator';
5
+
6
+ describe('OpenCode Validator', () => {
7
+ it('should validate a correct OpenCode configuration', () => {
7
8
  const validConfig = {
8
- $schema: "https://opencode.ai/config.json",
9
- username: "test-user",
10
- model: "gpt-4",
9
+ $schema: 'https://opencode.ai/config.json',
11
10
  agent: {
12
11
  test: {
13
- model: "gpt-4",
14
- temperature: 0.7,
15
- prompt: "Test agent",
12
+ model: 'gpt-4',
16
13
  permission: {
17
- edit: "allow",
18
- bash: "allow",
19
- webfetch: "allow",
14
+ bash: 'allow',
15
+ edit: 'allow',
16
+ webfetch: 'allow',
20
17
  },
18
+ prompt: 'Test agent',
19
+ temperature: 0.7,
21
20
  },
22
21
  },
22
+ model: 'gpt-4',
23
+ username: 'test-user',
23
24
  };
24
25
 
25
26
  const result = validateOpenCodeConfig(validConfig);
@@ -27,22 +28,22 @@ describe("OpenCode Validator", () => {
27
28
  expect(result.errors).toBeUndefined();
28
29
  });
29
30
 
30
- it("should reject invalid configuration", () => {
31
+ it('should reject invalid configuration', () => {
31
32
  const invalidConfig = {
32
- username: 123, // Should be string
33
- model: "gpt-4",
34
33
  agent: {
35
34
  test: {
36
- model: "gpt-4",
37
- temperature: "high", // Should be number
38
- prompt: "Test agent",
35
+ model: 'gpt-4',
39
36
  permission: {
40
- edit: "invalid", // Should be enum value
41
- bash: "allow",
42
- webfetch: "allow",
37
+ bash: 'allow',
38
+ edit: 'invalid', // Should be enum value
39
+ webfetch: 'allow',
43
40
  },
41
+ prompt: 'Test agent',
42
+ temperature: 'high', // Should be number
44
43
  },
45
44
  },
45
+ model: 'gpt-4',
46
+ username: 123, // Should be string
46
47
  };
47
48
 
48
49
  const result = validateOpenCodeConfig(invalidConfig);
@@ -51,49 +52,49 @@ describe("OpenCode Validator", () => {
51
52
  expect(result.errors!.length).toBeGreaterThan(0);
52
53
  });
53
54
 
54
- it("should fix common configuration issues", () => {
55
+ it('should fix common configuration issues', () => {
55
56
  const configWithIssues = {
56
- username: "test-user",
57
- model: "gpt-4",
58
- tools: {
59
- compact: { threshold: 80000 }, // Should be boolean
60
- },
61
57
  maxTokens: 4000, // Invalid property
58
+ model: 'gpt-4',
62
59
  provider: {
63
60
  berget: {
64
61
  models: {
65
- "test-model": {
66
- name: "Test Model",
67
- maxTokens: 4000, // Should be moved to limit.context
62
+ 'test-model': {
68
63
  contextWindow: 8000, // Should be moved to limit.context
64
+ maxTokens: 4000, // Should be moved to limit.context
65
+ name: 'Test Model',
69
66
  },
70
67
  },
71
68
  },
72
69
  },
70
+ tools: {
71
+ compact: { threshold: 80_000 }, // Should be boolean
72
+ },
73
+ username: 'test-user',
73
74
  };
74
75
 
75
76
  const fixed = fixOpenCodeConfig(configWithIssues);
76
77
 
77
78
  // tools.compact should be boolean
78
- expect(typeof fixed.tools.compact).toBe("boolean");
79
+ expect(typeof fixed.tools.compact).toBe('boolean');
79
80
 
80
81
  // maxTokens should be removed
81
82
  expect(fixed.maxTokens).toBeUndefined();
82
83
 
83
84
  // maxTokens and contextWindow should be moved to limit.context
84
- expect(fixed.provider.berget.models["test-model"].limit).toBeDefined();
85
- expect(fixed.provider.berget.models["test-model"].limit.context).toBe(8000);
86
- expect(fixed.provider.berget.models["test-model"].maxTokens).toBeUndefined();
87
- expect(fixed.provider.berget.models["test-model"].contextWindow).toBeUndefined();
85
+ expect(fixed.provider.berget.models['test-model'].limit).toBeDefined();
86
+ expect(fixed.provider.berget.models['test-model'].limit.context).toBe(8000);
87
+ expect(fixed.provider.berget.models['test-model'].maxTokens).toBeUndefined();
88
+ expect(fixed.provider.berget.models['test-model'].contextWindow).toBeUndefined();
88
89
  });
89
90
 
90
- it("should validate the current opencode.json file", () => {
91
+ it('should validate the current opencode.json file', () => {
91
92
  let currentConfig;
92
93
  try {
93
- currentConfig = JSON.parse(readFileSync("opencode.json", "utf8"));
94
+ currentConfig = JSON.parse(readFileSync('opencode.json', 'utf8'));
94
95
  } catch (error) {
95
96
  // Skip when opencode.json is not present (e.g. in CI or clean checkouts)
96
- console.log("Skipping: opencode.json not found:", error);
97
+ console.log('Skipping: opencode.json not found:', error);
97
98
  return;
98
99
  }
99
100
 
@@ -107,8 +108,8 @@ describe("OpenCode Validator", () => {
107
108
  expect(result.valid).toBe(true);
108
109
 
109
110
  if (!result.valid) {
110
- console.log("Fixed opencode.json validation errors:");
111
- result.errors?.forEach(err => console.log(` - ${err}`));
111
+ console.log('Fixed opencode.json validation errors:');
112
+ if (result.errors) for (const error of result.errors) console.log(` - ${error}`);
112
113
  }
113
114
  });
114
115
  });
package/tsconfig.json CHANGED
@@ -11,7 +11,8 @@
11
11
  // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
12
 
13
13
  /* Language and Environment */
14
- "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
14
+ "target": "ES2022",
15
+ "lib": ["ES2022"],
15
16
  // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
17
  // "jsx": "preserve", /* Specify what JSX code is generated. */
17
18
  // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
package/vitest.config.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { defineConfig } from "vitest/config";
1
+ import { defineConfig } from 'vitest/config';
2
2
 
3
3
  export default defineConfig({
4
4
  test: {
5
+ environment: 'node',
5
6
  globals: true,
6
- environment: "node",
7
7
  },
8
8
  });