berget 2.2.6 → 2.2.7

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 (144) hide show
  1. package/.github/workflows/publish.yml +6 -6
  2. package/.github/workflows/test.yml +11 -5
  3. package/.husky/pre-commit +1 -0
  4. package/.prettierignore +15 -0
  5. package/.prettierrc +5 -3
  6. package/CONTRIBUTING.md +38 -0
  7. package/README.md +2 -148
  8. package/dist/index.js +21 -21
  9. package/dist/package.json +28 -2
  10. package/dist/src/agents/app.js +28 -0
  11. package/dist/src/agents/backend.js +25 -0
  12. package/dist/src/agents/devops.js +34 -0
  13. package/dist/src/agents/frontend.js +25 -0
  14. package/dist/src/agents/fullstack.js +25 -0
  15. package/dist/src/agents/index.js +61 -0
  16. package/dist/src/agents/quality.js +70 -0
  17. package/dist/src/agents/security.js +26 -0
  18. package/dist/src/agents/types.js +2 -0
  19. package/dist/src/client.js +54 -62
  20. package/dist/src/commands/api-keys.js +132 -140
  21. package/dist/src/commands/auth.js +9 -9
  22. package/dist/src/commands/autocomplete.js +9 -9
  23. package/dist/src/commands/billing.js +7 -9
  24. package/dist/src/commands/chat.js +90 -92
  25. package/dist/src/commands/clusters.js +12 -12
  26. package/dist/src/commands/code/__tests__/auth-sync.test.js +348 -0
  27. package/dist/src/commands/code/__tests__/fake-api-key-service.js +23 -0
  28. package/dist/src/commands/code/__tests__/fake-auth-service.js +55 -0
  29. package/dist/src/commands/code/__tests__/fake-command-runner.js +5 -7
  30. package/dist/src/commands/code/__tests__/fake-file-store.js +9 -0
  31. package/dist/src/commands/code/__tests__/fake-prompter.js +60 -18
  32. package/dist/src/commands/code/__tests__/setup-flow.test.js +374 -107
  33. package/dist/src/commands/code/adapters/clack-prompter.js +10 -0
  34. package/dist/src/commands/code/adapters/fs-file-store.js +8 -3
  35. package/dist/src/commands/code/adapters/spawn-command-runner.js +15 -11
  36. package/dist/src/commands/code/auth-sync.js +283 -0
  37. package/dist/src/commands/code/errors.js +4 -4
  38. package/dist/src/commands/code/ports/auth-services.js +2 -0
  39. package/dist/src/commands/code/setup.js +234 -93
  40. package/dist/src/commands/code.js +139 -251
  41. package/dist/src/commands/models.js +13 -15
  42. package/dist/src/commands/users.js +6 -8
  43. package/dist/src/constants/command-structure.js +116 -116
  44. package/dist/src/services/api-key-service.js +43 -48
  45. package/dist/src/services/auth-service.js +60 -299
  46. package/dist/src/services/browser-auth.js +278 -0
  47. package/dist/src/services/chat-service.js +78 -91
  48. package/dist/src/services/cluster-service.js +6 -6
  49. package/dist/src/services/collaborator-service.js +5 -8
  50. package/dist/src/services/flux-service.js +5 -8
  51. package/dist/src/services/helm-service.js +5 -8
  52. package/dist/src/services/kubectl-service.js +7 -10
  53. package/dist/src/utils/config-checker.js +5 -5
  54. package/dist/src/utils/config-loader.js +25 -25
  55. package/dist/src/utils/default-api-key.js +23 -23
  56. package/dist/src/utils/env-manager.js +7 -7
  57. package/dist/src/utils/error-handler.js +60 -61
  58. package/dist/src/utils/logger.js +7 -7
  59. package/dist/src/utils/markdown-renderer.js +2 -2
  60. package/dist/src/utils/opencode-validator.js +17 -20
  61. package/dist/src/utils/token-manager.js +38 -11
  62. package/dist/tests/commands/chat.test.js +24 -24
  63. package/dist/tests/commands/code.test.js +147 -147
  64. package/dist/tests/utils/config-loader.test.js +114 -114
  65. package/dist/tests/utils/env-manager.test.js +57 -57
  66. package/dist/tests/utils/opencode-validator.test.js +33 -33
  67. package/dist/vitest.config.js +1 -1
  68. package/eslint.config.mjs +47 -0
  69. package/index.ts +42 -48
  70. package/package.json +28 -2
  71. package/src/agents/app.ts +27 -0
  72. package/src/agents/backend.ts +24 -0
  73. package/src/agents/devops.ts +33 -0
  74. package/src/agents/frontend.ts +24 -0
  75. package/src/agents/fullstack.ts +24 -0
  76. package/src/agents/index.ts +71 -0
  77. package/src/agents/quality.ts +69 -0
  78. package/src/agents/security.ts +26 -0
  79. package/src/agents/types.ts +17 -0
  80. package/src/client.ts +125 -167
  81. package/src/commands/api-keys.ts +261 -358
  82. package/src/commands/auth.ts +24 -30
  83. package/src/commands/autocomplete.ts +12 -12
  84. package/src/commands/billing.ts +22 -27
  85. package/src/commands/chat.ts +230 -323
  86. package/src/commands/clusters.ts +33 -33
  87. package/src/commands/code/__tests__/auth-sync.test.ts +481 -0
  88. package/src/commands/code/__tests__/fake-api-key-service.ts +13 -0
  89. package/src/commands/code/__tests__/fake-auth-service.ts +50 -0
  90. package/src/commands/code/__tests__/fake-command-runner.ts +39 -42
  91. package/src/commands/code/__tests__/fake-file-store.ts +32 -23
  92. package/src/commands/code/__tests__/fake-prompter.ts +107 -69
  93. package/src/commands/code/__tests__/setup-flow.test.ts +624 -270
  94. package/src/commands/code/adapters/clack-prompter.ts +50 -38
  95. package/src/commands/code/adapters/fs-file-store.ts +31 -27
  96. package/src/commands/code/adapters/spawn-command-runner.ts +33 -29
  97. package/src/commands/code/auth-sync.ts +329 -0
  98. package/src/commands/code/errors.ts +15 -15
  99. package/src/commands/code/ports/auth-services.ts +14 -0
  100. package/src/commands/code/ports/command-runner.ts +8 -4
  101. package/src/commands/code/ports/file-store.ts +5 -4
  102. package/src/commands/code/ports/prompter.ts +24 -18
  103. package/src/commands/code/setup.ts +545 -317
  104. package/src/commands/code.ts +271 -473
  105. package/src/commands/index.ts +19 -19
  106. package/src/commands/models.ts +32 -37
  107. package/src/commands/users.ts +15 -22
  108. package/src/constants/command-structure.ts +119 -142
  109. package/src/services/api-key-service.ts +96 -113
  110. package/src/services/auth-service.ts +92 -339
  111. package/src/services/browser-auth.ts +296 -0
  112. package/src/services/chat-service.ts +246 -279
  113. package/src/services/cluster-service.ts +29 -32
  114. package/src/services/collaborator-service.ts +13 -18
  115. package/src/services/flux-service.ts +16 -18
  116. package/src/services/helm-service.ts +16 -18
  117. package/src/services/kubectl-service.ts +12 -14
  118. package/src/types/api.d.ts +924 -926
  119. package/src/types/json.d.ts +3 -3
  120. package/src/utils/config-checker.ts +10 -10
  121. package/src/utils/config-loader.ts +110 -127
  122. package/src/utils/default-api-key.ts +81 -93
  123. package/src/utils/env-manager.ts +36 -40
  124. package/src/utils/error-handler.ts +83 -78
  125. package/src/utils/logger.ts +41 -41
  126. package/src/utils/markdown-renderer.ts +11 -11
  127. package/src/utils/opencode-validator.ts +51 -56
  128. package/src/utils/token-manager.ts +84 -64
  129. package/templates/agents/app.md +1 -0
  130. package/templates/agents/backend.md +1 -0
  131. package/templates/agents/devops.md +2 -0
  132. package/templates/agents/frontend.md +1 -0
  133. package/templates/agents/fullstack.md +1 -0
  134. package/templates/agents/quality.md +45 -40
  135. package/templates/agents/security.md +1 -0
  136. package/tests/commands/chat.test.ts +60 -70
  137. package/tests/commands/code.test.ts +330 -376
  138. package/tests/utils/config-loader.test.ts +260 -260
  139. package/tests/utils/env-manager.test.ts +127 -134
  140. package/tests/utils/opencode-validator.test.ts +58 -63
  141. package/tsconfig.json +2 -2
  142. package/vitest.config.ts +3 -3
  143. package/AGENTS.md +0 -374
  144. package/TODO.md +0 -19
