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
@@ -1,12 +1,12 @@
1
- import { createAuthenticatedClient } from "../client";
2
- import { COMMAND_GROUPS, SUBCOMMANDS } from "../constants/command-structure";
1
+ import { createAuthenticatedClient } from '../client';
2
+ import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure';
3
3
 
4
4
  export interface Cluster {
5
+ created: string;
5
6
  id: string;
6
7
  name: string;
7
- status: string;
8
8
  nodes: number;
9
- created: string;
9
+ status: string;
10
10
  }
11
11
 
12
12
  /**
@@ -14,15 +14,15 @@ export interface Cluster {
14
14
  * Command group: clusters
15
15
  */
16
16
  export class ClusterService {
17
- private static instance: ClusterService;
18
- private client = createAuthenticatedClient();
19
-
20
17
  // Command group name for this service
21
18
  public static readonly COMMAND_GROUP = COMMAND_GROUPS.CLUSTERS;
22
-
23
19
  // Subcommands for this service
24
20
  public static readonly COMMANDS = SUBCOMMANDS.CLUSTERS;
25
21
 
22
+ private static instance: ClusterService;
23
+
24
+ private client = createAuthenticatedClient();
25
+
26
26
  private constructor() {}
27
27
 
28
28
  public static getInstance(): ClusterService {
@@ -32,19 +32,35 @@ export class ClusterService {
32
32
  return ClusterService.instance;
33
33
  }
34
34
 
35
+ /**
36
+ * Get detailed information about a cluster
37
+ * Command: berget clusters describe
38
+ */
39
+ public async describe(clusterId: string): Promise<Cluster | null> {
40
+ try {
41
+ // This is a placeholder since the API doesn't have a specific endpoint
42
+ // In a real implementation, this would call a specific endpoint
43
+ const clusters = await this.list();
44
+ return clusters.find((cluster) => cluster.id === clusterId) || null;
45
+ } catch (error) {
46
+ console.error('Failed to describe cluster:', error);
47
+ throw error;
48
+ }
49
+ }
50
+
35
51
  /**
36
52
  * Get resource usage for a cluster
37
53
  * Command: berget clusters get-usage
38
54
  */
39
55
  public async getUsage(clusterId: string): Promise<any> {
40
56
  try {
41
- const { data, error } = await this.client.GET("/v1/clusters/{clusterId}/usage", {
57
+ const { data, error } = await this.client.GET('/v1/clusters/{clusterId}/usage', {
42
58
  params: { path: { clusterId } },
43
59
  });
44
60
  if (error) throw new Error(JSON.stringify(error));
45
61
  return data;
46
62
  } catch (error) {
47
- console.error("Failed to get cluster usage:", error);
63
+ console.error('Failed to get cluster usage:', error);
48
64
  throw error;
49
65
  }
50
66
  }
@@ -55,27 +71,11 @@ export class ClusterService {
55
71
  */
56
72
  public async list(): Promise<Cluster[]> {
57
73
  try {
58
- const { data, error } = await this.client.GET("/v1/clusters");
74
+ const { data, error } = await this.client.GET('/v1/clusters');
59
75
  if (error) throw new Error(JSON.stringify(error));
60
76
  return data?.data || [];
61
77
  } catch (error) {
62
- console.error("Failed to list clusters:", error);
63
- throw error;
64
- }
65
- }
66
-
67
- /**
68
- * Get detailed information about a cluster
69
- * Command: berget clusters describe
70
- */
71
- public async describe(clusterId: string): Promise<Cluster | null> {
72
- try {
73
- // This is a placeholder since the API doesn't have a specific endpoint
74
- // In a real implementation, this would call a specific endpoint
75
- const clusters = await this.list();
76
- return clusters.find(cluster => cluster.id === clusterId) || null;
77
- } catch (error) {
78
- console.error("Failed to describe cluster:", error);
78
+ console.error('Failed to list clusters:', error);
79
79
  throw error;
80
80
  }
81
81
  }
@@ -1,9 +1,9 @@
1
- import { COMMAND_GROUPS, SUBCOMMANDS } from "../constants/command-structure";
1
+ import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure';
2
2
 
3
3
  export interface Collaborator {
4
- username: string;
5
4
  role: string;
6
5
  status: string;
6
+ username: string;
7
7
  }
8
8
 
9
9
  /**
@@ -11,14 +11,14 @@ export interface Collaborator {
11
11
  * Command group: users
12
12
  */
13
13
  export class CollaboratorService {
14
- private static instance: CollaboratorService;
15
-
16
14
  // Command group name for this service
17
15
  public static readonly COMMAND_GROUP = COMMAND_GROUPS.USERS;
18
16
 
19
17
  // Subcommands for this service
20
18
  public static readonly COMMANDS = SUBCOMMANDS.USERS;
21
19
 
20
+ private static instance: CollaboratorService;
21
+
22
22
  private constructor() {}
23
23
 
24
24
  public static getInstance(): CollaboratorService {
@@ -34,7 +34,7 @@ export class CollaboratorService {
34
34
  * This endpoint is not available in the API
35
35
  */
36
36
  public async invite(_clusterId: string, _githubUsername: string): Promise<Collaborator[]> {
37
- throw new Error("This functionality is not available in the API");
37
+ throw new Error('This functionality is not available in the API');
38
38
  }
39
39
 
40
40
  /**
@@ -43,6 +43,6 @@ export class CollaboratorService {
43
43
  * This endpoint is not available in the API
44
44
  */
45
45
  public async list(_clusterId: string): Promise<Collaborator[]> {
46
- throw new Error("This functionality is not available in the API");
46
+ throw new Error('This functionality is not available in the API');
47
47
  }
48
48
  }
@@ -1,15 +1,15 @@
1
- import { COMMAND_GROUPS, SUBCOMMANDS } from "../constants/command-structure";
2
-
3
- export interface FluxInstallOptions {
4
- cluster: string;
5
- }
1
+ import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure';
6
2
 
7
3
  export interface FluxBootstrapOptions {
8
- provider: string;
9
4
  owner?: string;
10
- repository?: string;
11
5
  path?: string;
12
6
  personal?: boolean;
7
+ provider: string;
8
+ repository?: string;
9
+ }
10
+
11
+ export interface FluxInstallOptions {
12
+ cluster: string;
13
13
  }
14
14
 
15
15
  /**
@@ -17,14 +17,14 @@ export interface FluxBootstrapOptions {
17
17
  * Command group: flux
18
18
  */
19
19
  export class FluxService {
20
- private static instance: FluxService;
21
-
22
20
  // Command group name for this service
23
21
  public static readonly COMMAND_GROUP = COMMAND_GROUPS.FLUX;
24
22
 
25
23
  // Subcommands for this service
26
24
  public static readonly COMMANDS = SUBCOMMANDS.FLUX;
27
25
 
26
+ private static instance: FluxService;
27
+
28
28
  private constructor() {}
29
29
 
30
30
  public static getInstance(): FluxService {
@@ -35,20 +35,20 @@ export class FluxService {
35
35
  }
36
36
 
37
37
  /**
38
- * Install Flux CD
39
- * Command: berget flux install
38
+ * Bootstrap Flux CD
39
+ * Command: berget flux bootstrap
40
40
  * This endpoint is not available in the API
41
41
  */
42
- public async install(_options: FluxInstallOptions): Promise<boolean> {
43
- throw new Error("This functionality is not available in the API");
42
+ public async bootstrap(_options: FluxBootstrapOptions): Promise<boolean> {
43
+ throw new Error('This functionality is not available in the API');
44
44
  }
45
45
 
46
46
  /**
47
- * Bootstrap Flux CD
48
- * Command: berget flux bootstrap
47
+ * Install Flux CD
48
+ * Command: berget flux install
49
49
  * This endpoint is not available in the API
50
50
  */
51
- public async bootstrap(_options: FluxBootstrapOptions): Promise<boolean> {
52
- throw new Error("This functionality is not available in the API");
51
+ public async install(_options: FluxInstallOptions): Promise<boolean> {
52
+ throw new Error('This functionality is not available in the API');
53
53
  }
54
54
  }
@@ -1,30 +1,30 @@
1
- import { COMMAND_GROUPS, SUBCOMMANDS } from "../constants/command-structure";
2
-
3
- export interface HelmRepoAddOptions {
4
- name: string;
5
- url: string;
6
- }
1
+ import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure';
7
2
 
8
3
  export interface HelmInstallOptions {
9
- name: string;
10
4
  chart: string;
5
+ name: string;
11
6
  namespace?: string;
12
7
  values?: Record<string, string>;
13
8
  }
14
9
 
10
+ export interface HelmRepoAddOptions {
11
+ name: string;
12
+ url: string;
13
+ }
14
+
15
15
  /**
16
16
  * Service for managing Helm charts
17
17
  * Command group: helm
18
18
  */
19
19
  export class HelmService {
20
- private static instance: HelmService;
21
-
22
20
  // Command group name for this service
23
21
  public static readonly COMMAND_GROUP = COMMAND_GROUPS.HELM;
24
22
 
25
23
  // Subcommands for this service
26
24
  public static readonly COMMANDS = SUBCOMMANDS.HELM;
27
25
 
26
+ private static instance: HelmService;
27
+
28
28
  private constructor() {}
29
29
 
30
30
  public static getInstance(): HelmService {
@@ -40,7 +40,7 @@ export class HelmService {
40
40
  * This endpoint is not available in the API
41
41
  */
42
42
  public async addRepo(_options: HelmRepoAddOptions): Promise<boolean> {
43
- throw new Error("This functionality is not available in the API");
43
+ throw new Error('This functionality is not available in the API');
44
44
  }
45
45
 
46
46
  /**
@@ -49,6 +49,6 @@ export class HelmService {
49
49
  * This endpoint is not available in the API
50
50
  */
51
51
  public async install(_options: HelmInstallOptions): Promise<any> {
52
- throw new Error("This functionality is not available in the API");
52
+ throw new Error('This functionality is not available in the API');
53
53
  }
54
54
  }
@@ -1,18 +1,18 @@
1
- import { COMMAND_GROUPS, SUBCOMMANDS } from "../constants/command-structure";
1
+ import { COMMAND_GROUPS, SUBCOMMANDS } from '../constants/command-structure';
2
2
 
3
3
  /**
4
4
  * Service for managing Kubernetes resources
5
5
  * Command group: kubectl
6
6
  */
7
7
  export class KubectlService {
8
- private static instance: KubectlService;
9
-
10
8
  // Command group name for this service
11
9
  public static readonly COMMAND_GROUP = COMMAND_GROUPS.KUBECTL;
12
10
 
13
11
  // Subcommands for this service
14
12
  public static readonly COMMANDS = SUBCOMMANDS.KUBECTL;
15
13
 
14
+ private static instance: KubectlService;
15
+
16
16
  private constructor() {}
17
17
 
18
18
  public static getInstance(): KubectlService {
@@ -23,21 +23,21 @@ export class KubectlService {
23
23
  }
24
24
 
25
25
  /**
26
- * Create a Kubernetes namespace
27
- * Command: berget kubectl create-namespace
26
+ * Apply a Kubernetes configuration
27
+ * Command: berget kubectl apply
28
28
  * This endpoint is not available in the API
29
29
  */
30
- public async createNamespace(_name: string): Promise<boolean> {
31
- throw new Error("This functionality is not available in the API");
30
+ public async apply(_filename: string): Promise<boolean> {
31
+ throw new Error('This functionality is not available in the API');
32
32
  }
33
33
 
34
34
  /**
35
- * Apply a Kubernetes configuration
36
- * Command: berget kubectl apply
35
+ * Create a Kubernetes namespace
36
+ * Command: berget kubectl create-namespace
37
37
  * This endpoint is not available in the API
38
38
  */
39
- public async apply(_filename: string): Promise<boolean> {
40
- throw new Error("This functionality is not available in the API");
39
+ public async createNamespace(_name: string): Promise<boolean> {
40
+ throw new Error('This functionality is not available in the API');
41
41
  }
42
42
 
43
43
  /**
@@ -46,6 +46,6 @@ export class KubectlService {
46
46
  * This endpoint is not available in the API
47
47
  */
48
48
  public async get(_resource: string, _namespace?: string): Promise<any[]> {
49
- throw new Error("This functionality is not available in the API");
49
+ throw new Error('This functionality is not available in the API');
50
50
  }
51
51
  }