@wipal/agent-team 1.0.0

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 (89) hide show
  1. package/.claude/rules/common/general-rules.md +141 -0
  2. package/.claude/rules/lessons/lessons.md +91 -0
  3. package/.claude/rules/role-rules/dev-fe-rules.md +146 -0
  4. package/.claude/rules/role-rules/sa-rules.md +226 -0
  5. package/.claude/skills/SKILL-INDEX.md +299 -0
  6. package/.claude/skills/community/security-validator/SKILL.md +392 -0
  7. package/.claude/skills/core/agent-creation/SKILL.md +338 -0
  8. package/.claude/skills/core/code-review/SKILL.md +154 -0
  9. package/.claude/skills/core/git-automation/SKILL.md +93 -0
  10. package/.claude/skills/core/retrospect-work/SKILL.md +172 -0
  11. package/.claude/skills/domain/architecture/adr-writing/SKILL.md +254 -0
  12. package/.claude/skills/domain/architecture/adr-writing/references/adr-best-practices.md +257 -0
  13. package/.claude/skills/domain/architecture/adr-writing/references/adr-examples.md +246 -0
  14. package/.claude/skills/domain/architecture/adr-writing/references/adr-template.md +160 -0
  15. package/.claude/skills/domain/architecture/architecture-patterns/SKILL.md +316 -0
  16. package/.claude/skills/domain/architecture/architecture-patterns/references/event-driven.md +393 -0
  17. package/.claude/skills/domain/architecture/architecture-patterns/references/microservices.md +315 -0
  18. package/.claude/skills/domain/architecture/architecture-patterns/references/monolith.md +321 -0
  19. package/.claude/skills/domain/architecture/architecture-patterns/references/serverless.md +457 -0
  20. package/.claude/skills/domain/architecture/performance-engineering/SKILL.md +227 -0
  21. package/.claude/skills/domain/architecture/performance-engineering/references/benchmarking.md +336 -0
  22. package/.claude/skills/domain/architecture/performance-engineering/references/caching-strategies.md +284 -0
  23. package/.claude/skills/domain/architecture/performance-engineering/references/optimization.md +298 -0
  24. package/.claude/skills/domain/architecture/security-architecture/SKILL.md +206 -0
  25. package/.claude/skills/domain/architecture/security-architecture/references/auth-patterns.md +209 -0
  26. package/.claude/skills/domain/architecture/security-architecture/references/compliance.md +246 -0
  27. package/.claude/skills/domain/architecture/security-architecture/references/threat-modeling.md +219 -0
  28. package/.claude/skills/domain/architecture/system-design/SKILL.md +227 -0
  29. package/.claude/skills/domain/architecture/system-design/references/distributed-systems.md +231 -0
  30. package/.claude/skills/domain/architecture/system-design/references/resilience.md +344 -0
  31. package/.claude/skills/domain/architecture/system-design/references/scalability.md +303 -0
  32. package/.claude/skills/domain/architecture/tech-selection/SKILL.md +192 -0
  33. package/.claude/skills/domain/architecture/tech-selection/references/build-vs-buy.md +258 -0
  34. package/.claude/skills/domain/architecture/tech-selection/references/evaluation-framework.md +203 -0
  35. package/.claude/skills/domain/architecture/tech-selection/references/tech-radar.md +257 -0
  36. package/.claude/skills/domain/backend/api-design/SKILL.md +121 -0
  37. package/.claude/skills/domain/backend/database-design/SKILL.md +156 -0
  38. package/.claude/skills/domain/backend/performance-be/SKILL.md +210 -0
  39. package/.claude/skills/domain/backend/security/SKILL.md +138 -0
  40. package/.claude/skills/domain/backend/testing-be/SKILL.md +203 -0
  41. package/.claude/skills/domain/devops/ci-cd/SKILL.md +188 -0
  42. package/.claude/skills/domain/devops/containerization/SKILL.md +177 -0
  43. package/.claude/skills/domain/devops/deployment/SKILL.md +198 -0
  44. package/.claude/skills/domain/devops/infrastructure-as-code/SKILL.md +178 -0
  45. package/.claude/skills/domain/devops/monitoring/SKILL.md +163 -0
  46. package/.claude/skills/domain/frontend/accessibility/SKILL.md +179 -0
  47. package/.claude/skills/domain/frontend/frontend-design/SKILL.md +138 -0
  48. package/.claude/skills/domain/frontend/performance-fe/SKILL.md +195 -0
  49. package/.claude/skills/domain/frontend/state-management/SKILL.md +190 -0
  50. package/.claude/skills/domain/frontend/testing-fe/SKILL.md +193 -0
  51. package/.claude/skills/domain/product/requirements-gathering/SKILL.md +136 -0
  52. package/.claude/skills/domain/product/roadmap-planning/SKILL.md +169 -0
  53. package/.claude/skills/domain/product/sprint-planning/SKILL.md +151 -0
  54. package/.claude/skills/domain/product/stakeholder-communication/SKILL.md +162 -0
  55. package/.claude/skills/domain/product/user-stories/SKILL.md +141 -0
  56. package/.claude/skills/domain/quality/bug-reporting/SKILL.md +150 -0
  57. package/.claude/skills/domain/quality/regression-testing/SKILL.md +178 -0
  58. package/.claude/skills/domain/quality/test-automation/SKILL.md +185 -0
  59. package/.claude/skills/domain/quality/test-planning/SKILL.md +177 -0
  60. package/.claude/skills/leadership/code-review-advanced/SKILL.md +167 -0
  61. package/.claude/skills/leadership/mentoring/SKILL.md +151 -0
  62. package/.claude/skills/leadership/technical-debt/SKILL.md +166 -0
  63. package/.claude/skills/leadership/technical-decision/SKILL.md +160 -0
  64. package/.claude/skills/security-reports/.gitkeep +0 -0
  65. package/.claude/skills/skills-registry.yaml +441 -0
  66. package/README.md +232 -0
  67. package/bin/agent-team.js +107 -0
  68. package/package.json +51 -0
  69. package/src/commands/add.js +227 -0
  70. package/src/commands/init.js +136 -0
  71. package/src/commands/list.js +66 -0
  72. package/src/commands/remove.js +71 -0
  73. package/src/commands/switch.js +53 -0
  74. package/src/index.js +11 -0
  75. package/src/interactive/prompts.js +153 -0
  76. package/src/server/api/agents.js +150 -0
  77. package/src/server/api/roles.js +97 -0
  78. package/src/server/api/skills.js +79 -0
  79. package/src/server/index.js +78 -0
  80. package/src/ui/agents.html +174 -0
  81. package/src/ui/css/styles.css +470 -0
  82. package/src/ui/index.html +107 -0
  83. package/src/ui/roles.html +371 -0
  84. package/src/ui/skills.html +332 -0
  85. package/src/utils/file-utils.js +193 -0
  86. package/src/utils/skill-resolver.js +594 -0
  87. package/src/utils/skill-scanner.js +154 -0
  88. package/templates/CLAUDE.md.tmpl +42 -0
  89. package/templates/knowledge.md.tmpl +31 -0