@@ -1,8 +1,8 @@
1
- import { Command } from 'commander'
2
- import chalk from 'chalk'
3
- import { AuthService } from '../services/auth-service'
4
- import { clearAuthToken } from '../client'
5
- import { handleError } from '../utils/error-handler'
1
+ import { Command } from "commander";
2
+ import chalk from "chalk";
3
+ import { AuthService } from "../services/auth-service";
4
+ import { clearAuthToken } from "../client";
5
+ import { handleError } from "../utils/error-handler";
6
6
 
7
7
  /**
8
8
  * Register authentication commands
@@ -10,51 +10,45 @@ import { handleError } from '../utils/error-handler'
10
10
  export function registerAuthCommands(program: Command): void {
11
11
  const auth = program
12
12
  .command(AuthService.COMMAND_GROUP)
13
- .description('Manage authentication and authorization')
13
+ .description("Manage authentication and authorization");
14
14
 
15
15
  auth
16
16
  .command(AuthService.COMMANDS.LOGIN)
17
- .description('Log in to Berget')
17
+ .description("Log in to Berget")
18
18
  .action(async () => {
19
- const authService = AuthService.getInstance()
20
- await authService.login()
21
- })
19
+ const authService = AuthService.getInstance();
20
+ await authService.login();
21
+ });
22
22
 
23
23
  auth
24
24
  .command(AuthService.COMMANDS.LOGOUT)
25
- .description('Log out from Berget')
25
+ .description("Log out from Berget")
26
26
  .action(() => {
27
- clearAuthToken()
28
- console.log(chalk.green('You have been logged out from Berget'))
29
- })
27
+ clearAuthToken();
28
+ console.log(chalk.green("You have been logged out from Berget"));
29
+ });
30
30
 
31
31
  auth
32
32
  .command(AuthService.COMMANDS.WHOAMI)
33
- .description('Show information about the logged in user')
33
+ .description("Show information about the logged in user")
34
34
  .action(async () => {
35
35
  try {
36
- const authService = AuthService.getInstance()
37
- const profile = await authService.whoami()
36
+ const authService = AuthService.getInstance();
37
+ const profile = await authService.whoami();
38
38
 
39
39
  if (profile) {
40
- console.log(
41
- chalk.bold(`Logged in as: ${profile.name || profile.login}`),
42
- )
43
- console.log(`Email: ${chalk.cyan(profile.email || 'Not available')}`)
44
- console.log(`Role: ${chalk.cyan(profile.role || 'Not available')}`)
40
+ console.log(chalk.bold(`Logged in as: ${profile.name || profile.login}`));
41
+ console.log(`Email: ${chalk.cyan(profile.email || "Not available")}`);
42
+ console.log(`Role: ${chalk.cyan(profile.role || "Not available")}`);
45
43
 
46
44
  if (profile.company) {
47
- console.log(`Company: ${chalk.cyan(profile.company.name)}`)
45
+ console.log(`Company: ${chalk.cyan(profile.company.name)}`);
48
46
  }
49
47
  } else {
50
- console.log(
51
- chalk.yellow(
52
- 'You are not logged in. Use `berget login` to log in.',
53
- ),
54
- )
48
+ console.log(chalk.yellow("You are not logged in. Use `berget login` to log in."));
55
49
  }
56
50
  } catch (error) {
57
- handleError('You are not logged in or an error occurred', error)
51
+ handleError("You are not logged in or an error occurred", error);
58
52
  }
59
- })
53
+ });
60
54
  }
@@ -1,19 +1,19 @@
1
- import { Command } from 'commander'
2
- import chalk from 'chalk'
1
+ import { Command } from "commander";
2
+ import chalk from "chalk";
3
3
 
4
4
  /**
5
5
  * Register autocomplete commands
6
6
  */
