berget 2.2.6 → 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 +2 -2
- package/.github/workflows/test.yml +10 -4
- package/.husky/pre-commit +1 -0
- package/.prettierignore +15 -0
- package/.prettierrc +7 -3
- package/CONTRIBUTING.md +38 -0
- package/README.md +2 -148
- package/dist/index.js +10 -11
- package/dist/package.json +30 -2
- package/dist/src/agents/app.js +28 -0
- package/dist/src/agents/backend.js +25 -0
- package/dist/src/agents/devops.js +34 -0
- package/dist/src/agents/frontend.js +25 -0
- package/dist/src/agents/fullstack.js +25 -0
- package/dist/src/agents/index.js +61 -0
- package/dist/src/agents/quality.js +70 -0
- package/dist/src/agents/security.js +26 -0
- package/dist/src/agents/types.js +2 -0
- package/dist/src/client.js +97 -117
- package/dist/src/commands/api-keys.js +75 -90
- package/dist/src/commands/auth.js +7 -16
- package/dist/src/commands/autocomplete.js +1 -1
- package/dist/src/commands/billing.js +6 -17
- package/dist/src/commands/chat.js +68 -101
- package/dist/src/commands/clusters.js +9 -18
- package/dist/src/commands/code/__tests__/auth-sync.test.js +351 -0
- package/dist/src/commands/code/__tests__/fake-api-key-service.js +13 -0
- package/dist/src/commands/code/__tests__/fake-auth-service.js +47 -0
- package/dist/src/commands/code/__tests__/fake-command-runner.js +21 -34
- package/dist/src/commands/code/__tests__/fake-file-store.js +20 -33
- package/dist/src/commands/code/__tests__/fake-prompter.js +83 -57
- package/dist/src/commands/code/__tests__/setup-flow.test.js +359 -92
- package/dist/src/commands/code/adapters/clack-prompter.js +15 -22
- package/dist/src/commands/code/adapters/fs-file-store.js +26 -40
- package/dist/src/commands/code/adapters/spawn-command-runner.js +27 -37
- package/dist/src/commands/code/auth-sync.js +270 -0
- package/dist/src/commands/code/errors.js +12 -9
- package/dist/src/commands/code/ports/auth-services.js +2 -0
- package/dist/src/commands/code/setup.js +387 -281
- package/dist/src/commands/code.js +205 -332
- package/dist/src/commands/index.js +5 -5
- package/dist/src/commands/models.js +6 -17
- package/dist/src/commands/users.js +5 -16
- package/dist/src/constants/command-structure.js +104 -104
- package/dist/src/services/api-key-service.js +132 -157
- package/dist/src/services/auth-service.js +89 -342
- package/dist/src/services/browser-auth.js +268 -0
- package/dist/src/services/chat-service.js +371 -401
- package/dist/src/services/cluster-service.js +47 -62
- package/dist/src/services/collaborator-service.js +10 -25
- package/dist/src/services/flux-service.js +14 -29
- package/dist/src/services/helm-service.js +10 -25
- package/dist/src/services/kubectl-service.js +16 -33
- package/dist/src/utils/config-checker.js +3 -3
- package/dist/src/utils/config-loader.js +95 -95
- package/dist/src/utils/default-api-key.js +124 -134
- package/dist/src/utils/env-manager.js +55 -66
- package/dist/src/utils/error-handler.js +20 -21
- package/dist/src/utils/logger.js +72 -65
- package/dist/src/utils/markdown-renderer.js +27 -27
- package/dist/src/utils/opencode-validator.js +63 -68
- package/dist/src/utils/token-manager.js +74 -45
- package/dist/tests/commands/chat.test.js +16 -25
- package/dist/tests/commands/code.test.js +95 -104
- package/dist/tests/utils/config-loader.test.js +48 -48
- package/dist/tests/utils/env-manager.test.js +43 -52
- package/dist/tests/utils/opencode-validator.test.js +22 -21
- package/dist/vitest.config.js +1 -1
- package/eslint.config.mjs +67 -0
- package/index.ts +35 -42
- package/package.json +30 -2
- package/src/agents/app.ts +27 -0
- package/src/agents/backend.ts +24 -0
- package/src/agents/devops.ts +33 -0
- package/src/agents/frontend.ts +24 -0
- package/src/agents/fullstack.ts +24 -0
- package/src/agents/index.ts +73 -0
- package/src/agents/quality.ts +69 -0
- package/src/agents/security.ts +26 -0
- package/src/agents/types.ts +17 -0
- package/src/client.ts +118 -152
- package/src/commands/api-keys.ts +241 -333
- package/src/commands/auth.ts +22 -27
- package/src/commands/autocomplete.ts +9 -9
- package/src/commands/billing.ts +20 -24
- package/src/commands/chat.ts +248 -338
- package/src/commands/clusters.ts +27 -26
- package/src/commands/code/__tests__/auth-sync.test.ts +482 -0
- package/src/commands/code/__tests__/fake-api-key-service.ts +13 -0
- package/src/commands/code/__tests__/fake-auth-service.ts +50 -0
- package/src/commands/code/__tests__/fake-command-runner.ts +45 -42
- package/src/commands/code/__tests__/fake-file-store.ts +32 -23
- package/src/commands/code/__tests__/fake-prompter.ts +116 -77
- package/src/commands/code/__tests__/setup-flow.test.ts +624 -268
- package/src/commands/code/adapters/clack-prompter.ts +53 -39
- package/src/commands/code/adapters/fs-file-store.ts +32 -27
- package/src/commands/code/adapters/spawn-command-runner.ts +38 -29
- package/src/commands/code/auth-sync.ts +329 -0
- package/src/commands/code/errors.ts +18 -18
- package/src/commands/code/ports/auth-services.ts +14 -0
- package/src/commands/code/ports/command-runner.ts +8 -4
- package/src/commands/code/ports/file-store.ts +5 -4
- package/src/commands/code/ports/prompter.ts +24 -18
- package/src/commands/code/setup.ts +570 -340
- package/src/commands/code.ts +338 -539
- package/src/commands/index.ts +20 -19
- package/src/commands/models.ts +28 -32
- package/src/commands/users.ts +15 -21
- package/src/constants/command-structure.ts +134 -157
- package/src/services/api-key-service.ts +105 -122
- package/src/services/auth-service.ts +99 -345
- package/src/services/browser-auth.ts +296 -0
- package/src/services/chat-service.ts +265 -299
- package/src/services/cluster-service.ts +42 -45
- package/src/services/collaborator-service.ts +14 -19
- package/src/services/flux-service.ts +23 -25
- package/src/services/helm-service.ts +19 -21
- package/src/services/kubectl-service.ts +17 -19
- package/src/types/api.d.ts +1905 -1907
- package/src/types/json.d.ts +2 -2
- package/src/utils/config-checker.ts +10 -10
- package/src/utils/config-loader.ts +162 -178
- package/src/utils/default-api-key.ts +114 -125
- package/src/utils/env-manager.ts +53 -57
- package/src/utils/error-handler.ts +61 -56
- package/src/utils/logger.ts +79 -73
- package/src/utils/markdown-renderer.ts +31 -31
- package/src/utils/opencode-validator.ts +85 -89
- package/src/utils/token-manager.ts +108 -87
- package/templates/agents/app.md +1 -0
- package/templates/agents/backend.md +1 -0
- package/templates/agents/devops.md +2 -0
- package/templates/agents/frontend.md +1 -0
- package/templates/agents/fullstack.md +1 -0
- package/templates/agents/quality.md +45 -40
- package/templates/agents/security.md +1 -0
- package/tests/commands/chat.test.ts +53 -62
- package/tests/commands/code.test.ts +265 -310
- package/tests/utils/config-loader.test.ts +189 -188
- package/tests/utils/env-manager.test.ts +110 -113
- package/tests/utils/opencode-validator.test.ts +52 -56
- package/tsconfig.json +4 -3
- package/vitest.config.ts +3 -3
- package/AGENTS.md +0 -374
- package/TODO.md +0 -19
|
@@ -1,15 +1,6 @@
|
|
|
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
|
-
exports.FakePrompter = exports.confirm = exports.select = exports.CANCEL = void 0;
|
|
3
|
+
exports.FakePrompter = exports.multiselect = exports.confirm = exports.text = exports.select = exports.CANCEL = void 0;
|
|
13
4
|
const errors_1 = require("../errors");
|
|
14
5
|
exports.CANCEL = Symbol('cancel');
|
|
15
6
|
const select = (value, match) => ({
|
|
@@ -18,74 +9,109 @@ const select = (value, match) => ({
|
|
|
18
9
|
response: typeof value === 'symbol' ? value : String(value),
|
|
19
10
|
});
|
|
20
11
|
exports.select = select;
|
|
12
|
+
const text = (value, match) => ({
|
|
13
|
+
kind: 'text',
|
|
14
|
+
match: typeof match === 'string' ? new RegExp(match) : match,
|
|
15
|
+
response: value,
|
|
16
|
+
});
|
|
17
|
+
exports.text = text;
|
|
21
18
|
const confirm = (value, match) => ({
|
|
22
19
|
kind: 'confirm',
|
|
23
20
|
match: typeof match === 'string' ? new RegExp(match) : match,
|
|
24
21
|
response: value,
|
|
25
22
|
});
|
|
26
23
|
exports.confirm = confirm;
|
|
24
|
+
const multiselect = (values, match) => ({
|
|
25
|
+
kind: 'multiselect',
|
|
26
|
+
match: typeof match === 'string' ? new RegExp(match) : match,
|
|
27
|
+
response: values === exports.CANCEL ? [exports.CANCEL] : values.map(String),
|
|
28
|
+
});
|
|
29
|
+
exports.multiselect = multiselect;
|
|
27
30
|
class FakePrompter {
|
|
31
|
+
_script;
|
|
32
|
+
get calls() {
|
|
33
|
+
return this._calls;
|
|
34
|
+
}
|
|
35
|
+
_calls = [];
|
|
36
|
+
_cursor = 0;
|
|
28
37
|
constructor(_script) {
|
|
29
38
|
this._script = _script;
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
}
|
|
40
|
+
assertExhausted() {
|
|
41
|
+
if (this._cursor !== this._script.length) {
|
|
42
|
+
throw new Error(`Script not exhausted: ${this._script.length - this._cursor} entries left`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async confirm(options) {
|
|
46
|
+
this._calls.push({ args: options, method: 'confirm' });
|
|
47
|
+
const entry = this._script[this._cursor++];
|
|
48
|
+
if (!entry)
|
|
49
|
+
throw new Error(`No script entry for confirm #${this._cursor} (${options.message})`);
|
|
50
|
+
if (entry.kind !== 'confirm')
|
|
51
|
+
throw new Error(`Expected confirm, got ${entry.kind} for ${options.message}`);
|
|
52
|
+
if (entry.match && !entry.match.test(options.message))
|
|
53
|
+
throw new Error(`Message mismatch: got "${options.message}"`);
|
|
54
|
+
if (entry.response === exports.CANCEL)
|
|
55
|
+
throw new errors_1.CancelledError();
|
|
56
|
+
return entry.response;
|
|
32
57
|
}
|
|
33
58
|
intro(message) {
|
|
34
|
-
this._calls.push({
|
|
59
|
+
this._calls.push({ args: { message }, method: 'intro' });
|
|
35
60
|
}
|
|
36
|
-
|
|
37
|
-
this._calls.push({
|
|
61
|
+
async multiselect(options) {
|
|
62
|
+
this._calls.push({ args: options, method: 'multiselect' });
|
|
63
|
+
const entry = this._script[this._cursor++];
|
|
64
|
+
if (!entry)
|
|
65
|
+
throw new Error(`No script entry for multiselect #${this._cursor} (${options.message})`);
|
|
66
|
+
if (entry.kind !== 'multiselect')
|
|
67
|
+
throw new Error(`Expected multiselect, got ${entry.kind} for ${options.message}`);
|
|
68
|
+
if (entry.match && !entry.match.test(options.message))
|
|
69
|
+
throw new Error(`Message mismatch: got "${options.message}"`);
|
|
70
|
+
if (entry.response.includes(exports.CANCEL))
|
|
71
|
+
throw new errors_1.CancelledError();
|
|
72
|
+
return entry.response;
|
|
38
73
|
}
|
|
39
74
|
note(message, title) {
|
|
40
|
-
this._calls.push({
|
|
75
|
+
this._calls.push({ args: { message, title }, method: 'note' });
|
|
76
|
+
}
|
|
77
|
+
outro(message) {
|
|
78
|
+
this._calls.push({ args: { message }, method: 'outro' });
|
|
79
|
+
}
|
|
80
|
+
async select(options) {
|
|
81
|
+
this._calls.push({ args: options, method: 'select' });
|
|
82
|
+
const entry = this._script[this._cursor++];
|
|
83
|
+
if (!entry)
|
|
84
|
+
throw new Error(`No script entry for select #${this._cursor} (${options.message})`);
|
|
85
|
+
if (entry.kind !== 'select')
|
|
86
|
+
throw new Error(`Expected select, got ${entry.kind} for ${options.message}`);
|
|
87
|
+
if (entry.match && !entry.match.test(options.message))
|
|
88
|
+
throw new Error(`Message mismatch: got "${options.message}"`);
|
|
89
|
+
if (entry.response === exports.CANCEL)
|
|
90
|
+
throw new errors_1.CancelledError();
|
|
91
|
+
return entry.response;
|
|
41
92
|
}
|
|
42
93
|
spinner() {
|
|
43
94
|
return {
|
|
44
|
-
start: (
|
|
45
|
-
this._calls.push({
|
|
95
|
+
start: (message) => {
|
|
96
|
+
this._calls.push({ args: { message: message }, method: 'spinner.start' });
|
|
46
97
|
},
|
|
47
|
-
stop: (
|
|
48
|
-
this._calls.push({
|
|
98
|
+
stop: (message) => {
|
|
99
|
+
this._calls.push({ args: { message: message }, method: 'spinner.stop' });
|
|
49
100
|
},
|
|
50
101
|
};
|
|
51
102
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return entry.response;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
confirm(opts) {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
this._calls.push({ method: 'confirm', args: opts });
|
|
70
|
-
const entry = this._script[this._cursor++];
|
|
71
|
-
if (!entry)
|
|
72
|
-
throw new Error(`No script entry for confirm #${this._cursor} (${opts.message})`);
|
|
73
|
-
if (entry.kind !== 'confirm')
|
|
74
|
-
throw new Error(`Expected select, got confirm for ${opts.message}`);
|
|
75
|
-
if (entry.match && !entry.match.test(opts.message))
|
|
76
|
-
throw new Error(`Message mismatch: got "${opts.message}"`);
|
|
77
|
-
if (entry.response === exports.CANCEL)
|
|
78
|
-
throw new errors_1.CancelledError();
|
|
79
|
-
return entry.response;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
get calls() {
|
|
83
|
-
return this._calls;
|
|
84
|
-
}
|
|
85
|
-
assertExhausted() {
|
|
86
|
-
if (this._cursor !== this._script.length) {
|
|
87
|
-
throw new Error(`Script not exhausted: ${this._script.length - this._cursor} entries left`);
|
|
88
|
-
}
|
|
103
|
+
async text(options) {
|
|
104
|
+
this._calls.push({ args: options, method: 'text' });
|
|
105
|
+
const entry = this._script[this._cursor++];
|
|
106
|
+
if (!entry)
|
|
107
|
+
throw new Error(`No script entry for text #${this._cursor} (${options.message})`);
|
|
108
|
+
if (entry.kind !== 'text')
|
|
109
|
+
throw new Error(`Expected text, got ${entry.kind} for ${options.message}`);
|
|
110
|
+
if (entry.match && !entry.match.test(options.message))
|
|
111
|
+
throw new Error(`Message mismatch: got "${options.message}"`);
|
|
112
|
+
if (entry.response === exports.CANCEL)
|
|
113
|
+
throw new errors_1.CancelledError();
|
|
114
|
+
return entry.response;
|
|
89
115
|
}
|
|
90
116
|
}
|
|
91
117
|
exports.FakePrompter = FakePrompter;
|