package/README.md ADDED
@@ -0,0 +1,232 @@
1
+ # @wipal/agent-team
2
+
3
+ > **Template for creating AI agent teams with specialized roles, skills, and workflows**
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ Agent Team Template là hệ thống để:
10
+ - Tạo team với nhiều AI agents chuyên môn
11
+ - Mỗi agent có skills, knowledge base riêng
12
+ - Tự học và cải thiện qua thời gian
13
+ - Setup nhanh cho mỗi dự án
14
+
15
+ ## Quick Start
16
+
17
+ ```bash
18
+ # Via npx (recommended)
19
+ npx @wipal/agent-team init
20
+ npx @wipal/agent-team add payment-fe dev-fe --framework react --styling tailwind
21
+
22
+ # Or use UI dashboard
23
+ npx @wipal/agent-team ui
24
+ ```
25
+
26
+ ## CLI Commands
27
+
28
+ | Command | Description |
29
+ |---------|-------------|
30
+ | `init` | Initialize .claude/ structure |
31
+ | `add <name> <role>` | Add new agent |
32
+ | `list` | List all agents |
33
+ | `switch <name>` | Show switch instructions |
34
+ | `remove <name>` | Remove agent |
35
+ | `ui` | Start web dashboard |
36
+
37
+ ### Add Command Options
38
+
39
+ ```bash
40
+ npx @wipal/agent-team add <name> <role> [options]
41
+
42
+ # Frontend options
43
+ --framework <name> # react, vue, angular, svelte
44
+ --styling <name> # tailwind, css-modules, styled-components
45
+ --state <name> # zustand, redux, recoil
46
+
47
+ # Backend options
48
+ --database <name> # postgresql, mysql, mongodb
49
+ --orm <name> # prisma, typeorm, sequelize
50
+
51
+ # Common options
52
+ --testing <name> # vitest, jest, cypress
53
+ -i, --interactive # Interactive mode
54
+ ```
55
+
56
+ ### Examples
57
+
58
+ ```bash
59
+ # Frontend agent with React + Tailwind
60
+ npx @wipal/agent-team add payment-fe dev-fe --framework react --styling tailwind
61
+
62
+ # Backend agent with NestJS + Prisma
63
+ npx @wipal/agent-team add auth-api dev-be --framework nestjs --orm prisma
64
+
65
+ # Tech Lead (inherits dev-fe + dev-be skills)
66
+ npx @wipal/agent-team add lead tech-lead
67
+
68
+ # Interactive mode
69
+ npx @wipal/agent-team add
70
+ ```
71
+
72
+ ## Web Dashboard
73
+
74
+ ```bash
75
+ npx @wipal/agent-team ui
76
+
77
+ # Opens at http://localhost:3456
78
+ ```
79
+
80
+ Features:
81
+ - Agent management (CRUD)
82
+ - Role configuration (YAML editor)
83
+ - Skill browser
84
+ - Variant picker
85
+ - Dashboard stats
86
+
87
+ ## Available Roles
88
+
89
+ | Role | Description | Skills Count |
90
+ |------|-------------|--------------|
91
+ | **dev-fe** | Frontend Developer | 8 |
92
+ | **dev-be** | Backend Developer | 8 |
93
+ | **sa** | Solution Architect | 9 |
94
+ | **tech-lead** | Tech Lead (inherits dev-fe + dev-be) | 17 |
95
+ | **devops** | DevOps Engineer | 8 |
96
+ | **pm** | Product Manager | 8 |
97
+ | **qa** | QA Engineer | 7 |
98
+
99
+ ## Skills Overview
100
+
101
+ ### Total: 37 Skills across 8 categories
102
+
103
+ | Category | Count | Description |
104
+ |----------|-------|-------------|
105
+ | **Core** | 3 | Universal skills (code-review, git-automation, retrospect) |
106
+ | **Frontend** | 5 | React/Vue/UI development |
107
+ | **Backend** | 5 | API/Database/Security |
108
+ | **Architecture** | 6 | System design, ADRs |
109
+ | **DevOps** | 5 | CI/CD, Docker, Terraform |
110
+ | **Product** | 5 | Requirements, Sprints |
111
+ | **Quality** | 4 | Testing, QA |
112
+ | **Leadership** | 4 | Tech Lead skills |
113
+
114
+ ### Skills Structure
115
+
116
+ ```
117
+ .claude/skills/
118
+ ├── SKILL-INDEX.md # Central hub with dependency graph
119
+
120
+ ├── core/ # Universal skills (3)
121
+ │ ├── code-review/
122
+ │ ├── git-automation/
123
+ │ └── retrospect-work/
124
+
125
+ ├── domain/ # Domain-specific (31)
126
+ │ ├── frontend/ # 5 skills
127
+ │ ├── backend/ # 5 skills
128
+ │ ├── architecture/ # 6 skills
129
+ │ ├── devops/ # 5 skills
130
+ │ ├── product/ # 5 skills
131
+ │ └── quality/ # 4 skills
132
+
133
+ ├── leadership/ # Tech Lead skills (4)
134
+ │ ├── code-review-advanced/
135
+ │ ├── technical-decision/
136
+ │ ├── mentoring/
137
+ │ └── technical-debt/
138
+
139
+ └── community/ # Community contributions
140
+ ```
141
+
142
+ ### Skill Dependency Mechanism
143
+
144
+ Each skill has a YAML frontmatter with dependencies:
145
+
146
+ ```yaml
147
+ ---
148
+ name: skill-name
149
+ version: 1.0.0
150
+ description: What and WHEN to use this skill
151
+ category: domain-name
152
+ tags: [tag1, tag2]
153
+
154
+ # Dependency mechanism - "Skill dùng Skill"
155
+ depends_on: [] # Hard dependencies (must load)
156
+ recommends: [] # Soft dependencies (suggest in context)
157
+ used_by: [] # Reverse reference (for discovery)
158
+ ---
159
+ ```
160
+
161
+ ## Documentation
162
+
163
+ | Doc | Description |
164
+ |-----|-------------|
165
+ | [TUTORIAL.md](TUTORIAL.md) | Step-by-step guide |
166
+ | [Architecture](docs/01-architecture.md) | System design and structure |
167
+ | [Setup Guide](docs/02-setup-guide.md) | How to setup agents |
168
+ | [Skills Guide](docs/03-skills-guide.md) | Managing skills |
169
+ | [Workflows](docs/04-workflows.md) | Workflow orchestration |
170
+ | [Model Strategy](docs/05-model-strategy.md) | Model selection by task |
171
+ | [Extend Guide](docs/06-extend-guide.md) | Creating new agents/skills |
172
+ | [Quick Reference](docs/07-quick-reference.md) | Cheat sheet |
173
+
174
+ ## Key Features
175
+
176
+ ### 1. Base + Variants Architecture
177
+ - Base role provides common skills/MCPs
178
+ - Variants add tech-specific capabilities
179
+ - Agents can combine multiple variants
180
+
181
+ ### 2. Skill Dependency System
182
+ - Skills can depend on other skills
183
+ - Progressive disclosure (metadata → instructions → resources)
184
+ - Central hub for navigation
185
+
186
+ ### 3. Role Inheritance (v2)
187
+ - Tech Lead inherits dev-fe + dev-be skills
188
+ - Configurable via `config/roles.yaml`
189
+ - Per-project override in `.claude/roles.yaml`
190
+
191
+ ### 4. Rules System
192
+ - General rules for all agents
193
+ - Role-specific rules
194
+ - Lessons learned from corrections
195
+
196
+ ### 5. Self-Improvement
197
+ - Capture lessons from corrections
198
+ - Pattern promotion (Lesson → Pattern → Skill → Rule)
199
+ - Cross-session memory
200
+
201
+ ## Configuration
202
+
203
+ ### Per-Project Role Override
204
+
205
+ Create `.claude/roles.yaml`:
206
+
207
+ ```yaml
208
+ roles:
209
+ tech-lead:
210
+ skills:
211
+ inherit: [dev-fe, dev-be, devops] # Add devops to tech-lead
212
+
213
+ sa:
214
+ skills:
215
+ inherit: [dev-fe, dev-be] # SA also knows code
216
+ include:
217
+ - category: architecture
218
+ ```
219
+
220
+ ## Research Sources
221
+
222
+ Skills và architecture được xây dựng dựa trên research từ:
223
+
224
+ 1. **Agent-Skills-for-Context-Engineering** - Context engineering patterns
225
+ 2. **AI-Research-SKILLs** - 85 skills, 21 categories structure
226
+ 3. **everything-claude-code** - Hooks, commands, instinct system
227
+ 4. **BMAD-METHOD** - Agent YAML format, sharded workflows
228
+ 5. **spec-kit** - Extension system, multi-agent support
229
+
230
+ ## License
231
+
232
+ MIT
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @wipal/agent-team CLI
5
+ * Add AI agent teams to existing projects with minimal setup
6
+ */
7
+
8
+ import { program } from 'commander';
9
+ import chalk from 'chalk';
10
+ import { initCommand } from '../src/commands/init.js';
11
+ import { addCommand } from '../src/commands/add.js';
12
+ import { listCommand } from '../src/commands/list.js';
13
+ import { switchCommand } from '../src/commands/switch.js';
14
+ import { removeCommand } from '../src/commands/remove.js';
15
+ import { startServer } from '../src/server/index.js';
16
+
17
+ const VERSION = '1.0.0';
18
+
19
+ // Header
20
+ const showHeader = () => {
21
+ console.log('');
22
+ console.log(chalk.cyan('╔═══════════════════════════════════════════════════════════════╗'));
23
+ console.log(chalk.cyan('║') + chalk.bold.white(' 🤖 Agent Team CLI v' + VERSION + ' ') + chalk.cyan('║'));
24
+ console.log(chalk.cyan('║') + chalk.gray(' Add AI agents to your project with ease ') + chalk.cyan('║'));
25
+ console.log(chalk.cyan('╚═══════════════════════════════════════════════════════════════╝'));
26
+ console.log('');
27
+ };
28
+
29
+ program
30
+ .name('agent-team')
31
+ .description('Add AI agent teams to existing projects')
32
+ .version(VERSION)
33
+ .hook('preAction', () => {
34
+ // Show header for all commands except help
35
+ if (process.argv.length > 2 && !process.argv.includes('--help') && !process.argv.includes('-h')) {
36
+ showHeader();
37
+ }
38
+ });
39
+
40
+ // Init command
41
+ program
42
+ .command('init')
43
+ .description('Initialize .claude/ structure in current project')
44
+ .option('-f, --force', 'Overwrite existing files')
45
+ .action(initCommand);
46
+
47
+ // Add command
48
+ program
49
+ .command('add [name] [role]')
50
+ .description('Add a new agent to the project')
51
+ .option('--framework <name>', 'UI/Backend framework (react, vue, nestjs, etc.)')
52
+ .option('--styling <name>', 'CSS solution (tailwind, css-modules, etc.)')
53
+ .option('--state <name>', 'State management (zustand, redux, etc.)')
54
+ .option('--data <name>', 'Data fetching (tanstack-query, swr, etc.)')
55
+ .option('--testing <name>', 'Test framework (vitest, jest, etc.)')
56
+ .option('--form <name>', 'Form handling (react-hook-form, formik, etc.)')
57
+ .option('--ui-lib <name>', 'UI component library (shadcn, mui, etc.)')
58
+ .option('--i18n <name>', 'Internationalization (react-i18next, etc.)')
59
+ .option('--database <name>', 'Database type (postgresql, mysql, mongodb, etc.)')
60
+ .option('--orm <name>', 'ORM tool (prisma, typeorm, etc.)')
61
+ .option('-i, --interactive', 'Run in interactive mode')
62
+ .action(addCommand);
63
+
64
+ // List command
65
+ program
66
+ .command('list')
67
+ .alias('ls')
68
+ .description('List all agents in the project')
69
+ .action(listCommand);
70
+
71
+ // Switch command
72
+ program
73
+ .command('switch <name>')
74
+ .description('Show instructions to switch to an agent')
75
+ .action(switchCommand);
76
+
77
+ // Remove command
78
+ program
79
+ .command('remove <name>')
80
+ .alias('rm')
81
+ .description('Remove an agent from the project')
82
+ .option('-f, --force', 'Skip confirmation')
83
+ .action(removeCommand);
84
+
85
+ // UI command - Start web dashboard
86
+ program
87
+ .command('ui')
88
+ .description('Start web dashboard for managing agents')
89
+ .option('-p, --port <number>', 'Port to run server on', '3456')
90
+ .option('--no-open', 'Don\'t open browser automatically')
91
+ .action(async (options) => {
92
+ const port = parseInt(options.port, 10);
93
+ const openBrowser = options.open !== false;
94
+
95
+ console.log(chalk.blue('🎨 Starting Agent Team UI Dashboard...'));
96
+ console.log('');
97
+
98
+ try {
99
+ await startServer({ port, openBrowser, projectRoot: process.cwd() });
100
+ } catch (error) {
101
+ console.error(chalk.red('Failed to start server:'), error.message);
102
+ process.exit(1);
103
+ }
104
+ });
105
+
106
+ // Parse arguments
107
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@wipal/agent-team",
3
+ "version": "1.0.0",
4
+ "description": "CLI tool to add AI agent teams to existing projects with minimal setup",
5
+ "type": "module",
6
+ "bin": {
7
+ "agent-team": "./bin/agent-team.js"
8
+ },
9
+ "main": "./src/index.js",
10
+ "exports": {
11
+ ".": "./src/index.js"
12
+ },
13
+ "files": [
14
+ "bin",
15
+ "src",
16
+ "templates",
17
+ ".claude/skills",
18
+ ".claude/rules"
19
+ ],
20
+ "scripts": {
21
+ "test": "echo \"Error: no test specified\" && exit 1"
22
+ },
23
+ "keywords": [
24
+ "ai",
25
+ "agent",
26
+ "claude",
27
+ "claude-code",
28
+ "cli",
29
+ "team",
30
+ "productivity"
31
+ ],
32
+ "author": "wipal",
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "chalk": "^5.3.0",
36
+ "commander": "^12.0.0",
37
+ "express": "^5.2.1",
38
+ "fs-extra": "^11.2.0",
39
+ "glob": "^13.0.6",
40
+ "inquirer": "^9.2.0",
41
+ "js-yaml": "^4.1.1",
42
+ "open": "^11.0.0"
43
+ },
44
+ "engines": {
45
+ "node": ">=18.0.0"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/wipal/agent-team.git"
50
+ }
51
+ }
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Add command - Add a new agent to the project
3
+ */
4
+
5
+ import chalk from 'chalk';
6
+ import fs from 'fs-extra';
7
+ import path from 'path';
8
+ import {
9
+ getClaudeDir,
10
+ getAgentDir,
11
+ isInitialized,
12
+ agentExists,
13
+ readTemplate,
14
+ processTemplate,
15
+ copySkills
16
+ } from '../utils/file-utils.js';
17
+ import {
18
+ resolveSkills,
19
+ getAllSkills,
20
+ AVAILABLE_ROLES,
21
+ getVariantsForRole
22
+ } from '../utils/skill-resolver.js';
23
+ import { runInteractiveAdd } from '../interactive/prompts.js';
24
+
25
+ /**
26
+ * Add a new agent
27
+ */
28
+ export async function addCommand(name, role, options) {
29
+ const projectRoot = process.cwd();
30
+
31
+ // Check if initialized
32
+ if (!(await isInitialized(projectRoot))) {
33
+ console.log(chalk.red('❌ Project not initialized'));
34
+ console.log(chalk.gray(' Run `npx @wipal/agent-team init` first'));
35
+ return;
36
+ }
37
+
38
+ // If no name/role provided, run interactive mode
39
+ if (!name || !role || options.interactive) {
40
+ await runInteractiveAdd(projectRoot, { name, role, ...options });
41
+ return;
42
+ }
43
+
44
+ // Validate role
45
+ const validRole = AVAILABLE_ROLES.find(r => r.name === role);
46
+ if (!validRole) {
47
+ console.log(chalk.red(`❌ Invalid role: ${role}`));
48
+ console.log(chalk.gray(' Available roles:'));
49
+ AVAILABLE_ROLES.forEach(r => {
50
+ console.log(chalk.gray(` - ${r.name}: ${r.description}`));
51
+ });
52
+ return;
53
+ }
54
+
55
+ // Check if agent already exists
56
+ if (await agentExists(name, projectRoot)) {
57
+ console.log(chalk.red(`❌ Agent '${name}' already exists`));
58
+ console.log(chalk.gray(' Use a different name or remove the existing agent first'));
59
+ return;
60
+ }
61
+
62
+ // Parse variants from options
63
+ const variants = {};
64
+ const variantOptions = [
65
+ 'framework', 'metaFramework', 'styling', 'state', 'data',
66
+ 'testing', 'form', 'uiLib', 'i18n', 'database', 'orm',
67
+ 'infra', 'cicd', 'monitoring'
68
+ ];
69
+
70
+ for (const opt of variantOptions) {
71
+ const key = opt.charAt(0).toLowerCase() + opt.slice(1);
72
+ // Handle kebab-case to camelCase
73
+ const optKey = opt.replace(/([A-Z])/g, (m) => m.toLowerCase());
74
+ if (options[optKey]) {
75
+ variants[optKey] = options[optKey];
76
+ }
77
+ }
78
+
79
+ // Create the agent
80
+ await createAgent(name, role, variants, projectRoot);
81
+ }
82
+
83
+ /**
84
+ * Create agent with given configuration
85
+ */
86
+ export async function createAgent(name, role, variants, projectRoot) {
87
+ const agentDir = getAgentDir(name, projectRoot);
88
+ const projectName = path.basename(projectRoot);
89
+
90
+ console.log(chalk.blue('🚀 Creating agent...'));
91
+ console.log(chalk.gray(` Name: ${name}`));
92
+ console.log(chalk.gray(` Role: ${role}`));
93
+
94
+ // Show selected variants
95
+ const variantEntries = Object.entries(variants).filter(([_, v]) => v);
96
+ if (variantEntries.length > 0) {
97
+ console.log(chalk.gray(` Variants: ${variantEntries.map(([k, v]) => `${k}=${v}`).join(', ')}`));
98
+ }
99
+ console.log('');
100
+
101
+ // Create agent directory
102
+ await fs.ensureDir(agentDir);
103
+ await fs.ensureDir(path.join(agentDir, 'skills'));
104
+
105
+ // Resolve skills
106
+ console.log(chalk.blue(' Resolving skills...'));
107
+ const skills = resolveSkills(role, variants);
108
+ const allSkills = getAllSkills(role, variants);
109
+
110
+ console.log(chalk.gray(` Core skills: ${skills.core.join(', ')}`));
111
+ console.log(chalk.gray(` Role skills: ${skills.role.join(', ')}`));
112
+ if (skills.variants.length > 0) {
113
+ console.log(chalk.gray(` Variant skills: ${skills.variants.join(', ')}`));
114
+ }
115
+
116
+ // Copy skills
117
+ console.log(chalk.blue(' Copying skills...'));
118
+ const copiedSkills = await copySkills(allSkills, agentDir);
119
+ console.log(chalk.green(` ✓ Copied ${copiedSkills.length} skills`));
120
+
121
+ // Create CLAUDE.md
122
+ console.log(chalk.blue(' Creating CLAUDE.md...'));
123
+ await createClaudeMd(name, role, variants, skills, projectName, agentDir);
124
+ console.log(chalk.green(' ✓ Created CLAUDE.md'));
125
+
126
+ // Create knowledge.md
127
+ console.log(chalk.blue(' Creating knowledge.md...'));
128
+ await createKnowledgeMd(name, role, agentDir);
129
+ console.log(chalk.green(' ✓ Created knowledge.md'));
130
+
131
+ // Create variants.json
132
+ console.log(chalk.blue(' Creating variants.json...'));
133
+ await createVariantsJson(name, role, variants, skills, agentDir);
134
+ console.log(chalk.green(' ✓ Created variants.json'));
135
+
136
+ // Summary
137
+ console.log('');
138
+ console.log(chalk.green('✅ Agent created successfully!'));
139
+ console.log('');
140
+ console.log(chalk.blue('Agent location:'));
141
+ console.log(chalk.gray(` ${agentDir}`));
142
+ console.log('');
143
+ console.log(chalk.blue('To use this agent in Claude Code:'));
144
+ console.log(chalk.cyan(` npx @wipal/agent-team switch ${name}`));
145
+ console.log('');
146
+ }
147
+
148
+ /**
149
+ * Create CLAUDE.md for agent
150
+ */
151
+ async function createClaudeMd(name, role, variants, skills, projectName, agentDir) {
152
+ const roleInfo = AVAILABLE_ROLES.find(r => r.name === role);
153
+
154
+ // Build role skills list
155
+ const roleSkillsList = skills.role.map(s => ` - ${s}`).join('\n');
156
+
157
+ // Build tech stack from variants
158
+ const techStack = Object.entries(variants)
159
+ .filter(([_, v]) => v)
160
+ .map(([k, v]) => `- ${k}: ${v}`)
161
+ .join('\n');
162
+
163
+ // Build variants list
164
+ const variantsList = Object.entries(variants)
165
+ .filter(([_, v]) => v)
166
+ .map(([k, v]) => `- ${k}: ${v}`)
167
+ .join('\n');
168
+
169
+ // Build skills list
170
+ const skillsList = allSkills => allSkills.map(s => `- ${s}`).join('\n');
171
+
172
+ const template = await readTemplate('CLAUDE.md.tmpl');
173
+ const content = processTemplate(template, {
174
+ PROJECT_NAME: projectName,
175
+ AGENT_NAME: name,
176
+ ROLE_NAME: role,
177
+ ROLE_SKILLS: roleSkillsList,
178
+ TECH_STACK: techStack || '- [Configure your tech stack]',
179
+ VARIANTS_LIST: variantsList || '- [No variants selected]',
180
+ SKILLS_LIST: skillsList(getAllSkills(role, variants))
181
+ });
182
+
183
+ await fs.writeFile(path.join(agentDir, 'CLAUDE.md'), content);
184
+ }
185
+
186
+ /**
187
+ * Create knowledge.md for agent
188
+ */
189
+ async function createKnowledgeMd(name, role, agentDir) {
190
+ const now = new Date().toISOString();
191
+ const template = await readTemplate('knowledge.md.tmpl');
192
+ const content = processTemplate(template, {
193
+ AGENT_NAME: name,
194
+ ROLE_NAME: role,
195
+ CREATED_AT: now,
196
+ DATE: now.split('T')[0]
197
+ });
198
+
199
+ await fs.writeFile(path.join(agentDir, 'knowledge.md'), content);
200
+ }
201
+
202
+ /**
203
+ * Create variants.json for agent
204
+ */
205
+ async function createVariantsJson(name, role, variants, skills, agentDir) {
206
+ const now = new Date().toISOString();
207
+
208
+ const content = {
209
+ agent_name: name,
210
+ base_role: role,
211
+ created_at: now,
212
+ updated_at: now,
213
+ installed_variants: variants,
214
+ skills: {
215
+ core: skills.core,
216
+ role: skills.role,
217
+ variants: skills.variants
218
+ },
219
+ skill_status: {
220
+ last_checked: now,
221
+ all_available: true,
222
+ missing_skills: []
223
+ }
224
+ };
225
+
226
+ await fs.writeJson(path.join(agentDir, 'variants.json'), content, { spaces: 2 });
227
+ }