7
7
  export function registerAutocompleteCommands(program: Command): void {
8
- const autocomplete = program
9
- .command('autocomplete')
10
- .command('install')
11
- .description('Install shell autocompletion')
8
+ program
9
+ .command("autocomplete")
10
+ .command("install")
11
+ .description("Install shell autocompletion")
12
12
  .action(() => {
13
- console.log(chalk.green('✓ Berget autocomplete installed in your shell'))
14
- console.log(chalk.green('✓ Shell completion for kubectl also installed'))
15
- console.log('')
16
- console.log('Restart your shell or run:')
17
- console.log(' source ~/.bashrc')
18
- })
13
+ console.log(chalk.green("✓ Berget autocomplete installed in your shell"));
14
+ console.log(chalk.green("✓ Shell completion for kubectl also installed"));
15
+ console.log("");
16
+ console.log("Restart your shell or run:");
17
+ console.log(" source ~/.bashrc");
18
+ });
19
19
  }
@@ -1,44 +1,39 @@
1
- import { Command } from 'commander'
2
- import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure'
3
- import { createAuthenticatedClient } from '../client'
4
- import { handleError } from '../utils/error-handler'
1
+ import { Command } from "commander";
2
+ import { COMMAND_GROUPS, SUBCOMMANDS } from "../constants/command-structure";
3
+ import { createAuthenticatedClient } from "../client";
4
+ import { handleError } from "../utils/error-handler";
5
5
 
