berget 2.2.7 → 2.2.8

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 +5 -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 +195 -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 +7 -7
  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 +50 -30
  64. package/index.ts +30 -31
  65. package/package.json +5 -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 +190 -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 +169 -170
  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 +6 -6
  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
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  Object.defineProperty(exports, "__esModule", { value: true });
35
26
  exports.ClackPrompter = void 0;
36
27
  const p = __importStar(require("@clack/prompts"));
@@ -41,41 +32,33 @@ const unwrap = (v) => {
41
32
  return v;
42
33
  };
43
34
  class ClackPrompter {
35
+ async confirm(options) {
36
+ return unwrap(await p.confirm(options));
37
+ }
44
38
  intro(message) {
45
39
  p.intro(message);
46
40
  }
47
- outro(message) {
48
- p.outro(message);
41
+ async multiselect(options) {
42
+ return unwrap(await p.multiselect(options));
49
43
  }
50
44
  note(message, title) {
51
45
  p.note(message, title);
52
46
  }
47
+ outro(message) {
48
+ p.outro(message);
49
+ }
50
+ async select(options) {
51
+ return unwrap(await p.select(options));
52
+ }
53
53
  spinner() {
54
54
  const s = p.spinner();
55
55
  return {
56
- start: (msg) => s.start(msg),
57
- stop: (msg) => s.stop(msg),
56
+ start: (message) => s.start(message),
57
+ stop: (message) => s.stop(message),
58
58
  };
59
59
  }
60
- select(opts) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- return unwrap(yield p.select(opts));
63
- });
64
- }
65
- confirm(opts) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- return unwrap(yield p.confirm(opts));
68
- });
69
- }
70
- text(opts) {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- return unwrap(yield p.text(opts));
73
- });
74
- }
75
- multiselect(opts) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- return unwrap(yield p.multiselect(opts));
78
- });
60
+ async text(options) {
61
+ return unwrap(await p.text(options));
79
62
  }
80
63
  }
81
64
  exports.ClackPrompter = ClackPrompter;
@@ -22,59 +22,40 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  Object.defineProperty(exports, "__esModule", { value: true });
35
26
  exports.FsFileStore = void 0;
36
27
  const node_fs_1 = require("node:fs");
37
28
  const path = __importStar(require("node:path"));
38
29
  class FsFileStore {
39
- exists(filePath) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- try {
42
- yield node_fs_1.promises.access(filePath);
43
- return true;
44
- }
45
- catch (_a) {
46
- return false;
47
- }
48
- });
30
+ async chmod(filePath, mode) {
31
+ await node_fs_1.promises.chmod(filePath, mode);
49
32
  }
50
- readFile(filePath) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- try {
53
- return yield node_fs_1.promises.readFile(filePath, "utf8");
54
- }
55
- catch (err) {
56
- if (err.code === "ENOENT")
57
- return null;
58
- throw err;
59
- }
60
- });
33
+ async exists(filePath) {
34
+ try {
35
+ await node_fs_1.promises.access(filePath);
36
+ return true;
37
+ }
38
+ catch {
39
+ return false;
40
+ }
61
41
  }
62
- writeFile(filePath, content) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- const dir = path.dirname(filePath);
65
- yield node_fs_1.promises.mkdir(dir, { recursive: true });
66
- yield node_fs_1.promises.writeFile(filePath, content, "utf8");
67
- });
42
+ async mkdir(dir) {
43
+ await node_fs_1.promises.mkdir(dir, { recursive: true });
68
44
  }
69
- mkdir(dir) {
70
- return __awaiter(this, void 0, void 0, function* () {
71
- yield node_fs_1.promises.mkdir(dir, { recursive: true });
72
- });
45
+ async readFile(filePath) {
46
+ try {
47
+ return await node_fs_1.promises.readFile(filePath, 'utf8');
48
+ }
49
+ catch (error) {
50
+ if (error.code === 'ENOENT')
51
+ return null;
52
+ throw error;
53
+ }
73
54
  }
74
- chmod(filePath, mode) {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- yield node_fs_1.promises.chmod(filePath, mode);
77
- });
55
+ async writeFile(filePath, content) {
56
+ const dir = path.dirname(filePath);
57
+ await node_fs_1.promises.mkdir(dir, { recursive: true });
58
+ await node_fs_1.promises.writeFile(filePath, content, 'utf8');
78
59
  }
79
60
  }
80
61
  exports.FsFileStore = FsFileStore;
@@ -1,52 +1,38 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.SpawnCommandRunner = void 0;
13
4
  const node_child_process_1 = require("node:child_process");
14
5
  class SpawnCommandRunner {
15
- checkInstalled(binary) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- return new Promise(resolve => {
18
- const child = (0, node_child_process_1.spawn)("which", [binary], { stdio: "pipe" });
19
- child.on("close", code => resolve(code === 0));
20
- child.on("error", () => resolve(false));
21
- });
6
+ async checkInstalled(binary) {
7
+ return new Promise((resolve) => {
8
+ const child = (0, node_child_process_1.spawn)('which', [binary], { stdio: 'pipe' });
9
+ child.on('close', (code) => resolve(code === 0));
10
+ child.on('error', () => resolve(false));
22
11
  });
23
12
  }
24
- run(command, args, options) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- return new Promise((resolve, reject) => {
27
- var _a, _b;
28
- const child = (0, node_child_process_1.spawn)(command, args, {
29
- stdio: "pipe",
30
- cwd: (options === null || options === void 0 ? void 0 : options.cwd) || process.cwd(),
31
- });
32
- let stdout = "";
33
- let stderr = "";
34
- (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on("data", d => {
35
- stdout += d.toString();
36
- });
37
- (_b = child.stderr) === null || _b === void 0 ? void 0 : _b.on("data", d => {
38
- stderr += d.toString();
39
- });
40
- child.on("close", code => {
41
- if (code === 0) {
42
- resolve(stdout);
43
- }
44
- else {
45
- reject(new Error(stderr.trim() || `Command failed with exit code ${code}`));
46
- }
47
- });
48
- child.on("error", err => reject(err));
13
+ async run(command, arguments_, options) {
14
+ return new Promise((resolve, reject) => {
15
+ const child = (0, node_child_process_1.spawn)(command, arguments_, {
16
+ cwd: options?.cwd || process.cwd(),
17
+ stdio: 'pipe',
18
+ });
19
+ let stdout = '';
20
+ let stderr = '';
21
+ child.stdout?.on('data', (d) => {
22
+ stdout += d.toString();
23
+ });
24
+ child.stderr?.on('data', (d) => {
25
+ stderr += d.toString();
26
+ });
27
+ child.on('close', (code) => {
28
+ if (code === 0) {
29
+ resolve(stdout);
30
+ }
31
+ else {
32
+ reject(new Error(stderr.trim() || `Command failed with exit code ${code}`));
33
+ }
49
34
  });
35
+ child.on('error', (error) => reject(error));
50
36
  });
51
37
  }
52
38
  }