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.
- package/.github/workflows/publish.yml +6 -6
- package/.github/workflows/test.yml +1 -1
- package/.prettierrc +5 -3
- package/dist/index.js +24 -25
- package/dist/package.json +5 -3
- package/dist/src/agents/app.js +8 -8
- package/dist/src/agents/backend.js +3 -3
- package/dist/src/agents/devops.js +8 -8
- package/dist/src/agents/frontend.js +3 -3
- package/dist/src/agents/fullstack.js +3 -3
- package/dist/src/agents/index.js +18 -18
- package/dist/src/agents/quality.js +8 -8
- package/dist/src/agents/security.js +8 -8
- package/dist/src/client.js +115 -127
- package/dist/src/commands/api-keys.js +195 -202
- package/dist/src/commands/auth.js +16 -25
- package/dist/src/commands/autocomplete.js +8 -8
- package/dist/src/commands/billing.js +10 -19
- package/dist/src/commands/chat.js +139 -170
- package/dist/src/commands/clusters.js +21 -30
- package/dist/src/commands/code/__tests__/auth-sync.test.js +189 -186
- package/dist/src/commands/code/__tests__/fake-api-key-service.js +3 -13
- package/dist/src/commands/code/__tests__/fake-auth-service.js +21 -29
- package/dist/src/commands/code/__tests__/fake-command-runner.js +22 -33
- package/dist/src/commands/code/__tests__/fake-file-store.js +19 -41
- package/dist/src/commands/code/__tests__/fake-prompter.js +81 -97
- package/dist/src/commands/code/__tests__/setup-flow.test.js +295 -295
- package/dist/src/commands/code/adapters/clack-prompter.js +15 -32
- package/dist/src/commands/code/adapters/fs-file-store.js +25 -44
- package/dist/src/commands/code/adapters/spawn-command-runner.js +27 -41
- package/dist/src/commands/code/auth-sync.js +215 -228
- package/dist/src/commands/code/errors.js +15 -12
- package/dist/src/commands/code/setup.js +390 -425
- package/dist/src/commands/code.js +279 -294
- package/dist/src/commands/index.js +5 -5
- package/dist/src/commands/models.js +16 -25
- package/dist/src/commands/users.js +9 -18
- package/dist/src/constants/command-structure.js +138 -138
- package/dist/src/services/api-key-service.js +132 -152
- package/dist/src/services/auth-service.js +81 -95
- package/dist/src/services/browser-auth.js +121 -131
- package/dist/src/services/chat-service.js +369 -386
- package/dist/src/services/cluster-service.js +47 -62
- package/dist/src/services/collaborator-service.js +9 -21
- package/dist/src/services/flux-service.js +13 -25
- package/dist/src/services/helm-service.js +9 -21
- package/dist/src/services/kubectl-service.js +15 -29
- package/dist/src/utils/config-checker.js +7 -7
- package/dist/src/utils/config-loader.js +109 -109
- package/dist/src/utils/default-api-key.js +129 -139
- package/dist/src/utils/env-manager.js +55 -66
- package/dist/src/utils/error-handler.js +62 -62
- package/dist/src/utils/logger.js +74 -67
- package/dist/src/utils/markdown-renderer.js +28 -28
- package/dist/src/utils/opencode-validator.js +67 -69
- package/dist/src/utils/token-manager.js +67 -65
- package/dist/tests/commands/chat.test.js +30 -39
- package/dist/tests/commands/code.test.js +186 -195
- package/dist/tests/utils/config-loader.test.js +107 -107
- package/dist/tests/utils/env-manager.test.js +81 -90
- package/dist/tests/utils/opencode-validator.test.js +42 -41
- package/dist/vitest.config.js +1 -1
- package/eslint.config.mjs +50 -30
- package/index.ts +30 -31
- package/package.json +5 -3
- package/src/agents/app.ts +9 -9
- package/src/agents/backend.ts +4 -4
- package/src/agents/devops.ts +9 -9
- package/src/agents/frontend.ts +4 -4
- package/src/agents/fullstack.ts +4 -4
- package/src/agents/index.ts +27 -25
- package/src/agents/quality.ts +9 -9
- package/src/agents/security.ts +9 -9
- package/src/agents/types.ts +10 -10
- package/src/client.ts +85 -77
- package/src/commands/api-keys.ts +190 -185
- package/src/commands/auth.ts +15 -14
- package/src/commands/autocomplete.ts +10 -10
- package/src/commands/billing.ts +13 -12
- package/src/commands/chat.ts +145 -142
- package/src/commands/clusters.ts +20 -19
- package/src/commands/code/__tests__/auth-sync.test.ts +176 -175
- package/src/commands/code/__tests__/fake-api-key-service.ts +2 -2
- package/src/commands/code/__tests__/fake-auth-service.ts +18 -18
- package/src/commands/code/__tests__/fake-command-runner.ts +28 -22
- package/src/commands/code/__tests__/fake-file-store.ts +15 -15
- package/src/commands/code/__tests__/fake-prompter.ts +86 -85
- package/src/commands/code/__tests__/setup-flow.test.ts +253 -251
- package/src/commands/code/adapters/clack-prompter.ts +32 -30
- package/src/commands/code/adapters/fs-file-store.ts +18 -17
- package/src/commands/code/adapters/spawn-command-runner.ts +20 -15
- package/src/commands/code/auth-sync.ts +210 -210
- package/src/commands/code/errors.ts +11 -11
- package/src/commands/code/ports/auth-services.ts +7 -7
- package/src/commands/code/ports/command-runner.ts +2 -2
- package/src/commands/code/ports/file-store.ts +3 -3
- package/src/commands/code/ports/prompter.ts +13 -13
- package/src/commands/code/setup.ts +408 -406
- package/src/commands/code.ts +288 -287
- package/src/commands/index.ts +11 -10
- package/src/commands/models.ts +19 -18
- package/src/commands/users.ts +11 -10
- package/src/constants/command-structure.ts +159 -159
- package/src/services/api-key-service.ts +85 -85
- package/src/services/auth-service.ts +55 -54
- package/src/services/browser-auth.ts +62 -62
- package/src/services/chat-service.ts +169 -170
- package/src/services/cluster-service.ts +28 -28
- package/src/services/collaborator-service.ts +6 -6
- package/src/services/flux-service.ts +17 -17
- package/src/services/helm-service.ts +11 -11
- package/src/services/kubectl-service.ts +12 -12
- package/src/types/api.d.ts +1933 -1933
- package/src/types/json.d.ts +1 -1
- package/src/utils/config-checker.ts +6 -6
- package/src/utils/config-loader.ts +130 -129
- package/src/utils/default-api-key.ts +81 -80
- package/src/utils/env-manager.ts +37 -37
- package/src/utils/error-handler.ts +64 -64
- package/src/utils/logger.ts +72 -66
- package/src/utils/markdown-renderer.ts +28 -28
- package/src/utils/opencode-validator.ts +72 -71
- package/src/utils/token-manager.ts +69 -68
- package/tests/commands/chat.test.ts +32 -31
- package/tests/commands/code.test.ts +182 -181
- package/tests/utils/config-loader.test.ts +111 -110
- package/tests/utils/env-manager.test.ts +83 -79
- package/tests/utils/opencode-validator.test.ts +43 -42
- package/tsconfig.json +2 -1
- package/vitest.config.ts +2 -2
|
@@ -1,55 +1,57 @@
|
|
|
1
|
-
import * as p from
|
|
2
|
-
import { CancelledError } from "../errors";
|
|
3
|
-
import type { Prompter, Spinner } from "../ports/prompter";
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
import type { Prompter, Spinner } from '../ports/prompter';
|
|
4
|
+
|
|
5
|
+
import { CancelledError } from '../errors';
|
|
6
|
+
|
|
7
|
+
const unwrap = <T>(v: symbol | T): T => {
|
|
6
8
|
if (p.isCancel(v)) throw new CancelledError();
|
|
7
9
|
return v as T;
|
|
8
10
|
};
|
|
9
11
|
|
|
10
12
|
export class ClackPrompter implements Prompter {
|
|
13
|
+
async confirm(options: { initialValue?: boolean; message: string }): Promise<boolean> {
|
|
14
|
+
return unwrap(await p.confirm(options));
|
|
15
|
+
}
|
|
11
16
|
intro(message: string): void {
|
|
12
17
|
p.intro(message);
|
|
13
18
|
}
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
async multiselect<T>(options: {
|
|
20
|
+
message: string;
|
|
21
|
+
options: ReadonlyArray<{
|
|
22
|
+
hint?: string;
|
|
23
|
+
label: string;
|
|
24
|
+
value: T;
|
|
25
|
+
}>;
|
|
26
|
+
}): Promise<T[]> {
|
|
27
|
+
return unwrap(await p.multiselect(options as any));
|
|
16
28
|
}
|
|
17
29
|
note(message: string, title?: string): void {
|
|
18
30
|
p.note(message, title);
|
|
19
31
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
start: (msg: string) => s.start(msg),
|
|
24
|
-
stop: (msg: string) => s.stop(msg),
|
|
25
|
-
};
|
|
32
|
+
outro(message: string): void {
|
|
33
|
+
p.outro(message);
|
|
26
34
|
}
|
|
27
|
-
async select<T>(
|
|
35
|
+
async select<T>(options: {
|
|
28
36
|
message: string;
|
|
29
37
|
options: ReadonlyArray<{
|
|
30
|
-
value: T;
|
|
31
|
-
label: string;
|
|
32
38
|
hint?: string;
|
|
39
|
+
label: string;
|
|
40
|
+
value: T;
|
|
33
41
|
}>;
|
|
34
42
|
}): Promise<T> {
|
|
35
|
-
return unwrap(await p.select(
|
|
36
|
-
}
|
|
37
|
-
async confirm(opts: { message: string; initialValue?: boolean }): Promise<boolean> {
|
|
38
|
-
return unwrap(await p.confirm(opts));
|
|
43
|
+
return unwrap(await p.select(options as any));
|
|
39
44
|
}
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
spinner(): Spinner {
|
|
47
|
+
const s = p.spinner();
|
|
48
|
+
return {
|
|
49
|
+
start: (message: string) => s.start(message),
|
|
50
|
+
stop: (message: string) => s.stop(message),
|
|
51
|
+
};
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
async
|
|
46
|
-
|
|
47
|
-
options: ReadonlyArray<{
|
|
48
|
-
value: T;
|
|
49
|
-
label: string;
|
|
50
|
-
hint?: string;
|
|
51
|
-
}>;
|
|
52
|
-
}): Promise<T[]> {
|
|
53
|
-
return unwrap(await p.multiselect(opts as any));
|
|
54
|
+
async text(options: { message: string; placeholder?: string }): Promise<string> {
|
|
55
|
+
return unwrap(await p.text(options));
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { promises as fs } from
|
|
2
|
-
import * as path from
|
|
3
|
-
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import type { FileStore } from '../ports/file-store';
|
|
4
5
|
|
|
5
6
|
export class FsFileStore implements FileStore {
|
|
7
|
+
async chmod(filePath: string, mode: number): Promise<void> {
|
|
8
|
+
await fs.chmod(filePath, mode);
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
async exists(filePath: string): Promise<boolean> {
|
|
7
12
|
try {
|
|
8
13
|
await fs.access(filePath);
|
|
@@ -12,26 +17,22 @@ export class FsFileStore implements FileStore {
|
|
|
12
17
|
}
|
|
13
18
|
}
|
|
14
19
|
|
|
15
|
-
async
|
|
20
|
+
async mkdir(dir: string): Promise<void> {
|
|
21
|
+
await fs.mkdir(dir, { recursive: true });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async readFile(filePath: string): Promise<null | string> {
|
|
16
25
|
try {
|
|
17
|
-
return await fs.readFile(filePath,
|
|
18
|
-
} catch (
|
|
19
|
-
if (
|
|
20
|
-
throw
|
|
26
|
+
return await fs.readFile(filePath, 'utf8');
|
|
27
|
+
} catch (error: any) {
|
|
28
|
+
if (error.code === 'ENOENT') return null;
|
|
29
|
+
throw error;
|
|
21
30
|
}
|
|
22
31
|
}
|
|
23
32
|
|
|
24
33
|
async writeFile(filePath: string, content: string): Promise<void> {
|
|
25
34
|
const dir = path.dirname(filePath);
|
|
26
35
|
await fs.mkdir(dir, { recursive: true });
|
|
27
|
-
await fs.writeFile(filePath, content,
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async mkdir(dir: string): Promise<void> {
|
|
31
|
-
await fs.mkdir(dir, { recursive: true });
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async chmod(filePath: string, mode: number): Promise<void> {
|
|
35
|
-
await fs.chmod(filePath, mode);
|
|
36
|
+
await fs.writeFile(filePath, content, 'utf8');
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -1,40 +1,45 @@
|
|
|
1
|
-
import { spawn } from
|
|
2
|
-
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
import type { CommandRunner } from '../ports/command-runner';
|
|
3
4
|
|
|
4
5
|
export class SpawnCommandRunner implements CommandRunner {
|
|
5
6
|
async checkInstalled(binary: string): Promise<boolean> {
|
|
6
|
-
return new Promise(resolve => {
|
|
7
|
-
const child = spawn(
|
|
8
|
-
child.on(
|
|
9
|
-
child.on(
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
const child = spawn('which', [binary], { stdio: 'pipe' });
|
|
9
|
+
child.on('close', (code) => resolve(code === 0));
|
|
10
|
+
child.on('error', () => resolve(false));
|
|
10
11
|
});
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
async run(
|
|
14
|
+
async run(
|
|
15
|
+
command: string,
|
|
16
|
+
arguments_: readonly string[],
|
|
17
|
+
options?: { cwd?: string },
|
|
18
|
+
): Promise<string> {
|
|
14
19
|
return new Promise<string>((resolve, reject) => {
|
|
15
|
-
const child = spawn(command,
|
|
16
|
-
stdio: "pipe",
|
|
20
|
+
const child = spawn(command, arguments_ as string[], {
|
|
17
21
|
cwd: options?.cwd || process.cwd(),
|
|
22
|
+
stdio: 'pipe',
|
|
18
23
|
});
|
|
19
24
|
|
|
20
|
-
let stdout =
|
|
21
|
-
let stderr =
|
|
25
|
+
let stdout = '';
|
|
26
|
+
let stderr = '';
|
|
22
27
|
|
|
23
|
-
child.stdout?.on(
|
|
28
|
+
child.stdout?.on('data', (d) => {
|
|
24
29
|
stdout += d.toString();
|
|
25
30
|
});
|
|
26
|
-
child.stderr?.on(
|
|
31
|
+
child.stderr?.on('data', (d) => {
|
|
27
32
|
stderr += d.toString();
|
|
28
33
|
});
|
|
29
34
|
|
|
30
|
-
child.on(
|
|
35
|
+
child.on('close', (code) => {
|
|
31
36
|
if (code === 0) {
|
|
32
37
|
resolve(stdout);
|
|
33
38
|
} else {
|
|
34
39
|
reject(new Error(stderr.trim() || `Command failed with exit code ${code}`));
|
|
35
40
|
}
|
|
36
41
|
});
|
|
37
|
-
child.on(
|
|
42
|
+
child.on('error', (error) => reject(error));
|
|
38
43
|
});
|
|
39
44
|
}
|
|
40
45
|
}
|