6
6
  /**
7
7
  * Register billing commands
8
8
  */
9
9
  export function registerBillingCommands(program: Command): void {
10
- const billing = program
11
- .command(COMMAND_GROUPS.BILLING)
12
- .description('Manage billing and usage')
10
+ const billing = program.command(COMMAND_GROUPS.BILLING).description("Manage billing and usage");
13
11
 
14
12
  billing
15
13
  .command(SUBCOMMANDS.BILLING.GET_USAGE)
16
- .description('Get token usage statistics')
17
- .option('--model <modelId>', 'Get usage for a specific model')
18
- .action(async (options) => {
14
+ .description("Get token usage statistics")
15
+ .option("--model <modelId>", "Get usage for a specific model")
16
+ .action(async options => {
19
17
  try {
20
- const client = createAuthenticatedClient()
21
- let response
18
+ const client = createAuthenticatedClient();
19
+ let response;
22
20
 
23
21
  if (options.model) {
24
- const { data, error } = await client.GET(
25
- '/v1/usage/tokens/{modelId}',
26
- {
27
- params: { path: { modelId: options.model } },
28
- },
29
- )
30
- if (error) throw new Error(JSON.stringify(error))
31
- response = data
22
+ const { data, error } = await client.GET("/v1/usage/tokens/{modelId}", {
23
+ params: { path: { modelId: options.model } },
24
+ });
25
+ if (error) throw new Error(JSON.stringify(error));
26
+ response = data;
32
27
  } else {
33
- const { data, error } = await client.GET('/v1/usage/tokens')
34
- if (error) throw new Error(JSON.stringify(error))
35
- response = data
28
+ const { data, error } = await client.GET("/v1/usage/tokens");
29
+ if (error) throw new Error(JSON.stringify(error));
30
+ response = data;
36
31
  }
37
32
 
38
- console.log('Token Usage:')
39
- console.log(JSON.stringify(response, null, 2))
33
+ console.log("Token Usage:");
34
+ console.log(JSON.stringify(response, null, 2));
40
35
  } catch (error) {
41
- handleError('Failed to get token usage', error)
36
+ handleError("Failed to get token usage", error);
42
37
  }
43
- })
38
+ });
44
39
  }