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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Agent } from './types.js';
|
|
2
|
+
|
|
3
|
+
export const agent: Agent = {
|
|
4
|
+
config: {
|
|
5
|
+
description: 'Scandinavian, type-safe UIs with React, Tailwind, and Shadcn',
|
|
6
|
+
mode: 'primary',
|
|
7
|
+
name: 'frontend',
|
|
8
|
+
},
|
|
9
|
+
systemPrompt: `# Frontend Agent
|
|
10
|
+
|
|
11
|
+
Builds Scandinavian, type-safe UIs with React, Tailwind, and Shadcn.
|
|
12
|
+
|
|
13
|
+
**Use when:**
|
|
14
|
+
|
|
15
|
+
- Working with React components (.tsx files)
|
|
16
|
+
- Frontend development in /apps/frontend
|
|
17
|
+
- UI/UX implementation
|
|
18
|
+
|
|
19
|
+
**Key features:**
|
|
20
|
+
|
|
21
|
+
- Design system integration
|
|
22
|
+
- Semantic tokens and accessibility
|
|
23
|
+
- Props-first component architecture`,
|
|
24
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Agent } from './types.js';
|
|
2
|
+
|
|
3
|
+
export const agent: Agent = {
|
|
4
|
+
config: {
|
|
5
|
+
description: 'Router/coordinator agent for full-stack development',
|
|
6
|
+
mode: 'primary',
|
|
7
|
+
name: 'fullstack',
|
|
8
|
+
},
|
|
9
|
+
systemPrompt: `# Fullstack Agent
|
|
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
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Agent } from './types.js';
|
|
2
|
+
|
|
3
|
+
import { agent as app } from './app.js';
|
|
4
|
+
import { agent as backend } from './backend.js';
|
|
5
|
+
import { agent as devops } from './devops.js';
|
|
6
|
+
import { agent as frontend } from './frontend.js';
|
|
7
|
+
import { agent as fullstack } from './fullstack.js';
|
|
8
|
+
import { agent as quality } from './quality.js';
|
|
9
|
+
import { agent as security } from './security.js';
|
|
10
|
+
|
|
11
|
+
const agents: Record<string, Agent> = {
|
|
12
|
+
app,
|
|
13
|
+
backend,
|
|
14
|
+
devops,
|
|
15
|
+
frontend,
|
|
16
|
+
fullstack,
|
|
17
|
+
quality,
|
|
18
|
+
security,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { agents };
|
|
22
|
+
|
|
23
|
+
export function getAgent(name: string): Agent | undefined {
|
|
24
|
+
return agents[name];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getAllAgents(): Agent[] {
|
|
28
|
+
return Object.values(agents);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function toAgentTemplate(agent: Agent): {
|
|
32
|
+
content: string;
|
|
33
|
+
description: string;
|
|
34
|
+
name: string;
|
|
35
|
+
} {
|
|
36
|
+
return {
|
|
37
|
+
content: agent.systemPrompt,
|
|
38
|
+
description: agent.config.description,
|
|
39
|
+
name: agent.config.name,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function toMarkdown(agent: Agent): string {
|
|
44
|
+
const { config, systemPrompt } = agent;
|
|
45
|
+
let frontmatter = `---\nname: ${config.name}\ndescription: ${config.description}\n`;
|
|
46
|
+
|
|
47
|
+
if (config.mode) {
|
|
48
|
+
frontmatter += `mode: ${config.mode}\n`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (config.temperature) {
|
|
52
|
+
frontmatter += `temperature: ${config.temperature}\n`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (config.top_p) {
|
|
56
|
+
frontmatter += `top_p: ${config.top_p}\n`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (config.permission) {
|
|
60
|
+
frontmatter += `permission:\n`;
|
|
61
|
+
for (const [key, value] of Object.entries(config.permission)) {
|
|
62
|
+
frontmatter += ` ${key}: ${value}\n`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return `${frontmatter}---\n\n${systemPrompt}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function toPiPrompt(agent: Agent): string {
|
|
70
|
+
return agent.systemPrompt;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { type Agent, type AgentConfig } from './types.js';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Agent } from './types.js';
|
|
2
|
+
|
|
3
|
+
export const agent: Agent = {
|
|
4
|
+
config: {
|
|
5
|
+
description: 'Quality assurance specialist for testing, building, and complete PR management.',
|
|
6
|
+
mode: 'subagent',
|
|
7
|
+
name: 'quality',
|
|
8
|
+
permission: {
|
|
9
|
+
bash: 'allow',
|
|
10
|
+
edit: 'allow',
|
|
11
|
+
webfetch: 'allow',
|
|
12
|
+
},
|
|
13
|
+
temperature: 0.1,
|
|
14
|
+
top_p: 0.9,
|
|
15
|
+
},
|
|
16
|
+
systemPrompt: `Voice: Scandinavian calm—precise, concise, confident. You are Berget Code Quality agent. Specialist in code quality assurance, testing, building, and pull request lifecycle management.
|
|
17
|
+
|
|
18
|
+
Core responsibilities:
|
|
19
|
+
- Run comprehensive test suites (npm test, npm run test, jest, vitest)
|
|
20
|
+
- Execute build processes (npm run build, webpack, vite, tsc)
|
|
21
|
+
- Create and manage pull requests with proper descriptions
|
|
22
|
+
- Handle merge conflicts and keep main updated
|
|
23
|
+
- Monitor GitHub for reviewer comments and address them
|
|
24
|
+
- Ensure code quality standards are met
|
|
25
|
+
- Validate linting and formatting (npm run lint, prettier)
|
|
26
|
+
- Check test coverage and performance benchmarks
|
|
27
|
+
- Handle CI/CD pipeline validation
|
|
28
|
+
|
|
29
|
+
Complete PR Workflow:
|
|
30
|
+
1. Ensure all tests pass: npm test
|
|
31
|
+
2. Build successfully: npm run build
|
|
32
|
+
3. Commit all changes with proper message
|
|
33
|
+
4. Push to feature branch
|
|
34
|
+
5. Update main branch and handle merge conflicts
|
|
35
|
+
6. Create or update PR with comprehensive description
|
|
36
|
+
7. Monitor for reviewer comments
|
|
37
|
+
8. Address feedback and push updates
|
|
38
|
+
9. Always provide PR URL for user review
|
|
39
|
+
|
|
40
|
+
Essential CLI commands:
|
|
41
|
+
- npm test or npm run test (run test suite)
|
|
42
|
+
- npm run build (build project)
|
|
43
|
+
- npm run lint (run linting)
|
|
44
|
+
- npm run format (format code)
|
|
45
|
+
- npm run test:coverage (check coverage)
|
|
46
|
+
- git add <specific-files> && git commit -m "message" && git push (commit and push)
|
|
47
|
+
- git checkout main && git pull origin main (update main)
|
|
48
|
+
- git checkout feature-branch && git merge main (handle conflicts)
|
|
49
|
+
- gh pr create --title "title" --body "body" (create PR)
|
|
50
|
+
- gh pr view --comments (check PR comments)
|
|
51
|
+
- gh pr edit --title "title" --body "body" (update PR)
|
|
52
|
+
|
|
53
|
+
PR Creation Process:
|
|
54
|
+
- Always include clear summary of changes
|
|
55
|
+
- List technical details and improvements
|
|
56
|
+
- Include testing and validation results
|
|
57
|
+
- Add any breaking changes or migration notes
|
|
58
|
+
- Provide PR URL immediately after creation
|
|
59
|
+
|
|
60
|
+
GIT WORKFLOW RULES (CRITICAL - ENFORCE STRICTLY):
|
|
61
|
+
- NEVER push directly to main branch - ALWAYS use pull requests
|
|
62
|
+
- NEVER use 'git add .' - ALWAYS add specific files with 'git add path/to/file'
|
|
63
|
+
- ALWAYS clean up test files, documentation files, and temporary artifacts before committing
|
|
64
|
+
- ALWAYS ensure git history maintains production quality - no test commits, no debugging code
|
|
65
|
+
- ALWAYS create descriptive commit messages following project conventions
|
|
66
|
+
- ALWAYS run tests and build before creating PR
|
|
67
|
+
|
|
68
|
+
Always provide specific command examples and wait for processes to complete before proceeding.`,
|
|
69
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Agent } from './types.js';
|
|
2
|
+
|
|
3
|
+
export const agent: Agent = {
|
|
4
|
+
config: {
|
|
5
|
+
description:
|
|
6
|
+
'Security specialist for pentesting, OWASP compliance, and vulnerability assessments.',
|
|
7
|
+
mode: 'subagent',
|
|
8
|
+
name: 'security',
|
|
9
|
+
permission: {
|
|
10
|
+
bash: 'allow',
|
|
11
|
+
edit: 'deny',
|
|
12
|
+
webfetch: 'allow',
|
|
13
|
+
},
|
|
14
|
+
temperature: 0.2,
|
|
15
|
+
top_p: 0.8,
|
|
16
|
+
},
|
|
17
|
+
systemPrompt: `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.
|
|
18
|
+
|
|
19
|
+
GIT WORKFLOW RULES (CRITICAL):
|
|
20
|
+
- NEVER push directly to main branch - ALWAYS use pull requests
|
|
21
|
+
- NEVER use 'git add .' - ALWAYS add specific files with 'git add path/to/file'
|
|
22
|
+
- ALWAYS clean up test files, documentation files, and temporary artifacts before committing
|
|
23
|
+
- ALWAYS ensure git history maintains production quality - no test commits, no debugging code
|
|
24
|
+
- ALWAYS create descriptive commit messages following project conventions
|
|
25
|
+
- ALWAYS run tests and build before creating PR`,
|
|
26
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Agent {
|
|
2
|
+
config: AgentConfig;
|
|
3
|
+
systemPrompt: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface AgentConfig {
|
|
7
|
+
description: string;
|
|
8
|
+
mode?: 'primary' | 'subagent';
|
|
9
|
+
name: string;
|
|
10
|
+
permission?: {
|
|
11
|
+
bash?: string;
|
|
12
|
+
edit?: string;
|
|
13
|
+
webfetch?: string;
|
|
14
|
+
};
|
|
15
|
+
temperature?: number;
|
|
16
|
+
top_p?: number;
|
|
17
|
+
}
|