berget 2.2.5 → 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.
- package/.github/workflows/publish.yml +8 -8
- package/.github/workflows/test.yml +12 -6
- package/.husky/pre-commit +1 -0
- package/.prettierignore +15 -0
- package/.prettierrc +5 -3
- package/CONTRIBUTING.md +38 -0
- package/README.md +2 -148
- package/dist/index.js +21 -21
- 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 +54 -62
- package/dist/src/commands/api-keys.js +132 -140
- package/dist/src/commands/auth.js +9 -9
- package/dist/src/commands/autocomplete.js +9 -9
- package/dist/src/commands/billing.js +7 -9
- package/dist/src/commands/chat.js +90 -92
- package/dist/src/commands/clusters.js +12 -12
- package/dist/src/commands/code/__tests__/auth-sync.test.js +348 -0
- package/dist/src/commands/code/__tests__/fake-api-key-service.js +23 -0
- package/dist/src/commands/code/__tests__/fake-auth-service.js +55 -0
- package/dist/src/commands/code/__tests__/fake-command-runner.js +50 -0
- package/dist/src/commands/code/__tests__/fake-file-store.js +55 -0
- package/dist/src/commands/code/__tests__/fake-prompter.js +133 -0
- package/dist/src/commands/code/__tests__/setup-flow.test.js +505 -0
- package/dist/src/commands/code/adapters/clack-prompter.js +81 -0
- package/dist/src/commands/code/adapters/fs-file-store.js +80 -0
- package/dist/src/commands/code/adapters/spawn-command-runner.js +53 -0
- package/dist/src/commands/code/auth-sync.js +283 -0
- package/dist/src/commands/code/errors.js +27 -0
- package/dist/src/commands/code/ports/auth-services.js +2 -0
- package/dist/src/commands/code/ports/command-runner.js +2 -0
- package/dist/src/commands/code/ports/file-store.js +2 -0
- package/dist/src/commands/code/ports/prompter.js +2 -0
- package/dist/src/commands/code/setup.js +533 -0
- package/dist/src/commands/code.js +223 -779
- package/dist/src/commands/models.js +13 -15
- package/dist/src/commands/users.js +6 -8
- package/dist/src/constants/command-structure.js +116 -114
- package/dist/src/services/api-key-service.js +43 -48
- package/dist/src/services/auth-service.js +60 -299
- package/dist/src/services/browser-auth.js +278 -0
- package/dist/src/services/chat-service.js +78 -91
- package/dist/src/services/cluster-service.js +6 -6
- package/dist/src/services/collaborator-service.js +5 -8
- package/dist/src/services/flux-service.js +5 -8
- package/dist/src/services/helm-service.js +5 -8
- package/dist/src/services/kubectl-service.js +7 -10
- package/dist/src/utils/config-checker.js +5 -5
- package/dist/src/utils/config-loader.js +25 -25
- package/dist/src/utils/default-api-key.js +23 -23
- package/dist/src/utils/env-manager.js +7 -7
- package/dist/src/utils/error-handler.js +60 -61
- package/dist/src/utils/logger.js +7 -7
- package/dist/src/utils/markdown-renderer.js +2 -2
- package/dist/src/utils/opencode-validator.js +17 -20
- package/dist/src/utils/token-manager.js +38 -11
- package/dist/tests/commands/chat.test.js +24 -24
- package/dist/tests/commands/code.test.js +169 -138
- package/dist/tests/utils/config-loader.test.js +114 -114
- package/dist/tests/utils/env-manager.test.js +57 -57
- package/dist/tests/utils/opencode-validator.test.js +44 -43
- package/dist/vitest.config.js +1 -1
- package/eslint.config.mjs +47 -0
- package/index.ts +42 -48
- 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 +71 -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 +125 -167
- package/src/commands/api-keys.ts +261 -358
- package/src/commands/auth.ts +24 -30
- package/src/commands/autocomplete.ts +12 -12
- package/src/commands/billing.ts +22 -27
- package/src/commands/chat.ts +230 -323
- package/src/commands/clusters.ts +33 -33
- package/src/commands/code/__tests__/auth-sync.test.ts +481 -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 +44 -0
- package/src/commands/code/__tests__/fake-file-store.ts +44 -0
- package/src/commands/code/__tests__/fake-prompter.ts +121 -0
- package/src/commands/code/__tests__/setup-flow.test.ts +628 -0
- package/src/commands/code/adapters/clack-prompter.ts +55 -0
- package/src/commands/code/adapters/fs-file-store.ts +37 -0
- package/src/commands/code/adapters/spawn-command-runner.ts +40 -0
- package/src/commands/code/auth-sync.ts +329 -0
- package/src/commands/code/errors.ts +23 -0
- package/src/commands/code/ports/auth-services.ts +14 -0
- package/src/commands/code/ports/command-runner.ts +10 -0
- package/src/commands/code/ports/file-store.ts +7 -0
- package/src/commands/code/ports/prompter.ts +29 -0
- package/src/commands/code/setup.ts +630 -0
- package/src/commands/code.ts +335 -1074
- package/src/commands/index.ts +19 -19
- package/src/commands/models.ts +32 -37
- package/src/commands/users.ts +15 -22
- package/src/constants/command-structure.ts +120 -140
- package/src/services/api-key-service.ts +96 -113
- package/src/services/auth-service.ts +92 -339
- package/src/services/browser-auth.ts +296 -0
- package/src/services/chat-service.ts +246 -279
- package/src/services/cluster-service.ts +29 -32
- package/src/services/collaborator-service.ts +13 -18
- package/src/services/flux-service.ts +16 -18
- package/src/services/helm-service.ts +16 -18
- package/src/services/kubectl-service.ts +12 -14
- package/src/types/api.d.ts +924 -926
- package/src/types/json.d.ts +3 -3
- package/src/utils/config-checker.ts +10 -10
- package/src/utils/config-loader.ts +110 -127
- package/src/utils/default-api-key.ts +81 -93
- package/src/utils/env-manager.ts +36 -40
- package/src/utils/error-handler.ts +83 -78
- package/src/utils/logger.ts +41 -41
- package/src/utils/markdown-renderer.ts +11 -11
- package/src/utils/opencode-validator.ts +51 -56
- package/src/utils/token-manager.ts +84 -64
- package/templates/agents/app.md +23 -0
- package/templates/agents/backend.md +23 -0
- package/templates/agents/devops.md +30 -0
- package/templates/agents/frontend.md +25 -0
- package/templates/agents/fullstack.md +23 -0
- package/templates/agents/quality.md +69 -0
- package/templates/agents/security.md +21 -0
- package/tests/commands/chat.test.ts +60 -70
- package/tests/commands/code.test.ts +346 -345
- package/tests/utils/config-loader.test.ts +260 -260
- package/tests/utils/env-manager.test.ts +127 -134
- package/tests/utils/opencode-validator.test.ts +65 -69
- package/tsconfig.json +2 -2
- package/vitest.config.ts +3 -3
- package/AGENTS.md +0 -374
- package/TODO.md +0 -19
- package/opencode.json +0 -146
package/AGENTS.md
DELETED
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
# Berget Code Agents
|
|
2
|
-
|
|
3
|
-
This document describes the specialized agents available in this project for use with OpenCode.
|
|
4
|
-
|
|
5
|
-
## Available Agents
|
|
6
|
-
|
|
7
|
-
### Primary Agents
|
|
8
|
-
|
|
9
|
-
#### fullstack
|
|
10
|
-
|
|
11
|
-
Router/coordinator agent for full-stack development with schema-driven architecture. Handles routing between different personas based on file paths and task requirements.
|
|
12
|
-
|
|
13
|
-
**Use when:**
|
|
14
|
-
|
|
15
|
-
- Working across multiple parts of a monorepo
|
|
16
|
-
- Need to coordinate between frontend, backend, devops, and app
|
|
17
|
-
- Starting new projects and need to determine tech stack
|
|
18
|
-
|
|
19
|
-
**Key features:**
|
|
20
|
-
|
|
21
|
-
- Schema-driven development (database → OpenAPI → types)
|
|
22
|
-
- Automatic routing to appropriate persona
|
|
23
|
-
- Tech stack discovery and recommendations
|
|
24
|
-
|
|
25
|
-
#### frontend
|
|
26
|
-
|
|
27
|
-
Builds Scandinavian, type-safe UIs with React, Tailwind, and Shadcn.
|
|
28
|
-
|
|
29
|
-
**Use when:**
|
|
30
|
-
|
|
31
|
-
- Working with React components (.tsx files)
|
|
32
|
-
- Frontend development in /apps/frontend
|
|
33
|
-
- UI/UX implementation
|
|
34
|
-
|
|
35
|
-
**Key features:**
|
|
36
|
-
|
|
37
|
-
- Design system integration
|
|
38
|
-
- Semantic tokens and accessibility
|
|
39
|
-
- Props-first component architecture
|
|
40
|
-
|
|
41
|
-
#### backend
|
|
42
|
-
|
|
43
|
-
Functional, modular Koa + TypeScript services with schema-first approach and code quality focus.
|
|
44
|
-
|
|
45
|
-
**Use when:**
|
|
46
|
-
|
|
47
|
-
- Working with Koa routers and services
|
|
48
|
-
- Backend development in /services
|
|
49
|
-
- API development and database work
|
|
50
|
-
|
|
51
|
-
**Key features:**
|
|
52
|
-
|
|
53
|
-
- Zod validation and OpenAPI generation
|
|
54
|
-
- Code quality and refactoring principles
|
|
55
|
-
- PR workflow integration
|
|
56
|
-
|
|
57
|
-
#### devops
|
|
58
|
-
|
|
59
|
-
# ⚠️ ABSOLUTE RULE: kubectl apply NEVER
|
|
60
|
-
|
|
61
|
-
**THIS RULE HAS NO EXCEPTIONS - APPLIES TO ALL ENVIRONMENTS: DEV, STAGING, PRODUCTION**
|
|
62
|
-
|
|
63
|
-
Declarative GitOps infrastructure with FluxCD, Kustomize, Helm, and operators.
|
|
64
|
-
|
|
65
|
-
**Use when:**
|
|
66
|
-
|
|
67
|
-
- Working with Kubernetes manifests
|
|
68
|
-
- Infrastructure in /infra or /k8s
|
|
69
|
-
- CI/CD and deployment configurations
|
|
70
|
-
|
|
71
|
-
**Key features:**
|
|
72
|
-
|
|
73
|
-
- GitOps workflows
|
|
74
|
-
- Operator-first approach
|
|
75
|
-
- SemVer with release candidates
|
|
76
|
-
|
|
77
|
-
## 🚨 CRITICAL: WHY kubectl apply DESTROYS GITOPS
|
|
78
|
-
|
|
79
|
-
**kubectl apply is fundamentally incompatible with GitOps because it:**
|
|
80
|
-
|
|
81
|
-
1. **Overwrites FluxCD metadata** - The `kubectl.kubernetes.io/last-applied-configuration` annotation gets replaced with kubectl's version, breaking FluxCD's tracking
|
|
82
|
-
2. **Breaks the single source of truth** - Your cluster state diverges from Git state, making Git no longer authoritative
|
|
83
|
-
3. **Creates synchronization conflicts** - FluxCD cannot reconcile differences between Git and cluster state
|
|
84
|
-
4. **Makes debugging impossible** - Manual changes are invisible in Git history
|
|
85
|
-
5. **Undermines the entire GitOps model** - The promise of "Git as source of truth" is broken
|
|
86
|
-
|
|
87
|
-
## 📋 EXACTLY WHAT GETS DESTROYED
|
|
88
|
-
|
|
89
|
-
When you run `kubectl apply`, these critical metadata fields are corrupted:
|
|
90
|
-
|
|
91
|
-
```yaml
|
|
92
|
-
# BEFORE: FluxCD-managed resource
|
|
93
|
-
metadata:
|
|
94
|
-
annotations:
|
|
95
|
-
kubectl.kubernetes.io/last-applied-configuration: |
|
|
96
|
-
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"name":"app","namespace":"default"},"spec":{"template":{"spec":{"containers":[{"image":"nginx:1.21","name":"nginx"}]}}}}
|
|
97
|
-
kustomize.toolkit.fluxcd.io/checksum: a1b2c3d4e5f6
|
|
98
|
-
kustomize.toolkit.fluxcd.io/ssa: Merge
|
|
99
|
-
|
|
100
|
-
# AFTER: kubectl apply destroys this
|
|
101
|
-
metadata:
|
|
102
|
-
annotations:
|
|
103
|
-
kubectl.kubernetes.io/last-applied-configuration: |
|
|
104
|
-
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"name":"app","namespace":"default"},"spec":{"template":{"spec":{"containers":[{"image":"nginx:1.22","name":"nginx"}]}}}}
|
|
105
|
-
# kustomize.toolkit.fluxcd.io/checksum: GONE!
|
|
106
|
-
# kustomize.toolkit.fluxcd.io/ssa: GONE!
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
## 🔥 CONSEQUENCES OF USING kubectl apply
|
|
110
|
-
|
|
111
|
-
**Immediate Impact:**
|
|
112
|
-
- FluxCD loses track of the resource
|
|
113
|
-
- Future Git commits may not apply correctly
|
|
114
|
-
- Resource becomes "orphaned" from GitOps control
|
|
115
|
-
|
|
116
|
-
**Long-term Damage:**
|
|
117
|
-
- Cluster drift becomes undetectable
|
|
118
|
-
- Rollback capabilities are compromised
|
|
119
|
-
- Audit trail is broken
|
|
120
|
-
- Team loses trust in GitOps process
|
|
121
|
-
|
|
122
|
-
**Recovery Required:**
|
|
123
|
-
- Manual intervention to restore FluxCD metadata
|
|
124
|
-
- Potential resource recreation
|
|
125
|
-
- Downtime during recovery
|
|
126
|
-
- Complete audit of affected resources
|
|
127
|
-
|
|
128
|
-
## 🚨 KRITISKA REGLER FÖR FLUXCD-kluster
|
|
129
|
-
|
|
130
|
-
# ⚠️ ABSOLUT ALDRIG: kubectl apply
|
|
131
|
-
|
|
132
|
-
**DENNA REGLER HAR INGA UNDTAG - GÄLLER ALLTID: DEV, STAGING, PRODUCTION**
|
|
133
|
-
|
|
134
|
-
**ABSOLUT ALDRIG använd `kubectl apply` i FluxCD-hanterade kluster!**
|
|
135
|
-
|
|
136
|
-
### ❌ FORBUDNA OPERATIONER
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
# ❌ ALDRIG GÖR DETTA!
|
|
140
|
-
kubectl apply -f deployment.yaml
|
|
141
|
-
kubectl apply -f kustomization.yaml
|
|
142
|
-
kubectl apply -f flux-system/ # SPECIELT INTE FLUXCD-MANIFEST!
|
|
143
|
-
kubectl create -f ...
|
|
144
|
-
kubectl replace -f ...
|
|
145
|
-
kubectl edit deployment/...
|
|
146
|
-
kubectl patch deployment/...
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### ✅ TILLÅTNA OPERATIONER (Read-Only)
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
# ✅ SÄKERT FÖR DIAGNOSTIK
|
|
153
|
-
kubectl get pods
|
|
154
|
-
kubectl describe deployment/app
|
|
155
|
-
kubectl logs -f pod/name
|
|
156
|
-
kubectl get events
|
|
157
|
-
kubectl top nodes
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
### 🔄 RÄTT SÄTT ATT GÖRA ÄNDRINGAR
|
|
161
|
-
|
|
162
|
-
1. **Git är sanningens källa** - alla ändringar måste gå via Git repository
|
|
163
|
-
2. **FluxCD synkroniserar automatiskt** - ändra YAML-filer, inte klustret direkt
|
|
164
|
-
3. **Använd PR workflow** - commit ändringar, skapa PR, låt FluxCD hantera deployment
|
|
165
|
-
|
|
166
|
-
### 🚨 VAD HÄNDER OM DU ÄNDÅ ANVÄNDER kubectl apply?
|
|
167
|
-
|
|
168
|
-
**DET HÄNDER OM DU ANVÄNDER kubectl apply:**
|
|
169
|
-
|
|
170
|
-
- **Förstör FluxCD-metadata** - `kubectl.kubernetes.io/last-applied-configuration` skrivs över
|
|
171
|
-
- **Breakar GitOps-modellen** - klustret divergerar från Git-repository
|
|
172
|
-
- **FluxCD kan inte synkronisera** - konflikter mellan Git-state och kluster-state
|
|
173
|
-
- **Svår att diagnostisera** - manuella ändringar är osynliga i Git-historiken
|
|
174
|
-
|
|
175
|
-
**RESULTATET: FluxCD FÖRLORAR KONTROLLEN OCH KLUSTRET BLIR O-SYNKRONISERAT FRÅN GIT!**
|
|
176
|
-
|
|
177
|
-
### 🆘 NÖDSITUATIONER
|
|
178
|
-
|
|
179
|
-
```bash
|
|
180
|
-
# Pausa FluxCD temporärt
|
|
181
|
-
flux suspend kustomization app-name
|
|
182
|
-
|
|
183
|
-
# Gör nödvändiga ändringar i Git
|
|
184
|
-
git commit -m "emergency fix"
|
|
185
|
-
git push
|
|
186
|
-
|
|
187
|
-
# Återuppta FluxCD
|
|
188
|
-
flux resume kustomization app-name
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### 💡 MINNESREGEL
|
|
192
|
-
|
|
193
|
-
> **"Git first, kubectl never"**
|
|
194
|
-
>
|
|
195
|
-
> Om du måste använda `kubectl apply` - gör det inte. Gör en ändring i Git istället.
|
|
196
|
-
|
|
197
|
-
### 📋 CHECKLIST FÖR ÄNDRINGAR
|
|
198
|
-
|
|
199
|
-
- [ ] Ändring gjord i Git repository?
|
|
200
|
-
- [ ] PR skapad och granskad?
|
|
201
|
-
- [ ] FluxCD synkroniserar korrekt?
|
|
202
|
-
- [ ] Ingen `kubectl apply` använd?
|
|
203
|
-
- [ ] Kluster-state matchar Git-state?
|
|
204
|
-
|
|
205
|
-
**VIKTIGT:** Dessa regler gäller ALLTID, även i utvecklingsmiljöer och tester!
|
|
206
|
-
|
|
207
|
-
### 💡 MINNESREGEL
|
|
208
|
-
|
|
209
|
-
> **"Git first, kubectl never"**
|
|
210
|
-
>
|
|
211
|
-
> Om du måste använda `kubectl apply` - gör det inte. Gör en ändring i Git istället.
|
|
212
|
-
|
|
213
|
-
### 📋 CHECKLIST FÖR ÄNDRINGAR
|
|
214
|
-
|
|
215
|
-
- [ ] Ändring gjord i Git repository?
|
|
216
|
-
- [ ] PR skapad och granskad?
|
|
217
|
-
- [ ] FluxCD synkroniserar korrekt?
|
|
218
|
-
- [ ] Ingen `kubectl apply` använd?
|
|
219
|
-
- [ ] Kluster-state matchar Git-state?
|
|
220
|
-
|
|
221
|
-
**VIKTIGT:** Dessa regler gäller ALLTID, även i utvecklingsmiljöer och tester!
|
|
222
|
-
|
|
223
|
-
---
|
|
224
|
-
|
|
225
|
-
## ⚠️ ABSOLUT SLUTREGEL: INGA UNDTAG
|
|
226
|
-
|
|
227
|
-
**kubectl apply är FÖRBJUDET i ALLA FluxCD-kluster, ALLTID, utan undantag.**
|
|
228
|
-
**Detta inkluderar: dev, staging, production, testmiljöer, lokala kluster, ALLT.**
|
|
229
|
-
|
|
230
|
-
**Helm Values Configuration Process:**
|
|
231
|
-
|
|
232
|
-
1. **Documentation First Approach:**
|
|
233
|
-
- Always fetch official documentation for the specific chart version before writing values
|
|
234
|
-
- Search Artifact Hub for the exact chart version documentation
|
|
235
|
-
- Check the chart's GitHub repository for official docs and examples
|
|
236
|
-
- Verify the exact version being used in the deployment
|
|
237
|
-
|
|
238
|
-
2. **Validation Requirements:**
|
|
239
|
-
- Check for available validation schemas before committing YAML files
|
|
240
|
-
- Use Helm's built-in validation tools (`helm lint`, `helm template`)
|
|
241
|
-
- Validate against JSON schema if available for the chart
|
|
242
|
-
- Ensure YAML syntax correctness with linters
|
|
243
|
-
|
|
244
|
-
3. **Standard Workflow:**
|
|
245
|
-
- Identify chart name and exact version
|
|
246
|
-
- Fetch official documentation from Artifact Hub/GitHub
|
|
247
|
-
- Check for available schemas and validation tools
|
|
248
|
-
- Write values according to official documentation
|
|
249
|
-
- Validate against schema (if available)
|
|
250
|
-
- Test with `helm template` or `helm lint`
|
|
251
|
-
- Commit validated YAML files
|
|
252
|
-
|
|
253
|
-
4. **Quality Assurance:**
|
|
254
|
-
- Never commit unvalidated Helm values
|
|
255
|
-
- Use `helm dependency update` when adding new charts
|
|
256
|
-
- Test rendering with `helm template --dry-run` before deployment
|
|
257
|
-
- Document any custom values with comments referencing official docs
|
|
258
|
-
|
|
259
|
-
#### app
|
|
260
|
-
|
|
261
|
-
Expo + React Native applications with props-first architecture and offline awareness.
|
|
262
|
-
|
|
263
|
-
**Use when:**
|
|
264
|
-
|
|
265
|
-
- Mobile app development with Expo
|
|
266
|
-
- React Native projects in /apps/app
|
|
267
|
-
- Cross-platform mobile development
|
|
268
|
-
|
|
269
|
-
**Key features:**
|
|
270
|
-
|
|
271
|
-
- Shared design tokens with frontend
|
|
272
|
-
- Offline-first architecture
|
|
273
|
-
- Expo integration
|
|
274
|
-
|
|
275
|
-
### Subagents
|
|
276
|
-
|
|
277
|
-
#### security
|
|
278
|
-
|
|
279
|
-
Security specialist for penetration testing, OWASP compliance, and vulnerability assessments.
|
|
280
|
-
|
|
281
|
-
**Use when:**
|
|
282
|
-
|
|
283
|
-
- Need security review of code changes
|
|
284
|
-
- OWASP Top 10 compliance checks
|
|
285
|
-
- Vulnerability assessments
|
|
286
|
-
|
|
287
|
-
**Key features:**
|
|
288
|
-
|
|
289
|
-
- OWASP standards compliance
|
|
290
|
-
- Security best practices
|
|
291
|
-
- Actionable remediation strategies
|
|
292
|
-
|
|
293
|
-
#### quality
|
|
294
|
-
|
|
295
|
-
Quality assurance specialist for testing, building, and PR management.
|
|
296
|
-
|
|
297
|
-
**Use when:**
|
|
298
|
-
|
|
299
|
-
- Need to run test suites and build processes
|
|
300
|
-
- Creating or updating pull requests
|
|
301
|
-
- Monitoring GitHub for reviewer comments
|
|
302
|
-
- Ensuring code quality standards
|
|
303
|
-
|
|
304
|
-
**Key features:**
|
|
305
|
-
|
|
306
|
-
- Comprehensive testing and building workflows
|
|
307
|
-
- PR creation and management
|
|
308
|
-
- GitHub integration for reviewer feedback
|
|
309
|
-
- CLI command expertise for quality assurance
|
|
310
|
-
|
|
311
|
-
## Usage
|
|
312
|
-
|
|
313
|
-
### Switching Agents
|
|
314
|
-
|
|
315
|
-
Use the `<tab>` key to cycle through primary agents during a session.
|
|
316
|
-
|
|
317
|
-
### Manual Agent Selection
|
|
318
|
-
|
|
319
|
-
Use commands to switch to specific agents:
|
|
320
|
-
|
|
321
|
-
- `/fullstack` - Switch to Fullstack agent
|
|
322
|
-
- `/frontend` - Switch to Frontend agent
|
|
323
|
-
- `/backend` - Switch to Backend agent
|
|
324
|
-
- `/devops` - Switch to DevOps agent
|
|
325
|
-
- `/app` - Switch to App agent
|
|
326
|
-
- `/quality` - Switch to Quality agent for testing and PR management
|
|
327
|
-
|
|
328
|
-
### Using Subagents
|
|
329
|
-
|
|
330
|
-
Mention subagents with `@` symbol:
|
|
331
|
-
|
|
332
|
-
```
|
|
333
|
-
@security review this authentication implementation
|
|
334
|
-
@quality run tests and create PR for these changes
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
## Routing Rules
|
|
338
|
-
|
|
339
|
-
The fullstack agent automatically routes tasks based on file patterns:
|
|
340
|
-
|
|
341
|
-
- `/apps/frontend` or `.tsx` files → frontend
|
|
342
|
-
- `/apps/app` or Expo/React Native → app
|
|
343
|
-
- `/infra`, `/k8s`, FluxCD, Helm → devops
|
|
344
|
-
- `/services`, Koa routers → backend
|
|
345
|
-
|
|
346
|
-
## Configuration
|
|
347
|
-
|
|
348
|
-
All agents are configured in `opencode.json` with:
|
|
349
|
-
|
|
350
|
-
- Specialized prompts and temperature settings
|
|
351
|
-
- Appropriate tool permissions
|
|
352
|
-
- Model optimizations for their specific tasks
|
|
353
|
-
|
|
354
|
-
## Environment Setup
|
|
355
|
-
|
|
356
|
-
Copy `.env.example` to `.env` and configure:
|
|
357
|
-
|
|
358
|
-
```
|
|
359
|
-
BERGET_API_KEY=your_api_key_here
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
## Workflow
|
|
363
|
-
|
|
364
|
-
All agents follow these principles:
|
|
365
|
-
|
|
366
|
-
- **NEVER work directly in main branch** - ALWAYS use pull requests
|
|
367
|
-
- **NEVER use 'git add .'** - ALWAYS add specific files with 'git add path/to/file'
|
|
368
|
-
- **ALWAYS clean up test files, documentation files, and temporary artifacts before committing**
|
|
369
|
-
- **ALWAYS ensure git history maintains production quality** - no test commits, no debugging code
|
|
370
|
-
- **ALWAYS create descriptive commit messages following project conventions**
|
|
371
|
-
- **ALWAYS run tests and build before creating PR**
|
|
372
|
-
- Follow branch strategy and commit conventions
|
|
373
|
-
- Create PRs for new functionality
|
|
374
|
-
- Address reviewer feedback promptly
|
package/TODO.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Berget CLI - TODO
|
|
2
|
-
|
|
3
|
-
## Implementerade funktioner
|
|
4
|
-
|
|
5
|
-
- [x] Inloggning med BankID
|
|
6
|
-
- [x] Skapa och hantera API-nycklar
|
|
7
|
-
|
|
8
|
-
## Kommande funktioner
|
|
9
|
-
|
|
10
|
-
- [ ] Implementera riktiga API-anrop för klusterhantering
|
|
11
|
-
- [ ] Implementera riktiga API-anrop för Flux-integration
|
|
12
|
-
- [ ] Implementera riktiga API-anrop för Helm-kommandon
|
|
13
|
-
- [ ] Implementera riktiga API-anrop för Kubectl-kommandon
|
|
14
|
-
- [ ] Implementera riktiga API-anrop för samarbetsfunktioner
|
|
15
|
-
- [ ] Förbättra felhantering och återhämtning
|
|
16
|
-
- [ ] Lägg till enhetstester
|
|
17
|
-
- [ ] Implementera lokal konfigurationshantering
|
|
18
|
-
- [ ] Lägg till stöd för olika miljöer (dev, staging, prod)
|
|
19
|
-
- [ ] Förbättra dokumentation och hjälptexter
|
package/opencode.json
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://opencode.ai/config.json",
|
|
3
|
-
"username": "berget-code",
|
|
4
|
-
"theme": "berget-dark",
|
|
5
|
-
"share": "manual",
|
|
6
|
-
"autoupdate": true,
|
|
7
|
-
"model": "berget/glm-4.7",
|
|
8
|
-
"small_model": "berget/gpt-oss",
|
|
9
|
-
"agent": {
|
|
10
|
-
"fullstack": {
|
|
11
|
-
"model": "berget/glm-4.7",
|
|
12
|
-
"mode": "primary",
|
|
13
|
-
"permission": {
|
|
14
|
-
"edit": "allow",
|
|
15
|
-
"bash": "allow",
|
|
16
|
-
"webfetch": "allow"
|
|
17
|
-
},
|
|
18
|
-
"description": "Router/coordinator agent for full-stack development with schema-driven architecture",
|
|
19
|
-
"prompt": "Voice: Scandinavian calm—precise, concise, confident; no fluff. You are Berget Code Fullstack agent. Act as a router and coordinator in a monorepo. Bottom-up schema: database → OpenAPI → generated types. Top-down types: API → UI → components. Use openapi-fetch and Zod at every boundary; compile-time errors are desired when contracts change. Routing rules: if task/paths match /apps/frontend or React (.tsx) → use frontend; if /apps/app or Expo/React Native → app; if /infra, /k8s, flux-system, kustomization.yaml, Helm values → devops; if /services, Koa routers, services/adapters/domain → backend. If ambiguous, remain fullstack and outline the end-to-end plan, then delegate subtasks to the right persona. Security: validate inputs; secrets via FluxCD SOPS/Sealed Secrets. Documentation is generated from code—never duplicated.\n\nGIT WORKFLOW RULES (CRITICAL):\n- NEVER push directly to main branch - ALWAYS use pull requests\n- NEVER use 'git add .' - ALWAYS add specific files with 'git add path/to/file'\n- ALWAYS clean up test files, documentation files, and temporary artifacts before committing\n- ALWAYS ensure git history maintains production quality - no test commits, no debugging code\n- ALWAYS create descriptive commit messages following project conventions\n- ALWAYS run tests and build before creating PR\n\nCRITICAL: When all implementation tasks are complete and ready for merge, ALWAYS invoke @quality subagent to handle testing, building, and complete PR management including URL provision."
|
|
20
|
-
},
|
|
21
|
-
"frontend": {
|
|
22
|
-
"model": "berget/glm-4.7",
|
|
23
|
-
"mode": "primary",
|
|
24
|
-
"permission": {
|
|
25
|
-
"edit": "allow",
|
|
26
|
-
"bash": "deny",
|
|
27
|
-
"webfetch": "allow"
|
|
28
|
-
},
|
|
29
|
-
"note": "Bash access is denied for frontend persona to prevent shell command execution in UI environments. This restriction enforces security and architectural boundaries.",
|
|
30
|
-
"description": "Builds Scandinavian, type-safe UIs with React, Tailwind, Shadcn.",
|
|
31
|
-
"prompt": "You are Berget Code Frontend agent. Voice: Scandinavian calm—precise, concise, confident. React 18 + TypeScript. Tailwind + Shadcn UI only via the design system (index.css, tailwind.config.ts). Use semantic tokens for color/spacing/typography/motion; never ad-hoc classes or inline colors. Components are pure and responsive; props-first data; minimal global state (Zustand/Jotai). Accessibility and keyboard navigation mandatory. Mock data only at init under /data via typed hooks (e.g., useProducts() reading /data/products.json). Design: minimal, balanced, quiet motion.\\n\\nIMPORTANT: You have NO bash access and cannot run git commands. When your frontend implementation tasks are complete, inform the user that changes are ready and suggest using /pr command to create a pull request with proper testing and quality checks.\\n\\nCODE QUALITY RULES:\\n- Write clean, production-ready code\\n- Follow React and TypeScript best practices\\n- Ensure accessibility and responsive design\\n- Use semantic tokens from design system\\n- Test your components manually when possible\\n- Document any complex logic with comments\\n\\nCRITICAL: When frontend implementation is complete, ALWAYS inform the user to use '/pr' command to handle testing, building, and pull request creation."
|
|
32
|
-
},
|
|
33
|
-
"backend": {
|
|
34
|
-
"model": "berget/glm-4.7",
|
|
35
|
-
"mode": "primary",
|
|
36
|
-
"permission": {
|
|
37
|
-
"edit": "allow",
|
|
38
|
-
"bash": "allow",
|
|
39
|
-
"webfetch": "allow"
|
|
40
|
-
},
|
|
41
|
-
"description": "Functional, modular Koa + TypeScript services; schema-first with code quality focus.",
|
|
42
|
-
"prompt": "You are Berget Code Backend agent. Voice: Scandinavian calm—precise, concise, confident. TypeScript + Koa. Prefer many small pure functions; avoid big try/catch blocks. Routes thin; logic in services/adapters/domain. Validate with Zod; auto-generate OpenAPI. Adapters isolate external systems; domain never depends on framework. Test with supertest; idempotent and stateless by default. Each microservice emits an OpenAPI contract; changes propagate upward to types. Code Quality & Refactoring Principles: Apply Single Responsibility Principle, fail fast with explicit errors, eliminate code duplication, remove nested complexity, use descriptive error codes, keep functions under 30 lines. Always leave code cleaner and more readable than you found it.\n\nGIT WORKFLOW RULES (CRITICAL):\n- NEVER push directly to main branch - ALWAYS use pull requests\n- NEVER use 'git add .' - ALWAYS add specific files with 'git add path/to/file'\n- ALWAYS clean up test files, documentation files, and temporary artifacts before committing\n- ALWAYS ensure git history maintains production quality - no test commits, no debugging code\n- ALWAYS create descriptive commit messages following project conventions\n- ALWAYS run tests and build before creating PR\n\nCRITICAL: When all backend implementation tasks are complete and ready for merge, ALWAYS invoke @quality subagent to handle testing, building, and complete PR management including URL provision."
|
|
43
|
-
},
|
|
44
|
-
"devops": {
|
|
45
|
-
"model": "berget/glm-4.7",
|
|
46
|
-
"mode": "primary",
|
|
47
|
-
"permission": {
|
|
48
|
-
"edit": "allow",
|
|
49
|
-
"bash": "allow",
|
|
50
|
-
"webfetch": "allow"
|
|
51
|
-
},
|
|
52
|
-
"description": "Declarative GitOps infra with FluxCD, Kustomize, Helm, operators.",
|
|
53
|
-
"prompt": "You are Berget Code DevOps agent. Voice: Scandinavian calm—precise, concise, confident. Start simple: k8s/{deployment,service,ingress}. Add FluxCD sync to repo and image automation. Use Kustomize bases/overlays (staging, production). Add dependencies via Helm from upstream sources; prefer native operators when available (CloudNativePG, cert-manager, external-dns). SemVer with -rc tags keeps CI environments current. Observability with Prometheus/Grafana. No manual kubectl in production—Git is the source of truth.\\n\\nGIT WORKFLOW RULES (CRITICAL):\\n- NEVER push directly to main branch - ALWAYS use pull requests\\n- NEVER use 'git add .' - ALWAYS add specific files with 'git add path/to/file'\\n- ALWAYS clean up test files, documentation files, and temporary artifacts before committing\\n- ALWAYS ensure git history maintains production quality - no test commits, no debugging code\\n- ALWAYS create descriptive commit messages following project conventions\\n- ALWAYS run tests and build before creating PR\\n\\nHelm Values Configuration Process:\\\\n1. Documentation First Approach: Always fetch official documentation from Artifact Hub/GitHub for the specific chart version before writing values. Search Artifact Hub for exact chart version documentation, check the chart\\'s GitHub repository for official docs and examples, verify the exact version being used in the deployment.\\\\n2. Validation Requirements: Check for available validation schemas before committing YAML files. Use Helm\\'s built-in validation tools (helm lint, helm template). Validate against JSON schema if available for the chart. Ensure YAML syntax correctness with linters.\\\\n3. Standard Workflow: Identify chart name and exact version. Fetch official documentation from Artifact Hub/GitHub. Check for available schemas and validation tools. Write values according to official documentation. Validate against schema (if available). Test with helm template or helm lint. Commit validated YAML files.\\\\n4. Quality Assurance: Never commit unvalidated Helm values. Use helm dependency update when adding new charts. Test rendering with helm template --dry-run before deployment. Document any custom values with comments referencing official docs."
|
|
54
|
-
},
|
|
55
|
-
"app": {
|
|
56
|
-
"model": "berget/glm-4.7",
|
|
57
|
-
"mode": "primary",
|
|
58
|
-
"permission": {
|
|
59
|
-
"edit": "allow",
|
|
60
|
-
"bash": "deny",
|
|
61
|
-
"webfetch": "allow"
|
|
62
|
-
},
|
|
63
|
-
"note": "Bash access is denied for app persona to prevent shell command execution in mobile/Expo environments. This restriction enforces security and architectural boundaries.",
|
|
64
|
-
"description": "Expo + React Native apps; props-first, offline-aware, shared tokens.",
|
|
65
|
-
"prompt": "You are Berget Code App agent. Voice: Scandinavian calm—precise, concise, confident. Expo + React Native + TypeScript. Structure by components/hooks/services/navigation. Components are pure; data via props; refactor shared logic into hooks/stores. Share tokens with frontend. Mock data in /data via typed hooks; later replace with live APIs. Offline via SQLite/MMKV; notifications via Expo. Request permissions only when needed. Subtle, meaningful motion; light/dark parity.\\n\\nIMPORTANT: You have NO bash access and cannot run git commands. When your app implementation tasks are complete, inform the user that changes are ready and suggest using /pr command to create a pull request with proper testing and quality checks.\\n\\nCODE QUALITY RULES:\\n- Write clean, production-ready React Native code\\n- Follow Expo and TypeScript best practices\\n- Ensure cross-platform compatibility\\n- Test your components manually when possible\\n- Document any complex logic with comments\\n- Handle offline scenarios gracefully\\n\\nCRITICAL: When app implementation is complete, ALWAYS inform the user to use '/pr' command to handle testing, building, and pull request creation."
|
|
66
|
-
},
|
|
67
|
-
"security": {
|
|
68
|
-
"model": "berget/glm-4.7",
|
|
69
|
-
"mode": "subagent",
|
|
70
|
-
"permission": {
|
|
71
|
-
"edit": "deny",
|
|
72
|
-
"bash": "allow",
|
|
73
|
-
"webfetch": "allow"
|
|
74
|
-
},
|
|
75
|
-
"description": "Security specialist for pentesting, OWASP compliance, and vulnerability assessments.",
|
|
76
|
-
"prompt": "Voice: Scandinavian calm—precise, concise, confident. You are Berget Code Security agent. Expert in application security, penetration testing, and OWASP standards. Core responsibilities: Conduct security assessments and penetration tests, Validate OWASP Top 10 compliance, Review code for security vulnerabilities, Implement security headers and Content Security Policy (CSP), Audit API security, Check for sensitive data exposure, Validate input sanitization and output encoding, Assess dependency security and supply chain risks. Tools and techniques: OWASP ZAP, Burp Suite, security linters, dependency scanners, manual code review. Always provide specific, actionable security recommendations with priority levels.\n\nGIT WORKFLOW RULES (CRITICAL):\n- NEVER push directly to main branch - ALWAYS use pull requests\n- NEVER use 'git add .' - ALWAYS add specific files with 'git add path/to/file'\n- ALWAYS clean up test files, documentation files, and temporary artifacts before committing\n- ALWAYS ensure git history maintains production quality - no test commits, no debugging code\n- ALWAYS create descriptive commit messages following project conventions\n- ALWAYS run tests and build before creating PR"
|
|
77
|
-
},
|
|
78
|
-
"quality": {
|
|
79
|
-
"model": "berget/glm-4.7",
|
|
80
|
-
"mode": "subagent",
|
|
81
|
-
"permission": {
|
|
82
|
-
"edit": "allow",
|
|
83
|
-
"bash": "allow",
|
|
84
|
-
"webfetch": "allow"
|
|
85
|
-
},
|
|
86
|
-
"description": "Quality assurance specialist for testing, building, and PR management.",
|
|
87
|
-
"prompt": "Voice: Scandinavian calm—precise, concise, confident. You are Berget Code Quality agent. Specialist in code quality assurance, testing, building, and pull request management.\\n\\nCore responsibilities:\\n - Run comprehensive test suites (npm test, npm run test, jest, vitest)\\n - Execute build processes (npm run build, webpack, vite, tsc)\\n - Create and manage pull requests with proper descriptions\\n - Monitor GitHub for Copilot/reviewer comments\\n - Ensure code quality standards are met\\n - Validate linting and formatting (npm run lint, prettier)\\n - Check test coverage and performance benchmarks\\n - Handle CI/CD pipeline validation\\n\\nGIT WORKFLOW RULES (CRITICAL - ENFORCE STRICTLY):\\n - NEVER push directly to main branch - ALWAYS use pull requests\\n - NEVER use 'git add .' - ALWAYS add specific files with 'git add path/to/file'\\n - ALWAYS clean up test files, documentation files, and temporary artifacts before committing\\n - ALWAYS ensure git history maintains production quality - no test commits, no debugging code\\n - ALWAYS create descriptive commit messages following project conventions\\n - ALWAYS run tests and build before creating PR\\n\\nCommon CLI commands:\\n - npm test or npm run test (run test suite)\\n - npm run build (build project)\\n - npm run lint (run linting)\\n - npm run format (format code)\\n - npm run test:coverage (check coverage)\\n - gh pr create (create pull request)\\n - gh pr view --comments (check PR comments)\\n - git add specific/files && git commit -m \\\"message\\\" && git push (NEVER use git add .)\\n\\nPR Workflow:\\n 1. Ensure all tests pass: npm test\\n 2. Build successfully: npm run build\\n 3. Create/update PR with clear description\\n 4. Monitor for reviewer comments\\n 5. Address feedback promptly\\n 6. Update PR with fixes\\n 7. Ensure CI checks pass\\n\\nAlways provide specific command examples and wait for processes to complete before proceeding."
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
"command": {
|
|
91
|
-
"pr": {
|
|
92
|
-
"description": "Prepare and create a pull request with testing and quality checks",
|
|
93
|
-
"template": "@quality Prepare a pull request for the current changes. Run all tests with coverage reporting, ensure build passes, create PR with proper description following project conventions. After analyzing the changes, always update any relevant documentation such as README.md or other documentation files to reflect the changes made. Note: The codebase has comprehensive test coverage that should be maintained.",
|
|
94
|
-
"agent": "quality"
|
|
95
|
-
},
|
|
96
|
-
"test": {
|
|
97
|
-
"description": "Run tests with coverage and fix any issues or write new tests for current changes",
|
|
98
|
-
"template": "@quality Run the complete test suite with coverage reporting. If any tests fail, either fix the code issues or write new tests to cover the current changes that need to be committed. Ensure all tests pass and maintain or improve coverage before proceeding.",
|
|
99
|
-
"agent": "quality"
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
"watcher": {
|
|
103
|
-
"ignore": ["node_modules", "dist", ".git", "coverage"]
|
|
104
|
-
},
|
|
105
|
-
"provider": {
|
|
106
|
-
"berget": {
|
|
107
|
-
"npm": "@ai-sdk/openai-compatible",
|
|
108
|
-
"name": "Berget AI",
|
|
109
|
-
"options": {
|
|
110
|
-
"baseURL": "https://api.berget.ai/v1"
|
|
111
|
-
},
|
|
112
|
-
"models": {
|
|
113
|
-
"glm-4.7": {
|
|
114
|
-
"name": "GLM-4.7",
|
|
115
|
-
"limit": {
|
|
116
|
-
"output": 4000,
|
|
117
|
-
"context": 200000
|
|
118
|
-
},
|
|
119
|
-
"modalities": {
|
|
120
|
-
"input": ["text"],
|
|
121
|
-
"output": ["text"]
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
"gpt-oss": {
|
|
126
|
-
"name": "GPT-OSS",
|
|
127
|
-
"limit": {
|
|
128
|
-
"output": 4000,
|
|
129
|
-
"context": 128000
|
|
130
|
-
},
|
|
131
|
-
"modalities": {
|
|
132
|
-
"input": ["text", "image"],
|
|
133
|
-
"output": ["text"]
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
"llama-8b": {
|
|
137
|
-
"name": "llama-3.1-8b",
|
|
138
|
-
"limit": {
|
|
139
|
-
"output": 4000,
|
|
140
|
-
"context": 128000
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|