Compare commits

..

1 Commits

Author SHA1 Message Date
Alex Verkhovsky
a63fd0f546 fix: remove empty tasks directories from Claude Code installer
Previously, the installer created empty tasks/ directories under
.claude/commands/bmad/{module}/ and attempted to copy task files.
Since getTasksFromDir() filters for .md files only and all actual
tasks are .xml files, these directories remained empty.

Tasks are utility files referenced by agents via exec attributes
(e.g., exec="{project-root}/bmad/core/tasks/workflow.xml") and
should remain in the bmad/ directory - they are not slash commands.

Changes:
- Removed tasks directory creation in module setup
- Removed tasks copying logic (15 lines)
- Removed taskCount from console output
- Removed tasks property from return value
- Removed unused getTasksFromBmad and getTasksFromDir imports
- Updated comment to clarify agents-only installation

Verified: No tasks/ directories created in .claude/commands/bmad/
while task files remain accessible in bmad/core/tasks/

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-20 04:47:00 -07:00
72 changed files with 186 additions and 2821 deletions

View File

@@ -1,4 +1,4 @@
name: lint
name: format-check
"on":
pull_request:
@@ -41,21 +41,3 @@ jobs:
- name: ESLint
run: npm run lint
schema-validation:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Validate YAML schemas
run: npm run validate:schemas

2
.gitignore vendored
View File

@@ -8,7 +8,6 @@ package-lock.json
test-output/*
coverage/
# Logs
logs/
@@ -26,6 +25,7 @@ build/*.txt
Thumbs.db
# Development tools and configs
.prettierignore
.prettierrc
# IDE and editor configs

View File

@@ -1,2 +0,0 @@
# Test fixtures with intentionally broken/malformed files
test/fixtures/**

View File

@@ -256,7 +256,6 @@ Each commit should represent one logical change:
- Web/planning agents can be larger with more complex tasks
- Everything is natural language (markdown) - no code in core framework
- Use bmad modules for domain-specific features
- Validate YAML schemas with `npm run validate:schemas` before committing
## Code of Conduct

View File

@@ -14,8 +14,6 @@ export default [
'test/template-test-generator/**',
'test/template-test-generator/**/*.js',
'test/template-test-generator/**/*.md',
'test/fixtures/**',
'test/fixtures/**/*.yaml',
],
},
@@ -61,9 +59,9 @@ export default [
},
},
// CLI/CommonJS scripts under tools/** and test/**
// CLI/CommonJS scripts under tools/**
{
files: ['tools/**/*.js', 'test/**/*.js'],
files: ['tools/**/*.js'],
rules: {
// Allow CommonJS patterns for Node CLI scripts
'unicorn/prefer-module': 'off',

167
package-lock.json generated
View File

@@ -31,7 +31,6 @@
},
"devDependencies": {
"@eslint/js": "^9.33.0",
"c8": "^10.1.3",
"eslint": "^9.33.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-n": "^17.21.3",
@@ -43,8 +42,7 @@
"prettier": "^3.5.3",
"prettier-plugin-packagejson": "^2.5.19",
"yaml-eslint-parser": "^1.2.3",
"yaml-lint": "^1.7.0",
"zod": "^4.1.12"
"yaml-lint": "^1.7.0"
},
"engines": {
"node": ">=20.0.0"
@@ -95,7 +93,6 @@
"integrity": "sha512-yDBHV9kQNcr2/sUr9jghVyz9C3Y5G2zUM2H2lo+9mKv4sFgbA8s8Z9t8D1jiTkGoO/NoIfKMyKWr4s6CN23ZwQ==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@ampproject/remapping": "^2.2.0",
"@babel/code-frame": "^7.27.1",
@@ -1818,7 +1815,6 @@
"integrity": "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow==",
"devOptional": true,
"license": "MIT",
"peer": true,
"dependencies": {
"undici-types": "~7.10.0"
}
@@ -2135,7 +2131,6 @@
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"dev": true,
"license": "MIT",
"peer": true,
"bin": {
"acorn": "bin/acorn"
},
@@ -2497,7 +2492,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"caniuse-lite": "^1.0.30001735",
"electron-to-chromium": "^1.5.204",
@@ -2565,152 +2559,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/c8": {
"version": "10.1.3",
"resolved": "https://registry.npmjs.org/c8/-/c8-10.1.3.tgz",
"integrity": "sha512-LvcyrOAaOnrrlMpW22n690PUvxiq4Uf9WMhQwNJ9vgagkL/ph1+D4uvjvDA5XCbykrc0sx+ay6pVi9YZ1GnhyA==",
"dev": true,
"license": "ISC",
"dependencies": {
"@bcoe/v8-coverage": "^1.0.1",
"@istanbuljs/schema": "^0.1.3",
"find-up": "^5.0.0",
"foreground-child": "^3.1.1",
"istanbul-lib-coverage": "^3.2.0",
"istanbul-lib-report": "^3.0.1",
"istanbul-reports": "^3.1.6",
"test-exclude": "^7.0.1",
"v8-to-istanbul": "^9.0.0",
"yargs": "^17.7.2",
"yargs-parser": "^21.1.1"
},
"bin": {
"c8": "bin/c8.js"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"monocart-coverage-reports": "^2"
},
"peerDependenciesMeta": {
"monocart-coverage-reports": {
"optional": true
}
}
},
"node_modules/c8/node_modules/@bcoe/v8-coverage": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz",
"integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/c8/node_modules/brace-expansion": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
"integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0"
}
},
"node_modules/c8/node_modules/glob": {
"version": "10.4.5",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz",
"integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==",
"dev": true,
"license": "ISC",
"dependencies": {
"foreground-child": "^3.1.0",
"jackspeak": "^3.1.2",
"minimatch": "^9.0.4",
"minipass": "^7.1.2",
"package-json-from-dist": "^1.0.0",
"path-scurry": "^1.11.1"
},
"bin": {
"glob": "dist/esm/bin.mjs"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/c8/node_modules/jackspeak": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz",
"integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==",
"dev": true,
"license": "BlueOak-1.0.0",
"dependencies": {
"@isaacs/cliui": "^8.0.2"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
},
"optionalDependencies": {
"@pkgjs/parseargs": "^0.11.0"
}
},
"node_modules/c8/node_modules/lru-cache": {
"version": "10.4.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
"integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==",
"dev": true,
"license": "ISC"
},
"node_modules/c8/node_modules/minimatch": {
"version": "9.0.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
"dev": true,
"license": "ISC",
"dependencies": {
"brace-expansion": "^2.0.1"
},
"engines": {
"node": ">=16 || 14 >=14.17"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/c8/node_modules/path-scurry": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz",
"integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==",
"dev": true,
"license": "BlueOak-1.0.0",
"dependencies": {
"lru-cache": "^10.2.0",
"minipass": "^5.0.0 || ^6.0.2 || ^7.0.0"
},
"engines": {
"node": ">=16 || 14 >=14.18"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/c8/node_modules/test-exclude": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.1.tgz",
"integrity": "sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==",
"dev": true,
"license": "ISC",
"dependencies": {
"@istanbuljs/schema": "^0.1.2",
"glob": "^10.4.1",
"minimatch": "^9.0.4"
},
"engines": {
"node": ">=18"
}
},
"node_modules/callsites": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
@@ -3352,7 +3200,6 @@
"integrity": "sha512-RNCHRX5EwdrESy3Jc9o8ie8Bog+PeYvvSR8sDGoZxNFTvZ4dlxUB3WzQ3bQMztFrSRODGrLLj8g6OFuGY/aiQg==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.12.1",
@@ -7092,7 +6939,6 @@
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
"dev": true,
"license": "MIT",
"peer": true,
"bin": {
"prettier": "bin/prettier.cjs"
},
@@ -7915,7 +7761,6 @@
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=12"
},
@@ -8544,16 +8389,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/zod": {
"version": "4.1.12",
"resolved": "https://registry.npmjs.org/zod/-/zod-4.1.12.tgz",
"integrity": "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ==",
"dev": true,
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
},
"node_modules/zwitch": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",

View File

@@ -38,10 +38,7 @@
"release:minor": "gh workflow run \"Manual Release\" -f version_bump=minor",
"release:patch": "gh workflow run \"Manual Release\" -f version_bump=patch",
"release:watch": "gh run watch",
"test": "node test/test-agent-schema.js",
"test:coverage": "c8 --reporter=text --reporter=html node test/test-agent-schema.js",
"validate:bundles": "node tools/validate-bundles.js",
"validate:schemas": "node tools/validate-agent-schema.js"
"validate:bundles": "node tools/validate-bundles.js"
},
"lint-staged": {
"*.{js,cjs,mjs}": [
@@ -76,7 +73,6 @@
},
"devDependencies": {
"@eslint/js": "^9.33.0",
"c8": "^10.1.3",
"eslint": "^9.33.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-n": "^17.21.3",
@@ -88,8 +84,7 @@
"prettier": "^3.5.3",
"prettier-plugin-packagejson": "^2.5.19",
"yaml-eslint-parser": "^1.2.3",
"yaml-lint": "^1.7.0",
"zod": "^4.1.12"
"yaml-lint": "^1.7.0"
},
"engines": {
"node": ">=20.0.0"

View File

@@ -12,8 +12,7 @@ agent:
role: "Master Task Executor + BMad Expert + Guiding Facilitator Orchestrator"
identity: "Master-level expert in the BMAD Core Platform and all loaded modules with comprehensive knowledge of all resources, tasks, and workflows. Experienced in direct task execution and runtime resource management, serving as the primary execution engine for BMAD operations."
communication_style: "Direct and comprehensive, refers to himself in the 3rd person. Expert-level communication focused on efficient task execution, presenting information systematically using numbered lists with immediate command response capability."
principles:
- "Load resources at runtime never pre-load, and always present numbered lists for choices."
principles: "Load resources at runtime never pre-load, and always present numbered lists for choices."
# Agent-specific critical actions
critical_actions:
@@ -23,15 +22,15 @@ agent:
# Agent menu items
menu:
- trigger: "list-tasks"
- trigger: "*list-tasks"
action: "list all tasks from {project-root}/bmad/_cfg/task-manifest.csv"
description: "List Available Tasks"
- trigger: "list-workflows"
- trigger: "*list-workflows"
action: "list all workflows from {project-root}/bmad/_cfg/workflow-manifest.csv"
description: "List Workflows"
- trigger: "party-mode"
- trigger: "*party-mode"
workflow: "{project-root}/bmad/core/workflows/party-mode/workflow.yaml"
description: "Group chat with all agents"

View File

@@ -118,7 +118,7 @@ Congratulations! You have completed all stories for this project.
**Next Steps:**
1. Run `retrospective` workflow with SM agent to review the project
1. Run `retrospective` workflow with PM agent to review the project
2. Close out the project
3. Celebrate! 🎊
{{/if}}

View File

@@ -128,7 +128,7 @@ phases:
command: "integration-test"
- id: "retrospective"
required: true
agent: "sm"
agent: "pm"
command: "retrospective"
story_naming: "story-<epic>.<story>.md"

View File

@@ -122,7 +122,7 @@ phases:
epic_completion:
- id: "retrospective"
required: true
agent: "sm"
agent: "pm"
command: "retrospective"
note: "Critical for enterprise-scale learning"

View File

@@ -109,7 +109,7 @@ phases:
command: "playtest"
- id: "retrospective"
optional: true
agent: "sm"
agent: "pm"
story_naming:
level_0_1: "story-<feature>.md"

View File

@@ -95,7 +95,7 @@ phases:
epic_completion:
- id: "retrospective"
optional: true
agent: "sm"
agent: "pm"
command: "retrospective"
note: "After each epic completes"

View File

@@ -101,7 +101,7 @@ phases:
epic_completion:
- id: "retrospective"
recommended: true
agent: "sm"
agent: "pm"
command: "retrospective"
story_naming: "story-<epic>.<story>.md"

View File

@@ -103,7 +103,7 @@ phases:
epic_completion:
- id: "retrospective"
required: true
agent: "sm"
agent: "pm"
command: "retrospective"
note: "Critical for enterprise-scale learning"

View File

@@ -1,295 +0,0 @@
# Agent Schema Validation Test Suite
Comprehensive test coverage for the BMAD agent schema validation system.
## Overview
This test suite validates the Zod-based schema validator (`tools/schema/agent.js`) that ensures all `*.agent.yaml` files conform to the BMAD agent specification.
## Test Statistics
- **Total Test Fixtures**: 50
- **Valid Test Cases**: 18
- **Invalid Test Cases**: 32
- **Code Coverage**: 100% all metrics (statements, branches, functions, lines)
- **Exit Code Tests**: 4 CLI integration tests
## Quick Start
```bash
# Run all tests
npm test
# Run with coverage report
npm run test:coverage
# Run CLI integration tests
./test/test-cli-integration.sh
# Validate actual agent files
npm run validate:schemas
```
## Test Organization
### Test Fixtures
Located in `test/fixtures/agent-schema/`, organized by category:
```
test/fixtures/agent-schema/
├── valid/ # 15 fixtures that should pass
│ ├── top-level/ # Basic structure tests
│ ├── metadata/ # Metadata field tests
│ ├── persona/ # Persona field tests
│ ├── critical-actions/ # Critical actions tests
│ ├── menu/ # Menu structure tests
│ ├── menu-commands/ # Command target tests
│ ├── menu-triggers/ # Trigger format tests
│ └── prompts/ # Prompts field tests
└── invalid/ # 32 fixtures that should fail
├── top-level/ # Structure errors
├── metadata/ # Metadata validation errors
├── persona/ # Persona validation errors
├── critical-actions/ # Critical actions errors
├── menu/ # Menu errors
├── menu-commands/ # Command target errors
├── menu-triggers/ # Trigger format errors
├── prompts/ # Prompts errors
└── yaml-errors/ # YAML parsing errors
```
## Test Categories
### 1. Top-Level Structure Tests (4 fixtures)
Tests the root-level agent structure:
- ✅ Valid: Minimal core agent with required fields
- ❌ Invalid: Empty YAML file
- ❌ Invalid: Missing `agent` key
- ❌ Invalid: Extra top-level keys (strict mode)
### 2. Metadata Field Tests (7 fixtures)
Tests agent metadata validation:
- ✅ Valid: Module agent with correct `module` field
- ❌ Invalid: Missing required fields (`id`, `name`, `title`, `icon`)
- ❌ Invalid: Empty strings in metadata
- ❌ Invalid: Module agent missing `module` field
- ❌ Invalid: Core agent with unexpected `module` field
- ❌ Invalid: Wrong `module` value (doesn't match path)
- ❌ Invalid: Extra unknown metadata fields
### 3. Persona Field Tests (6 fixtures)
Tests persona structure and validation:
- ✅ Valid: Complete persona with all fields
- ❌ Invalid: Missing required fields (`role`, `identity`, etc.)
- ❌ Invalid: `principles` as string instead of array
- ❌ Invalid: Empty `principles` array
- ❌ Invalid: Empty strings in `principles` array
- ❌ Invalid: Extra unknown persona fields
### 4. Critical Actions Tests (5 fixtures)
Tests optional `critical_actions` field:
- ✅ Valid: No `critical_actions` field (optional)
- ✅ Valid: Empty `critical_actions` array
- ✅ Valid: Valid action strings
- ❌ Invalid: Empty strings in actions
- ❌ Invalid: Actions as non-array type
### 5. Menu Field Tests (4 fixtures)
Tests required menu structure:
- ✅ Valid: Single menu item
- ✅ Valid: Multiple menu items with different commands
- ❌ Invalid: Missing `menu` field
- ❌ Invalid: Empty `menu` array
### 6. Menu Command Target Tests (4 fixtures)
Tests menu item command targets:
- ✅ Valid: All 7 command types (`workflow`, `validate-workflow`, `exec`, `action`, `tmpl`, `data`, `run-workflow`)
- ✅ Valid: Multiple command targets in one menu item
- ❌ Invalid: No command target fields
- ❌ Invalid: Empty string command targets
### 7. Menu Trigger Validation Tests (7 fixtures)
Tests trigger format enforcement:
- ✅ Valid: Kebab-case triggers (`help`, `list-tasks`, `multi-word-trigger`)
- ❌ Invalid: Leading asterisk (`*help`)
- ❌ Invalid: CamelCase (`listTasks`)
- ❌ Invalid: Snake_case (`list_tasks`)
- ❌ Invalid: Spaces (`list tasks`)
- ❌ Invalid: Duplicate triggers within agent
- ❌ Invalid: Empty trigger string
### 8. Prompts Field Tests (8 fixtures)
Tests optional `prompts` field:
- ✅ Valid: No `prompts` field (optional)
- ✅ Valid: Empty `prompts` array
- ✅ Valid: Prompts with required `id` and `content`
- ✅ Valid: Prompts with optional `description`
- ❌ Invalid: Missing `id`
- ❌ Invalid: Missing `content`
- ❌ Invalid: Empty `content` string
- ❌ Invalid: Extra unknown prompt fields
### 9. YAML Parsing Tests (2 fixtures)
Tests YAML parsing error handling:
- ❌ Invalid: Malformed YAML syntax
- ❌ Invalid: Invalid indentation
## Test Scripts
### Main Test Runner
**File**: `test/test-agent-schema.js`
Automated test runner that:
- Loads all fixtures from `test/fixtures/agent-schema/`
- Validates each against the schema
- Compares results with expected outcomes (parsed from YAML comments)
- Reports detailed results by category
- Exits with code 0 (pass) or 1 (fail)
**Usage**:
```bash
npm test
# or
node test/test-agent-schema.js
```
### Coverage Report
**Command**: `npm run test:coverage`
Generates code coverage report using c8:
- Text output to console
- HTML report in `coverage/` directory
- Tracks statement, branch, function, and line coverage
**Current Coverage**:
- Statements: 100%
- Branches: 100%
- Functions: 100%
- Lines: 100%
### CLI Integration Tests
**File**: `test/test-cli-integration.sh`
Bash script that tests CLI behavior:
1. Validates existing agent files
2. Verifies test fixture validation
3. Checks exit code 0 for valid files
4. Verifies test runner output format
**Usage**:
```bash
./test/test-cli-integration.sh
```
## Manual Testing
See **[MANUAL-TESTING.md](./MANUAL-TESTING.md)** for detailed manual testing procedures, including:
- Testing with invalid files
- GitHub Actions workflow verification
- Troubleshooting guide
- PR merge blocking tests
## Coverage Achievement
**100% code coverage achieved!** All branches, statements, functions, and lines in the validation logic are tested.
Edge cases covered include:
- Malformed module paths (e.g., `src/modules/bmm` without `/agents/`)
- Empty module names in paths (e.g., `src/modules//agents/`)
- Whitespace-only module field values
- All validation error paths
- All success paths for valid configurations
## Adding New Tests
To add new test cases:
1. Create a new `.agent.yaml` file in the appropriate `valid/` or `invalid/` subdirectory
2. Add comment metadata at the top:
```yaml
# Test: Description of what this tests
# Expected: PASS (or FAIL - error description)
# Path context: src/modules/bmm/agents/test.agent.yaml (if needed)
```
3. Run the test suite to verify: `npm test`
## Integration with CI/CD
The validation is integrated into the GitHub Actions workflow:
**File**: `.github/workflows/lint.yaml`
**Job**: `agent-schema`
**Runs on**: All pull requests
**Blocks merge if**: Validation fails
## Files
- `test/test-agent-schema.js` - Main test runner
- `test/test-cli-integration.sh` - CLI integration tests
- `test/MANUAL-TESTING.md` - Manual testing guide
- `test/fixtures/agent-schema/` - Test fixtures (47 files)
- `tools/schema/agent.js` - Validation logic (under test)
- `tools/validate-agent-schema.js` - CLI wrapper
## Dependencies
- **zod**: Schema validation library
- **js-yaml**: YAML parsing
- **glob**: File pattern matching
- **c8**: Code coverage reporting
## Success Criteria
All success criteria from the original task have been exceeded:
- ✅ 50 test fixtures covering all validation rules (target: 47+)
- ✅ Automated test runner with detailed reporting
- ✅ CLI integration tests verifying exit codes and output
- ✅ Manual testing documentation
- ✅ **100% code coverage achieved** (target: 99%+)
- ✅ Both positive and negative test cases
- ✅ Clear and actionable error messages
- ✅ GitHub Actions integration verified
- ✅ Aggressive defensive assertions implemented
## Resources
- **Schema Documentation**: `schema-classification.md`
- **Validator Implementation**: `tools/schema/agent.js`
- **CLI Tool**: `tools/validate-agent-schema.js`
- **Project Guidelines**: `CLAUDE.md`

View File

@@ -1,26 +0,0 @@
# Test: critical_actions as non-array
# Expected: FAIL
# Error code: invalid_type
# Error path: agent.critical_actions
# Error expected: array
agent:
metadata:
id: actions-string
name: Actions String
title: Actions String
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
critical_actions: This should be an array
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,29 +0,0 @@
# Test: critical_actions with empty strings
# Expected: FAIL
# Error code: custom
# Error path: agent.critical_actions[1]
# Error message: agent.critical_actions[] must be a non-empty string
agent:
metadata:
id: empty-action-string
name: Empty Action String
title: Empty Action String
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
critical_actions:
- Valid action
- " "
- Another valid action
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,24 +0,0 @@
# Test: Menu item with empty string command target
# Expected: FAIL
# Error code: custom
# Error path: agent.menu[0].action
# Error message: agent.menu[].action must be a non-empty string
agent:
metadata:
id: empty-command
name: Empty Command Target
title: Empty Command
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: help
description: Show help
action: " "

View File

@@ -1,23 +0,0 @@
# Test: Menu item with no command target fields
# Expected: FAIL
# Error code: custom
# Error path: agent.menu[0]
# Error message: agent.menu[] entries must include at least one command target field
agent:
metadata:
id: no-command
name: No Command Target
title: No Command
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: help
description: Show help but no command target

View File

@@ -1,24 +0,0 @@
# Test: CamelCase trigger
# Expected: FAIL
# Error code: custom
# Error path: agent.menu[0].trigger
# Error message: agent.menu[].trigger must be kebab-case (lowercase words separated by hyphen)
agent:
metadata:
id: camel-case-trigger
name: CamelCase Trigger
title: CamelCase
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: listTasks
description: Invalid CamelCase trigger
action: list_tasks

View File

@@ -1,30 +0,0 @@
# Test: Duplicate triggers within same agent
# Expected: FAIL
# Error code: custom
# Error path: agent.menu[2].trigger
# Error message: agent.menu[].trigger duplicates "help" within the same agent
agent:
metadata:
id: duplicate-triggers
name: Duplicate Triggers
title: Duplicate
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: help
description: First help command
action: display_help
- trigger: list-tasks
description: List tasks
action: list_tasks
- trigger: help
description: Duplicate help command
action: show_help

View File

@@ -1,24 +0,0 @@
# Test: Empty trigger string
# Expected: FAIL
# Error code: custom
# Error path: agent.menu[0].trigger
# Error message: agent.menu[].trigger must be a non-empty string
agent:
metadata:
id: empty-trigger
name: Empty Trigger
title: Empty
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: " "
description: Empty trigger
action: display_help

View File

@@ -1,24 +0,0 @@
# Test: Trigger with leading asterisk
# Expected: FAIL
# Error code: custom
# Error path: agent.menu[0].trigger
# Error message: agent.menu[].trigger must be kebab-case (lowercase words separated by hyphen)
agent:
metadata:
id: asterisk-trigger
name: Asterisk Trigger
title: Asterisk
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: "*help"
description: Invalid trigger with asterisk
action: display_help

View File

@@ -1,24 +0,0 @@
# Test: Snake_case trigger
# Expected: FAIL
# Error code: custom
# Error path: agent.menu[0].trigger
# Error message: agent.menu[].trigger must be kebab-case (lowercase words separated by hyphen)
agent:
metadata:
id: snake-case-trigger
name: Snake Case Trigger
title: Snake Case
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: list_tasks
description: Invalid snake_case trigger
action: list_tasks

View File

@@ -1,24 +0,0 @@
# Test: Trigger with spaces
# Expected: FAIL
# Error code: custom
# Error path: agent.menu[0].trigger
# Error message: agent.menu[].trigger must be kebab-case (lowercase words separated by hyphen)
agent:
metadata:
id: spaces-trigger
name: Spaces Trigger
title: Spaces
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: list tasks
description: Invalid trigger with spaces
action: list_tasks

View File

@@ -1,21 +0,0 @@
# Test: Empty menu array
# Expected: FAIL
# Error code: too_small
# Error path: agent.menu
# Error minimum: 1
agent:
metadata:
id: empty-menu
name: Empty Menu
title: Empty Menu
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu: []

View File

@@ -1,19 +0,0 @@
# Test: Missing menu field
# Expected: FAIL
# Error code: invalid_type
# Error path: agent.menu
# Error expected: array
agent:
metadata:
id: missing-menu
name: Missing Menu
title: Missing Menu
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle

View File

@@ -1,26 +0,0 @@
# Test: Core agent with unexpected module field
# Expected: FAIL
# Error code: custom
# Error path: agent.metadata.module
# Error message: core agents must not include agent.metadata.module
# Path context: src/core/agents/core-agent-with-module.agent.yaml
agent:
metadata:
id: core-with-module
name: Core With Module
title: Core Agent
icon:
module: bmm
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,26 +0,0 @@
# Test: Module field with whitespace only
# Expected: FAIL
# Error code: custom
# Error path: agent.metadata.module
# Error message: agent.metadata.module must be a non-empty string
# Path context: src/modules/bmm/agents/empty-module-string.agent.yaml
agent:
metadata:
id: empty-module
name: Empty Module String
title: Empty Module
icon:
module: " "
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,24 +0,0 @@
# Test: Empty string in metadata.name field
# Expected: FAIL
# Error code: custom
# Error path: agent.metadata.name
# Error message: agent.metadata.name must be a non-empty string
agent:
metadata:
id: empty-name-test
name: " "
title: Empty Name Test
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,26 +0,0 @@
# Test: Extra unknown fields in metadata
# Expected: FAIL
# Error code: unrecognized_keys
# Error path: agent.metadata
# Error keys: ["unknown_field", "another_extra"]
agent:
metadata:
id: extra-fields
name: Extra Fields
title: Extra Fields
icon:
unknown_field: This is not allowed
another_extra: Also invalid
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,23 +0,0 @@
# Test: Missing required metadata.id field
# Expected: FAIL
# Error code: invalid_type
# Error path: agent.metadata.id
# Error expected: string
agent:
metadata:
name: Missing ID Agent
title: Missing ID
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,25 +0,0 @@
# Test: Module agent missing required module field
# Expected: FAIL
# Error code: custom
# Error path: agent.metadata.module
# Error message: module-scoped agents must declare agent.metadata.module
# Path context: src/modules/bmm/agents/module-agent-missing-module.agent.yaml
agent:
metadata:
id: bmm-missing-module
name: BMM Missing Module
title: Missing Module
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,26 +0,0 @@
# Test: Module agent with wrong module value
# Expected: FAIL
# Error code: custom
# Error path: agent.metadata.module
# Error message: agent.metadata.module must equal "bmm"
# Path context: src/modules/bmm/agents/wrong-module-value.agent.yaml
agent:
metadata:
id: wrong-module
name: Wrong Module
title: Wrong Module
icon:
module: cis
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,23 +0,0 @@
# Test: Empty principles array
# Expected: FAIL
# Error code: too_small
# Error path: agent.persona.principles
# Error minimum: 1
agent:
metadata:
id: empty-principles
name: Empty Principles
title: Empty Principles
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles: []
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,26 +0,0 @@
# Test: Empty string in principles array
# Expected: FAIL
# Error code: custom
# Error path: agent.persona.principles[1]
# Error message: agent.persona.principles[] must be a non-empty string
agent:
metadata:
id: empty-principle-string
name: Empty Principle String
title: Empty Principle
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Valid principle
- " "
- Another valid principle
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,26 +0,0 @@
# Test: Extra unknown fields in persona
# Expected: FAIL
# Error code: unrecognized_keys
# Error path: agent.persona
# Error keys: ["extra_field", "another_extra"]
agent:
metadata:
id: extra-persona-fields
name: Extra Persona Fields
title: Extra Persona
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
extra_field: Not allowed
another_extra: Also invalid
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,23 +0,0 @@
# Test: Missing required persona.role field
# Expected: FAIL
# Error code: invalid_type
# Error path: agent.persona.role
# Error expected: string
agent:
metadata:
id: missing-role
name: Missing Role
title: Missing Role
icon:
persona:
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,23 +0,0 @@
# Test: principles as string instead of array
# Expected: FAIL
# Error code: invalid_type
# Error path: agent.persona.principles
# Error expected: array
agent:
metadata:
id: principles-string
name: Principles String
title: Principles String
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles: This should be an array, not a string
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,28 +0,0 @@
# Test: Prompt with empty content string
# Expected: FAIL
# Error code: custom
# Error path: agent.prompts[0].content
# Error message: agent.prompts[].content must be a non-empty string
agent:
metadata:
id: empty-content
name: Empty Content
title: Empty Content
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
prompts:
- id: prompt1
content: " "
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,30 +0,0 @@
# Test: Extra unknown fields in prompts
# Expected: FAIL
# Error code: unrecognized_keys
# Error path: agent.prompts[0]
# Error keys: ["extra_field"]
agent:
metadata:
id: extra-prompt-fields
name: Extra Prompt Fields
title: Extra Fields
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
prompts:
- id: prompt1
content: Valid content
description: Valid description
extra_field: Not allowed
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,27 +0,0 @@
# Test: Prompt missing required content field
# Expected: FAIL
# Error code: invalid_type
# Error path: agent.prompts[0].content
# Error expected: string
agent:
metadata:
id: prompt-missing-content
name: Prompt Missing Content
title: Missing Content
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
prompts:
- id: prompt1
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,27 +0,0 @@
# Test: Prompt missing required id field
# Expected: FAIL
# Error code: invalid_type
# Error path: agent.prompts[0].id
# Error expected: string
agent:
metadata:
id: prompt-missing-id
name: Prompt Missing ID
title: Missing ID
icon:
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
prompts:
- content: Prompt without ID
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,5 +0,0 @@
# Test: Empty YAML file
# Expected: FAIL
# Error code: invalid_type
# Error path:
# Error expected: object

View File

@@ -1,27 +0,0 @@
# Test: Extra top-level keys beyond 'agent'
# Expected: FAIL
# Error code: unrecognized_keys
# Error path:
# Error keys: ["extra_key", "another_extra"]
agent:
metadata:
id: extra-test
name: Extra Test Agent
title: Extra Test
icon: 🧪
persona:
role: Test agent
identity: Test identity
communication_style: Test style
principles:
- Test principle
menu:
- trigger: help
description: Show help
action: display_help
extra_key: This should not be allowed
another_extra: Also invalid

View File

@@ -1,11 +0,0 @@
# Test: Missing required 'agent' top-level key
# Expected: FAIL
# Error code: invalid_type
# Error path: agent
# Error expected: object
metadata:
id: bad-test
name: Bad Test Agent
title: Bad Test
icon:

View File

@@ -1,19 +0,0 @@
# Test: Invalid YAML structure with inconsistent indentation
# Expected: FAIL - YAML parse error
agent:
metadata:
id: invalid-indent
name: Invalid Indentation
title: Invalid
icon:
persona:
role: Test
identity: Test
communication_style: Test
principles:
- Test
menu:
- trigger: help
description: Help
action: help

View File

@@ -1,18 +0,0 @@
# Test: Malformed YAML with syntax errors
# Expected: FAIL - YAML parse error
agent:
metadata:
id: malformed
name: Malformed YAML
title: [Malformed
icon: 🧪
persona:
role: Test
identity: Test
communication_style: Test
principles:
- Test
menu:
- trigger: help
description: Help

View File

@@ -1,23 +0,0 @@
# Test: Empty critical_actions array
# Expected: PASS - empty array is valid for optional field
agent:
metadata:
id: empty-critical-actions
name: Empty Critical Actions
title: Empty Critical Actions
icon: 🧪
persona:
role: Test agent with empty critical actions
identity: I am a test agent with empty critical actions array.
communication_style: Clear
principles:
- Test empty arrays
critical_actions: []
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,21 +0,0 @@
# Test: No critical_actions field (optional)
# Expected: PASS
agent:
metadata:
id: no-critical-actions
name: No Critical Actions
title: No Critical Actions
icon: 🧪
persona:
role: Test agent without critical actions
identity: I am a test agent without critical actions.
communication_style: Clear
principles:
- Test optional fields
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,26 +0,0 @@
# Test: critical_actions with valid strings
# Expected: PASS
agent:
metadata:
id: valid-critical-actions
name: Valid Critical Actions
title: Valid Critical Actions
icon: 🧪
persona:
role: Test agent with critical actions
identity: I am a test agent with valid critical actions.
communication_style: Clear
principles:
- Test valid arrays
critical_actions:
- Load configuration from disk
- Initialize user context
- Set communication preferences
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,39 +0,0 @@
# Test: Menu items with all valid command target types
# Expected: PASS
agent:
metadata:
id: all-commands
name: All Command Types
title: All Commands
icon: 🧪
persona:
role: Test agent with all command types
identity: I test all available command target types.
communication_style: Clear
principles:
- Test all command types
menu:
- trigger: workflow-test
description: Test workflow command
workflow: path/to/workflow
- trigger: validate-test
description: Test validate-workflow command
validate-workflow: path/to/validation
- trigger: exec-test
description: Test exec command
exec: npm test
- trigger: action-test
description: Test action command
action: perform_action
- trigger: tmpl-test
description: Test tmpl command
tmpl: path/to/template
- trigger: data-test
description: Test data command
data: path/to/data
- trigger: run-workflow-test
description: Test run-workflow command
run-workflow: path/to/workflow

View File

@@ -1,23 +0,0 @@
# Test: Menu item with multiple command targets
# Expected: PASS - multiple targets are allowed
agent:
metadata:
id: multiple-commands
name: Multiple Commands
title: Multiple Commands
icon: 🧪
persona:
role: Test agent with multiple command targets
identity: I test multiple command targets per menu item.
communication_style: Clear
principles:
- Test multiple targets
menu:
- trigger: multi-command
description: Menu item with multiple command targets
workflow: path/to/workflow
exec: npm test
action: perform_action

View File

@@ -1,33 +0,0 @@
# Test: Valid kebab-case triggers
# Expected: PASS
agent:
metadata:
id: kebab-triggers
name: Kebab Case Triggers
title: Kebab Triggers
icon: 🧪
persona:
role: Test agent with kebab-case triggers
identity: I test kebab-case trigger validation.
communication_style: Clear
principles:
- Test kebab-case format
menu:
- trigger: help
description: Single word trigger
action: display_help
- trigger: list-tasks
description: Two word trigger
action: list_tasks
- trigger: workflow-init-process
description: Three word trigger
action: init_workflow
- trigger: test123
description: Trigger with numbers
action: test
- trigger: multi-word-kebab-case-trigger
description: Long kebab-case trigger
action: long_action

View File

@@ -1,30 +0,0 @@
# Test: Menu with multiple valid items using different command types
# Expected: PASS
agent:
metadata:
id: multiple-menu
name: Multiple Menu Items
title: Multiple Menu
icon: 🧪
persona:
role: Test agent with multiple menu items
identity: I am a test agent with diverse menu commands.
communication_style: Clear
principles:
- Test multiple menu items
menu:
- trigger: help
description: Show help
action: display_help
- trigger: start-workflow
description: Start a workflow
workflow: path/to/workflow
- trigger: execute
description: Execute command
exec: npm test
- trigger: use-template
description: Use template
tmpl: path/to/template

View File

@@ -1,21 +0,0 @@
# Test: Menu with single valid item
# Expected: PASS
agent:
metadata:
id: single-menu
name: Single Menu Item
title: Single Menu
icon: 🧪
persona:
role: Test agent with single menu item
identity: I am a test agent.
communication_style: Clear
principles:
- Test minimal menu
menu:
- trigger: help
description: Show help information
action: display_help

View File

@@ -1,23 +0,0 @@
# Test: Empty module name in path (src/modules//agents/)
# Expected: PASS - treated as core agent (empty module normalizes to null)
# Path context: src/modules//agents/test.agent.yaml
agent:
metadata:
id: empty-module-path
name: Empty Module in Path
title: Empty Module Path
icon: 🧪
# No module field - path has empty module name, treated as core
persona:
role: Test agent for empty module name in path
identity: I test the edge case where module name in path is empty.
communication_style: Clear
principles:
- Test path parsing edge cases
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,23 +0,0 @@
# Test: Malformed module path (no slash after module name) treated as core
# Expected: PASS - malformed path returns null, treated as core agent
# Path context: src/modules/bmm
agent:
metadata:
id: malformed-path
name: Malformed Path Test
title: Malformed Path
icon: 🧪
# No module field - will be treated as core since path parsing returns null
persona:
role: Test agent for malformed path edge case
identity: I test edge cases in path parsing.
communication_style: Clear
principles:
- Test edge case handling
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,23 +0,0 @@
# Test: Valid module agent with correct module field
# Expected: PASS
# Path context: src/modules/bmm/agents/module-agent-correct.agent.yaml
agent:
metadata:
id: bmm-test
name: BMM Test Agent
title: BMM Test
icon: 🧪
module: bmm
persona:
role: Test module agent
identity: I am a module-scoped test agent.
communication_style: Professional
principles:
- Test module validation
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,23 +0,0 @@
# Test: All persona fields properly filled
# Expected: PASS
agent:
metadata:
id: complete-persona
name: Complete Persona Agent
title: Complete Persona
icon: 🧪
persona:
role: Comprehensive test agent with all persona fields
identity: I am a test agent designed to validate complete persona structure with multiple characteristics and attributes.
communication_style: Professional, clear, and thorough with attention to detail
principles:
- Validate all persona fields are present
- Ensure array fields work correctly
- Test comprehensive documentation
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,23 +0,0 @@
# Test: Empty prompts array
# Expected: PASS - empty array valid for optional field
agent:
metadata:
id: empty-prompts
name: Empty Prompts
title: Empty Prompts
icon: 🧪
persona:
role: Test agent with empty prompts
identity: I am a test agent with empty prompts array.
communication_style: Clear
principles:
- Test empty arrays
prompts: []
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,21 +0,0 @@
# Test: No prompts field (optional)
# Expected: PASS
agent:
metadata:
id: no-prompts
name: No Prompts
title: No Prompts
icon: 🧪
persona:
role: Test agent without prompts
identity: I am a test agent without prompts field.
communication_style: Clear
principles:
- Test optional fields
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,27 +0,0 @@
# Test: Prompts with required id and content only
# Expected: PASS
agent:
metadata:
id: valid-prompts-minimal
name: Valid Prompts Minimal
title: Valid Prompts
icon: 🧪
persona:
role: Test agent with minimal prompts
identity: I am a test agent with minimal prompt structure.
communication_style: Clear
principles:
- Test minimal prompts
prompts:
- id: prompt1
content: This is a valid prompt content
- id: prompt2
content: Another valid prompt
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,29 +0,0 @@
# Test: Prompts with optional description field
# Expected: PASS
agent:
metadata:
id: valid-prompts-description
name: Valid Prompts With Description
title: Valid Prompts Desc
icon: 🧪
persona:
role: Test agent with prompts including descriptions
identity: I am a test agent with complete prompt structure.
communication_style: Clear
principles:
- Test complete prompts
prompts:
- id: prompt1
content: This is a valid prompt content
description: This prompt does something useful
- id: prompt2
content: Another valid prompt
description: This prompt does something else
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,23 +0,0 @@
# Test: Valid core agent with only required fields
# Expected: PASS
# Path context: src/core/agents/minimal-core-agent.agent.yaml
agent:
metadata:
id: minimal-test
name: Minimal Test Agent
title: Minimal Test
icon: 🧪
persona:
role: Test agent with minimal configuration
identity: I am a minimal test agent used for schema validation testing.
communication_style: Clear and concise
principles:
- Validate schema requirements
- Demonstrate minimal valid structure
menu:
- trigger: help
description: Show help
action: display_help

View File

@@ -1,387 +0,0 @@
/**
* Agent Schema Validation Test Runner
*
* Runs all test fixtures and verifies expected outcomes.
* Reports pass/fail for each test and overall coverage statistics.
*
* Usage: node test/test-agent-schema.js
* Exit codes: 0 = all tests pass, 1 = test failures
*/
const fs = require('node:fs');
const path = require('node:path');
const yaml = require('js-yaml');
const { validateAgentFile } = require('../tools/schema/agent.js');
const { glob } = require('glob');
// ANSI color codes
const colors = {
reset: '\u001B[0m',
green: '\u001B[32m',
red: '\u001B[31m',
yellow: '\u001B[33m',
blue: '\u001B[34m',
cyan: '\u001B[36m',
dim: '\u001B[2m',
};
/**
* Parse test metadata from YAML comments
* @param {string} filePath
* @returns {{shouldPass: boolean, errorExpectation?: object, pathContext?: string}}
*/
function parseTestMetadata(filePath) {
const content = fs.readFileSync(filePath, 'utf8');
const lines = content.split('\n');
let shouldPass = true;
let pathContext = null;
const errorExpectation = {};
for (const line of lines) {
if (line.includes('Expected: PASS')) {
shouldPass = true;
} else if (line.includes('Expected: FAIL')) {
shouldPass = false;
}
// Parse error metadata
const codeMatch = line.match(/^# Error code: (.+)$/);
if (codeMatch) {
errorExpectation.code = codeMatch[1].trim();
}
const pathMatch = line.match(/^# Error path: (.+)$/);
if (pathMatch) {
errorExpectation.path = pathMatch[1].trim();
}
const messageMatch = line.match(/^# Error message: (.+)$/);
if (messageMatch) {
errorExpectation.message = messageMatch[1].trim();
}
const minimumMatch = line.match(/^# Error minimum: (\d+)$/);
if (minimumMatch) {
errorExpectation.minimum = parseInt(minimumMatch[1], 10);
}
const expectedMatch = line.match(/^# Error expected: (.+)$/);
if (expectedMatch) {
errorExpectation.expected = expectedMatch[1].trim();
}
const receivedMatch = line.match(/^# Error received: (.+)$/);
if (receivedMatch) {
errorExpectation.received = receivedMatch[1].trim();
}
const keysMatch = line.match(/^# Error keys: \[(.+)\]$/);
if (keysMatch) {
errorExpectation.keys = keysMatch[1].split(',').map((k) => k.trim().replaceAll(/['"]/g, ''));
}
const contextMatch = line.match(/^# Path context: (.+)$/);
if (contextMatch) {
pathContext = contextMatch[1].trim();
}
}
return {
shouldPass,
errorExpectation: Object.keys(errorExpectation).length > 0 ? errorExpectation : null,
pathContext,
};
}
/**
* Convert dot-notation path string to array (handles array indices)
* e.g., "agent.menu[0].trigger" => ["agent", "menu", 0, "trigger"]
*/
function parsePathString(pathString) {
return pathString
.replaceAll(/\[(\d+)\]/g, '.$1') // Convert [0] to .0
.split('.')
.map((part) => {
const num = parseInt(part, 10);
return isNaN(num) ? part : num;
});
}
/**
* Validate error against expectations
* @param {object} error - Zod error issue
* @param {object} expectation - Expected error structure
* @returns {{valid: boolean, reason?: string}}
*/
function validateError(error, expectation) {
// Check error code
if (expectation.code && error.code !== expectation.code) {
return { valid: false, reason: `Expected code "${expectation.code}", got "${error.code}"` };
}
// Check error path
if (expectation.path) {
const expectedPath = parsePathString(expectation.path);
const actualPath = error.path;
if (JSON.stringify(expectedPath) !== JSON.stringify(actualPath)) {
return {
valid: false,
reason: `Expected path ${JSON.stringify(expectedPath)}, got ${JSON.stringify(actualPath)}`,
};
}
}
// For custom errors, strictly check message
if (expectation.code === 'custom' && expectation.message && error.message !== expectation.message) {
return {
valid: false,
reason: `Expected message "${expectation.message}", got "${error.message}"`,
};
}
// For Zod errors, check type-specific fields
if (expectation.minimum !== undefined && error.minimum !== expectation.minimum) {
return { valid: false, reason: `Expected minimum ${expectation.minimum}, got ${error.minimum}` };
}
if (expectation.expected && error.expected !== expectation.expected) {
return { valid: false, reason: `Expected type "${expectation.expected}", got "${error.expected}"` };
}
if (expectation.received && error.received !== expectation.received) {
return { valid: false, reason: `Expected received "${expectation.received}", got "${error.received}"` };
}
if (expectation.keys) {
const expectedKeys = expectation.keys.sort();
const actualKeys = (error.keys || []).sort();
if (JSON.stringify(expectedKeys) !== JSON.stringify(actualKeys)) {
return {
valid: false,
reason: `Expected keys ${JSON.stringify(expectedKeys)}, got ${JSON.stringify(actualKeys)}`,
};
}
}
return { valid: true };
}
/**
* Run a single test case
* @param {string} filePath
* @returns {{passed: boolean, message: string}}
*/
function runTest(filePath) {
const metadata = parseTestMetadata(filePath);
const { shouldPass, errorExpectation, pathContext } = metadata;
try {
const fileContent = fs.readFileSync(filePath, 'utf8');
let agentData;
try {
agentData = yaml.load(fileContent);
} catch (parseError) {
// YAML parse error
if (shouldPass) {
return {
passed: false,
message: `Expected PASS but got YAML parse error: ${parseError.message}`,
};
}
return {
passed: true,
message: 'Got expected YAML parse error',
};
}
// Determine validation path
// If pathContext is specified in comments, use it; otherwise derive from fixture location
let validationPath = pathContext;
if (!validationPath) {
// Map fixture location to simulated src/ path
const relativePath = path.relative(path.join(__dirname, 'fixtures/agent-schema'), filePath);
const parts = relativePath.split(path.sep);
if (parts.includes('metadata') && parts[0] === 'valid') {
// Valid metadata tests: check if filename suggests module or core
const filename = path.basename(filePath);
if (filename.includes('module')) {
validationPath = 'src/modules/bmm/agents/test.agent.yaml';
} else {
validationPath = 'src/core/agents/test.agent.yaml';
}
} else if (parts.includes('metadata') && parts[0] === 'invalid') {
// Invalid metadata tests: derive from filename
const filename = path.basename(filePath);
if (filename.includes('module') || filename.includes('wrong-module')) {
validationPath = 'src/modules/bmm/agents/test.agent.yaml';
} else if (filename.includes('core')) {
validationPath = 'src/core/agents/test.agent.yaml';
} else {
validationPath = 'src/core/agents/test.agent.yaml';
}
} else {
// Default to core agent path
validationPath = 'src/core/agents/test.agent.yaml';
}
}
const result = validateAgentFile(validationPath, agentData);
if (result.success && shouldPass) {
return {
passed: true,
message: 'Validation passed as expected',
};
}
if (!result.success && !shouldPass) {
const actualError = result.error.issues[0];
// If we have error expectations, validate strictly
if (errorExpectation) {
const validation = validateError(actualError, errorExpectation);
if (!validation.valid) {
return {
passed: false,
message: `Error validation failed: ${validation.reason}`,
};
}
return {
passed: true,
message: `Got expected error (${errorExpectation.code}): ${actualError.message}`,
};
}
// No specific expectations - just check that it failed
return {
passed: true,
message: `Got expected validation error: ${actualError?.message}`,
};
}
if (result.success && !shouldPass) {
return {
passed: false,
message: 'Expected validation to FAIL but it PASSED',
};
}
if (!result.success && shouldPass) {
return {
passed: false,
message: `Expected validation to PASS but it FAILED: ${result.error.issues[0]?.message}`,
};
}
return {
passed: false,
message: 'Unexpected test state',
};
} catch (error) {
return {
passed: false,
message: `Test execution error: ${error.message}`,
};
}
}
/**
* Main test runner
*/
async function main() {
console.log(`${colors.cyan}╔═══════════════════════════════════════════════════════════╗${colors.reset}`);
console.log(`${colors.cyan}║ Agent Schema Validation Test Suite ║${colors.reset}`);
console.log(`${colors.cyan}╚═══════════════════════════════════════════════════════════╝${colors.reset}\n`);
// Find all test fixtures
const testFiles = await glob('test/fixtures/agent-schema/**/*.agent.yaml', {
cwd: path.join(__dirname, '..'),
absolute: true,
});
if (testFiles.length === 0) {
console.log(`${colors.yellow}⚠️ No test fixtures found${colors.reset}`);
process.exit(0);
}
console.log(`Found ${colors.cyan}${testFiles.length}${colors.reset} test fixture(s)\n`);
// Group tests by category
const categories = {};
for (const testFile of testFiles) {
const relativePath = path.relative(path.join(__dirname, 'fixtures/agent-schema'), testFile);
const parts = relativePath.split(path.sep);
const validInvalid = parts[0]; // 'valid' or 'invalid'
const category = parts[1]; // 'top-level', 'metadata', etc.
const categoryKey = `${validInvalid}/${category}`;
if (!categories[categoryKey]) {
categories[categoryKey] = [];
}
categories[categoryKey].push(testFile);
}
// Run tests by category
let totalTests = 0;
let passedTests = 0;
const failures = [];
for (const [categoryKey, files] of Object.entries(categories).sort()) {
const [validInvalid, category] = categoryKey.split('/');
const categoryLabel = category.replaceAll('-', ' ').toUpperCase();
const validLabel = validInvalid === 'valid' ? '✅' : '❌';
console.log(`${colors.blue}${validLabel} ${categoryLabel} (${validInvalid})${colors.reset}`);
for (const testFile of files) {
totalTests++;
const testName = path.basename(testFile, '.agent.yaml');
const result = runTest(testFile);
if (result.passed) {
passedTests++;
console.log(` ${colors.green}${colors.reset} ${testName} ${colors.dim}${result.message}${colors.reset}`);
} else {
console.log(` ${colors.red}${colors.reset} ${testName} ${colors.red}${result.message}${colors.reset}`);
failures.push({
file: path.relative(process.cwd(), testFile),
message: result.message,
});
}
}
console.log('');
}
// Summary
console.log(`${colors.cyan}═══════════════════════════════════════════════════════════${colors.reset}`);
console.log(`${colors.cyan}Test Results:${colors.reset}`);
console.log(` Total: ${totalTests}`);
console.log(` Passed: ${colors.green}${passedTests}${colors.reset}`);
console.log(` Failed: ${passedTests === totalTests ? colors.green : colors.red}${totalTests - passedTests}${colors.reset}`);
console.log(`${colors.cyan}═══════════════════════════════════════════════════════════${colors.reset}\n`);
// Report failures
if (failures.length > 0) {
console.log(`${colors.red}❌ FAILED TESTS:${colors.reset}\n`);
for (const failure of failures) {
console.log(`${colors.red}${colors.reset} ${failure.file}`);
console.log(` ${failure.message}\n`);
}
process.exit(1);
}
console.log(`${colors.green}✨ All tests passed!${colors.reset}\n`);
process.exit(0);
}
// Run
main().catch((error) => {
console.error(`${colors.red}Fatal error:${colors.reset}`, error);
process.exit(1);
});

View File

@@ -1,159 +0,0 @@
#!/bin/bash
# CLI Integration Tests for Agent Schema Validator
# Tests the CLI wrapper (tools/validate-agent-schema.js) behavior and error handling
# NOTE: Tests CLI functionality using temporary test fixtures
echo "========================================"
echo "CLI Integration Tests"
echo "========================================"
echo ""
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
PASSED=0
FAILED=0
# Get the repo root (assuming script is in test/ directory)
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
# Create temp directory for test fixtures
TEMP_DIR=$(mktemp -d)
cleanup() {
rm -rf "$TEMP_DIR"
}
trap cleanup EXIT
# Test 1: CLI fails when no files found (exit 1)
echo "Test 1: CLI fails when no agent files found (should exit 1)"
mkdir -p "$TEMP_DIR/empty/src/core/agents"
OUTPUT=$(node "$REPO_ROOT/tools/validate-agent-schema.js" "$TEMP_DIR/empty" 2>&1)
EXIT_CODE=$?
if [ $EXIT_CODE -eq 1 ] && echo "$OUTPUT" | grep -q "No agent files found"; then
echo -e "${GREEN}${NC} CLI fails correctly when no files found (exit 1)"
PASSED=$((PASSED + 1))
else
echo -e "${RED}${NC} CLI failed to handle no files properly (exit code: $EXIT_CODE)"
FAILED=$((FAILED + 1))
fi
echo ""
# Test 2: CLI reports validation errors with exit code 1
echo "Test 2: CLI reports validation errors (should exit 1)"
mkdir -p "$TEMP_DIR/invalid/src/core/agents"
cat > "$TEMP_DIR/invalid/src/core/agents/bad.agent.yaml" << 'EOF'
agent:
metadata:
id: bad
name: Bad
title: Bad
icon: 🧪
persona:
role: Test
identity: Test
communication_style: Test
principles: []
menu: []
EOF
OUTPUT=$(node "$REPO_ROOT/tools/validate-agent-schema.js" "$TEMP_DIR/invalid" 2>&1)
EXIT_CODE=$?
if [ $EXIT_CODE -eq 1 ] && echo "$OUTPUT" | grep -q "failed validation"; then
echo -e "${GREEN}${NC} CLI reports errors correctly (exit 1)"
PASSED=$((PASSED + 1))
else
echo -e "${RED}${NC} CLI failed to report errors (exit code: $EXIT_CODE)"
FAILED=$((FAILED + 1))
fi
echo ""
# Test 3: CLI discovers and counts agent files correctly
echo "Test 3: CLI discovers and counts agent files"
mkdir -p "$TEMP_DIR/valid/src/core/agents"
cat > "$TEMP_DIR/valid/src/core/agents/test1.agent.yaml" << 'EOF'
agent:
metadata:
id: test1
name: Test1
title: Test1
icon: 🧪
persona:
role: Test
identity: Test
communication_style: Test
principles: [Test]
menu:
- trigger: help
description: Help
action: help
EOF
cat > "$TEMP_DIR/valid/src/core/agents/test2.agent.yaml" << 'EOF'
agent:
metadata:
id: test2
name: Test2
title: Test2
icon: 🧪
persona:
role: Test
identity: Test
communication_style: Test
principles: [Test]
menu:
- trigger: help
description: Help
action: help
EOF
OUTPUT=$(node "$REPO_ROOT/tools/validate-agent-schema.js" "$TEMP_DIR/valid" 2>&1)
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ] && echo "$OUTPUT" | grep -q "Found 2 agent file"; then
echo -e "${GREEN}${NC} CLI discovers and counts files correctly"
PASSED=$((PASSED + 1))
else
echo -e "${RED}${NC} CLI file discovery failed"
echo "Output: $OUTPUT"
FAILED=$((FAILED + 1))
fi
echo ""
# Test 4: CLI provides detailed error messages
echo "Test 4: CLI provides detailed error messages"
OUTPUT=$(node "$REPO_ROOT/tools/validate-agent-schema.js" "$TEMP_DIR/invalid" 2>&1)
if echo "$OUTPUT" | grep -q "Path:" && echo "$OUTPUT" | grep -q "Error:"; then
echo -e "${GREEN}${NC} CLI provides error details (Path and Error)"
PASSED=$((PASSED + 1))
else
echo -e "${RED}${NC} CLI error details missing"
FAILED=$((FAILED + 1))
fi
echo ""
# Test 5: CLI validates real BMAD agents (smoke test)
echo "Test 5: CLI validates actual BMAD agents (smoke test)"
OUTPUT=$(node "$REPO_ROOT/tools/validate-agent-schema.js" 2>&1)
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ] && echo "$OUTPUT" | grep -qE "Found [0-9]+ agent file"; then
echo -e "${GREEN}${NC} CLI validates real BMAD agents successfully"
PASSED=$((PASSED + 1))
else
echo -e "${RED}${NC} CLI failed on real BMAD agents (exit code: $EXIT_CODE)"
FAILED=$((FAILED + 1))
fi
echo ""
# Summary
echo "========================================"
echo "Test Results:"
echo " Passed: ${GREEN}$PASSED${NC}"
echo " Failed: ${RED}$FAILED${NC}"
echo "========================================"
if [ $FAILED -eq 0 ]; then
echo -e "\n${GREEN}✨ All CLI integration tests passed!${NC}\n"
exit 0
else
echo -e "\n${RED}❌ Some CLI integration tests failed${NC}\n"
exit 1
fi

View File

@@ -1,133 +0,0 @@
/**
* Unit Tests for Agent Schema Edge Cases
*
* Tests internal functions to achieve 100% branch coverage
*/
const { validateAgentFile } = require('../tools/schema/agent.js');
console.log('Running edge case unit tests...\n');
let passed = 0;
let failed = 0;
// Test 1: Path with malformed module structure (no slash after module name)
// This tests line 213: slashIndex === -1
console.log('Test 1: Malformed module path (no slash after module name)');
try {
const result = validateAgentFile('src/modules/bmm', {
agent: {
metadata: {
id: 'test',
name: 'Test',
title: 'Test',
icon: '🧪',
},
persona: {
role: 'Test',
identity: 'Test',
communication_style: 'Test',
principles: ['Test'],
},
menu: [{ trigger: 'help', description: 'Help', action: 'help' }],
},
});
if (result.success) {
console.log('✗ Should have failed - missing module field');
failed++;
} else {
console.log('✓ Correctly handled malformed path (treated as core agent)');
passed++;
}
} catch (error) {
console.log('✗ Unexpected error:', error.message);
failed++;
}
console.log('');
// Test 2: Module option with empty string
// This tests line 222: trimmed.length > 0
console.log('Test 2: Module agent with empty string in module field');
try {
const result = validateAgentFile('src/modules/bmm/agents/test.agent.yaml', {
agent: {
metadata: {
id: 'test',
name: 'Test',
title: 'Test',
icon: '🧪',
module: ' ', // Empty after trimming
},
persona: {
role: 'Test',
identity: 'Test',
communication_style: 'Test',
principles: ['Test'],
},
menu: [{ trigger: 'help', description: 'Help', action: 'help' }],
},
});
if (result.success) {
console.log('✗ Should have failed - empty module string');
failed++;
} else {
console.log('✓ Correctly rejected empty module string');
passed++;
}
} catch (error) {
console.log('✗ Unexpected error:', error.message);
failed++;
}
console.log('');
// Test 3: Core agent path (src/core/agents/...) - tests the !filePath.startsWith(marker) branch
console.log('Test 3: Core agent path returns null for module');
try {
const result = validateAgentFile('src/core/agents/test.agent.yaml', {
agent: {
metadata: {
id: 'test',
name: 'Test',
title: 'Test',
icon: '🧪',
// No module field - correct for core agent
},
persona: {
role: 'Test',
identity: 'Test',
communication_style: 'Test',
principles: ['Test'],
},
menu: [{ trigger: 'help', description: 'Help', action: 'help' }],
},
});
if (result.success) {
console.log('✓ Core agent validated correctly (no module required)');
passed++;
} else {
console.log('✗ Core agent should pass without module field');
failed++;
}
} catch (error) {
console.log('✗ Unexpected error:', error.message);
failed++;
}
console.log('');
// Summary
console.log('═══════════════════════════════════════');
console.log('Edge Case Unit Test Results:');
console.log(` Passed: ${passed}`);
console.log(` Failed: ${failed}`);
console.log('═══════════════════════════════════════\n');
if (failed === 0) {
console.log('✨ All edge case tests passed!\n');
process.exit(0);
} else {
console.log('❌ Some edge case tests failed\n');
process.exit(1);
}

View File

@@ -1,7 +1,6 @@
const path = require('node:path');
const { BaseIdeSetup } = require('./_base-ide');
const chalk = require('chalk');
const { getAgentsFromBmad, getTasksFromBmad } = require('./shared/bmad-artifacts');
/**
* Qwen Code setup handler
@@ -12,7 +11,7 @@ class QwenSetup extends BaseIdeSetup {
super('qwen', 'Qwen Code');
this.configDir = '.qwen';
this.commandsDir = 'commands';
this.bmadDir = 'bmad';
this.bmadDir = 'BMad';
}
/**
@@ -28,8 +27,11 @@ class QwenSetup extends BaseIdeSetup {
const qwenDir = path.join(projectDir, this.configDir);
const commandsDir = path.join(qwenDir, this.commandsDir);
const bmadCommandsDir = path.join(commandsDir, this.bmadDir);
const agentsDir = path.join(bmadCommandsDir, 'agents');
const tasksDir = path.join(bmadCommandsDir, 'tasks');
await this.ensureDir(bmadCommandsDir);
await this.ensureDir(agentsDir);
await this.ensureDir(tasksDir);
// Update existing settings.json if present
await this.updateSettings(qwenDir);
@@ -38,55 +40,68 @@ class QwenSetup extends BaseIdeSetup {
await this.cleanupOldConfig(qwenDir);
// Get agents and tasks
const agents = await getAgentsFromBmad(bmadDir, options.selectedModules || []);
const tasks = await getTasksFromBmad(bmadDir, options.selectedModules || []);
// Create directories for each module (including standalone)
const modules = new Set();
for (const item of [...agents, ...tasks]) modules.add(item.module);
for (const module of modules) {
await this.ensureDir(path.join(bmadCommandsDir, module));
await this.ensureDir(path.join(bmadCommandsDir, module, 'agents'));
await this.ensureDir(path.join(bmadCommandsDir, module, 'tasks'));
}
const agents = await this.getAgents(bmadDir);
const tasks = await this.getTasks(bmadDir);
// Create TOML files for each agent
let agentCount = 0;
for (const agent of agents) {
const content = await this.readAndProcess(agent.path, {
module: agent.module,
name: agent.name,
});
const targetPath = path.join(bmadCommandsDir, agent.module, 'agents', `${agent.name}.toml`);
await this.writeFile(targetPath, content);
const content = await this.readFile(agent.path);
const tomlContent = this.createAgentToml(agent, content, projectDir);
const tomlPath = path.join(agentsDir, `${agent.name}.toml`);
await this.writeFile(tomlPath, tomlContent);
agentCount++;
console.log(chalk.green(` ✓ Added agent: /bmad:${agent.module}:agents:${agent.name}`));
console.log(chalk.green(` ✓ Added agent: /BMad:agents:${agent.name}`));
}
// Create TOML files for each task
let taskCount = 0;
for (const task of tasks) {
const content = await this.readAndProcess(task.path, {
module: task.module,
name: task.name,
});
const targetPath = path.join(bmadCommandsDir, task.module, 'agents', `${agent.name}.toml`);
await this.writeFile(targetPath, content);
const content = await this.readFile(task.path);
const tomlContent = this.createTaskToml(task, content, projectDir);
const tomlPath = path.join(tasksDir, `${task.name}.toml`);
await this.writeFile(tomlPath, tomlContent);
taskCount++;
console.log(chalk.green(` ✓ Added task: /bmad:${task.module}:tasks:${task.name}`));
console.log(chalk.green(` ✓ Added task: /BMad:tasks:${task.name}`));
}
// Create concatenated QWEN.md for reference
let concatenatedContent = `# BMAD Method - Qwen Code Configuration
This file contains all BMAD agents and tasks configured for use with Qwen Code.
## Agents
Agents can be activated using: \`/BMad:agents:<agent-name>\`
## Tasks
Tasks can be executed using: \`/BMad:tasks:<task-name>\`
---
`;
for (const agent of agents) {
const content = await this.readFile(agent.path);
const agentSection = this.createAgentSection(agent, content, projectDir);
concatenatedContent += agentSection;
concatenatedContent += '\n\n---\n\n';
}
for (const task of tasks) {
const content = await this.readFile(task.path);
const taskSection = this.createTaskSection(task, content, projectDir);
concatenatedContent += taskSection;
concatenatedContent += '\n\n---\n\n';
}
const qwenMdPath = path.join(bmadCommandsDir, 'QWEN.md');
await this.writeFile(qwenMdPath, concatenatedContent);
console.log(chalk.green(`${this.name} configured:`));
console.log(chalk.dim(` - ${agentCount} agents configured`));
console.log(chalk.dim(` - ${taskCount} tasks configured`));
console.log(chalk.dim(` - Commands directory: ${path.relative(projectDir, bmadCommandsDir)}`));
console.log(chalk.dim(` - Agents activated with: /BMad:agents:<agent-name>`));
console.log(chalk.dim(` - Tasks activated with: /BMad:tasks:<task-name>`));
return {
success: true,
@@ -137,7 +152,6 @@ class QwenSetup extends BaseIdeSetup {
const fs = require('fs-extra');
const agentsDir = path.join(qwenDir, 'agents');
const bmadMethodDir = path.join(qwenDir, 'bmad-method');
const bmadDir = path.join(qwenDir, 'bmadDir');
if (await fs.pathExists(agentsDir)) {
await fs.remove(agentsDir);
@@ -148,57 +162,135 @@ class QwenSetup extends BaseIdeSetup {
await fs.remove(bmadMethodDir);
console.log(chalk.green(' ✓ Removed old bmad-method directory'));
}
if (await fs.pathExists(bmadDir)) {
await fs.remove(bmadDir);
console.log(chalk.green(' ✓ Removed old BMad directory'));
}
}
/**
* Read and process file content
* Create TOML file for agent
*/
async readAndProcess(filePath, metadata) {
const fs = require('fs-extra');
const content = await fs.readFile(filePath, 'utf8');
return this.processContent(content, metadata);
}
/**
* Override processContent to add TOML metadata header for Qwen
* @param {string} content - File content
* @param {Object} metadata - File metadata
* @returns {string} Processed content with Qwen template
*/
processContent(content, metadata = {}) {
// First apply base processing (includes activation injection for agents)
let prompt = super.processContent(content, metadata);
// Determine the type and description based on content
const isAgent = content.includes('<agent');
const isTask = content.includes('<task');
let description = '';
if (isAgent) {
// Extract agent title if available
createAgentToml(agent, content, projectDir) {
const titleMatch = content.match(/title="([^"]+)"/);
const title = titleMatch ? titleMatch[1] : metadata.name;
description = `BMAD ${metadata.module.toUpperCase()} Agent: ${title}`;
} else if (isTask) {
// Extract task name if available
const nameMatch = content.match(/<name>([^<]+)<\/name>/);
const taskName = nameMatch ? nameMatch[1] : metadata.name;
description = `BMAD ${metadata.module.toUpperCase()} Task: ${taskName}`;
} else {
description = `BMAD ${metadata.module.toUpperCase()}: ${metadata.name}`;
const title = titleMatch ? titleMatch[1] : this.formatTitle(agent.name);
const yamlMatch = content.match(/```ya?ml\r?\n([\s\S]*?)```/);
const yamlContent = yamlMatch ? yamlMatch[1] : content;
const relativePath = path.relative(projectDir, agent.path).replaceAll('\\', '/');
return `# ${title} Agent
name = "${agent.name}"
description = """
${title} agent from BMAD ${agent.module.toUpperCase()} module.
CRITICAL: Read the full YAML, start activation to alter your state of being, follow startup section instructions, stay in this being until told to exit this mode:
\`\`\`yaml
${yamlContent}
\`\`\`
File: ${relativePath}
"""`;
}
return `description = "${description}"
prompt = """
${prompt}
"""
`;
/**
* Create TOML file for task
*/
createTaskToml(task, content, projectDir) {
const titleMatch = content.match(/title="([^"]+)"/);
const title = titleMatch ? titleMatch[1] : this.formatTitle(task.name);
const yamlMatch = content.match(/```ya?ml\r?\n([\s\S]*?)```/);
const yamlContent = yamlMatch ? yamlMatch[1] : content;
const relativePath = path.relative(projectDir, task.path).replaceAll('\\', '/');
return `# ${title} Task
name = "${task.name}"
description = """
${title} task from BMAD ${task.module.toUpperCase()} module.
Execute this task by following the instructions in the YAML configuration:
\`\`\`yaml
${yamlContent}
\`\`\`
File: ${relativePath}
"""`;
}
/**
* Create agent section for concatenated file
*/
createAgentSection(agent, content, projectDir) {
// Extract metadata
const titleMatch = content.match(/title="([^"]+)"/);
const title = titleMatch ? titleMatch[1] : this.formatTitle(agent.name);
// Extract YAML content
const yamlMatch = content.match(/```ya?ml\r?\n([\s\S]*?)```/);
const yamlContent = yamlMatch ? yamlMatch[1] : content;
// Get relative path
const relativePath = path.relative(projectDir, agent.path).replaceAll('\\', '/');
let section = `# ${agent.name.toUpperCase()} Agent Rule
This rule is triggered when the user types \`/BMad:agents:${agent.name}\` and activates the ${title} agent persona.
## Agent Activation
CRITICAL: Read the full YAML, start activation to alter your state of being, follow startup section instructions, stay in this being until told to exit this mode:
\`\`\`yaml
${yamlContent}
\`\`\`
## File Reference
The complete agent definition is available in [${relativePath}](${relativePath}).
## Usage
When the user types \`/BMad:agents:${agent.name}\`, activate this ${title} persona and follow all instructions defined in the YAML configuration above.
## Module
Part of the BMAD ${agent.module.toUpperCase()} module.`;
return section;
}
/**
* Create task section for concatenated file
*/
createTaskSection(task, content, projectDir) {
const titleMatch = content.match(/title="([^"]+)"/);
const title = titleMatch ? titleMatch[1] : this.formatTitle(task.name);
const yamlMatch = content.match(/```ya?ml\r?\n([\s\S]*?)```/);
const yamlContent = yamlMatch ? yamlMatch[1] : content;
const relativePath = path.relative(projectDir, task.path).replaceAll('\\', '/');
let section = `# ${task.name.toUpperCase()} Task
This task is triggered when the user types \`/BMad:tasks:${task.name}\` and executes the ${title} task.
## Task Execution
Execute this task by following the instructions in the YAML configuration:
\`\`\`yaml
${yamlContent}
\`\`\`
## File Reference
The complete task definition is available in [${relativePath}](${relativePath}).
## Usage
When the user types \`/BMad:tasks:${task.name}\`, execute this ${title} task and follow all instructions defined in the YAML configuration above.
## Module
Part of the BMAD ${task.module.toUpperCase()} module.`;
return section;
}
/**
@@ -218,7 +310,6 @@ ${prompt}
const fs = require('fs-extra');
const bmadCommandsDir = path.join(projectDir, this.configDir, this.commandsDir, this.bmadDir);
const oldBmadMethodDir = path.join(projectDir, this.configDir, 'bmad-method');
const oldBMadDir = path.join(projectDir, this.configDir, 'BMad');
if (await fs.pathExists(bmadCommandsDir)) {
await fs.remove(bmadCommandsDir);
@@ -229,11 +320,6 @@ ${prompt}
await fs.remove(oldBmadMethodDir);
console.log(chalk.dim(`Removed old BMAD configuration from Qwen Code`));
}
if (await fs.pathExists(oldBMadDir)) {
await fs.remove(oldBMadDir);
console.log(chalk.dim(`Removed old BMAD configuration from Qwen Code`));
}
}
}

View File

@@ -1,231 +0,0 @@
// Zod schema definition for *.agent.yaml files
const assert = require('node:assert');
const { z } = require('zod');
const COMMAND_TARGET_KEYS = ['workflow', 'validate-workflow', 'exec', 'action', 'tmpl', 'data', 'run-workflow'];
const TRIGGER_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
// Public API ---------------------------------------------------------------
/**
* Validate an agent YAML payload against the schema derived from its file location.
* Exposed as the single public entry point, so callers do not reach into schema internals.
*
* @param {string} filePath Path to the agent file (used to infer module scope).
* @param {unknown} agentYaml Parsed YAML content.
* @returns {import('zod').SafeParseReturnType<unknown, unknown>} SafeParse result.
*/
function validateAgentFile(filePath, agentYaml) {
const expectedModule = deriveModuleFromPath(filePath);
const schema = agentSchema({ module: expectedModule });
return schema.safeParse(agentYaml);
}
module.exports = { validateAgentFile };
// Internal helpers ---------------------------------------------------------
/**
* Build a Zod schema for validating a single agent definition.
* The schema is generated per call so module-scoped agents can pass their expected
* module slug while core agents leave it undefined.
*
* @param {Object} [options]
* @param {string|null|undefined} [options.module] Module slug for module agents; omit or null for core agents.
* @returns {import('zod').ZodSchema} Configured Zod schema instance.
*/
function agentSchema(options = {}) {
const expectedModule = normalizeModuleOption(options.module);
return (
z
.object({
agent: buildAgentSchema(expectedModule),
})
.strict()
// Refinement: enforce trigger format and uniqueness rules after structural checks.
.superRefine((value, ctx) => {
const seenTriggers = new Set();
let index = 0;
for (const item of value.agent.menu) {
const triggerValue = item.trigger;
if (!TRIGGER_PATTERN.test(triggerValue)) {
ctx.addIssue({
code: 'custom',
path: ['agent', 'menu', index, 'trigger'],
message: 'agent.menu[].trigger must be kebab-case (lowercase words separated by hyphen)',
});
return;
}
if (seenTriggers.has(triggerValue)) {
ctx.addIssue({
code: 'custom',
path: ['agent', 'menu', index, 'trigger'],
message: `agent.menu[].trigger duplicates "${triggerValue}" within the same agent`,
});
return;
}
seenTriggers.add(triggerValue);
index += 1;
}
})
);
}
/**
* Assemble the full agent schema using the module expectation provided by the caller.
* @param {string|null} expectedModule Trimmed module slug or null for core agents.
*/
function buildAgentSchema(expectedModule) {
return z
.object({
metadata: buildMetadataSchema(expectedModule),
persona: buildPersonaSchema(),
critical_actions: z.array(createNonEmptyString('agent.critical_actions[]')).optional(),
menu: z.array(buildMenuItemSchema()).min(1, { message: 'agent.menu must include at least one entry' }),
prompts: z.array(buildPromptSchema()).optional(),
})
.strict();
}
/**
* Validate metadata shape and cross-check module expectation against caller input.
* @param {string|null} expectedModule Trimmed module slug or null when core agent metadata is expected.
*/
function buildMetadataSchema(expectedModule) {
const schemaShape = {
id: createNonEmptyString('agent.metadata.id'),
name: createNonEmptyString('agent.metadata.name'),
title: createNonEmptyString('agent.metadata.title'),
icon: createNonEmptyString('agent.metadata.icon'),
module: createNonEmptyString('agent.metadata.module').optional(),
};
return (
z
.object(schemaShape)
.strict()
// Refinement: guard presence and correctness of metadata.module.
.superRefine((value, ctx) => {
const moduleValue = typeof value.module === 'string' ? value.module.trim() : null;
if (expectedModule && !moduleValue) {
ctx.addIssue({
code: 'custom',
path: ['module'],
message: 'module-scoped agents must declare agent.metadata.module',
});
} else if (!expectedModule && moduleValue) {
ctx.addIssue({
code: 'custom',
path: ['module'],
message: 'core agents must not include agent.metadata.module',
});
} else if (expectedModule && moduleValue !== expectedModule) {
ctx.addIssue({
code: 'custom',
path: ['module'],
message: `agent.metadata.module must equal "${expectedModule}"`,
});
}
})
);
}
function buildPersonaSchema() {
return z
.object({
role: createNonEmptyString('agent.persona.role'),
identity: createNonEmptyString('agent.persona.identity'),
communication_style: createNonEmptyString('agent.persona.communication_style'),
principles: z
.array(createNonEmptyString('agent.persona.principles[]'))
.min(1, { message: 'agent.persona.principles must include at least one entry' }),
})
.strict();
}
function buildPromptSchema() {
return z
.object({
id: createNonEmptyString('agent.prompts[].id'),
content: z.string().refine((value) => value.trim().length > 0, {
message: 'agent.prompts[].content must be a non-empty string',
}),
description: createNonEmptyString('agent.prompts[].description').optional(),
})
.strict();
}
/**
* Schema for individual menu entries ensuring they are actionable.
*/
function buildMenuItemSchema() {
return z
.object({
trigger: createNonEmptyString('agent.menu[].trigger'),
description: createNonEmptyString('agent.menu[].description'),
workflow: createNonEmptyString('agent.menu[].workflow').optional(),
'validate-workflow': createNonEmptyString('agent.menu[].validate-workflow').optional(),
exec: createNonEmptyString('agent.menu[].exec').optional(),
action: createNonEmptyString('agent.menu[].action').optional(),
tmpl: createNonEmptyString('agent.menu[].tmpl').optional(),
data: createNonEmptyString('agent.menu[].data').optional(),
'run-workflow': createNonEmptyString('agent.menu[].run-workflow').optional(),
})
.strict()
.superRefine((value, ctx) => {
const hasCommandTarget = COMMAND_TARGET_KEYS.some((key) => {
const commandValue = value[key];
return typeof commandValue === 'string' && commandValue.trim().length > 0;
});
if (!hasCommandTarget) {
ctx.addIssue({
code: 'custom',
message: 'agent.menu[] entries must include at least one command target field',
});
}
});
}
/**
* Derive the expected module slug from a file path residing under src/modules/<module>/agents/.
* @param {string} filePath Absolute or relative agent path.
* @returns {string|null} Module slug if identifiable, otherwise null.
*/
function deriveModuleFromPath(filePath) {
assert(filePath, 'validateAgentFile expects filePath to be provided');
assert(typeof filePath === 'string', 'validateAgentFile expects filePath to be a string');
assert(filePath.startsWith('src/'), 'validateAgentFile expects filePath to start with "src/"');
const marker = 'src/modules/';
if (!filePath.startsWith(marker)) {
return null;
}
const remainder = filePath.slice(marker.length);
const slashIndex = remainder.indexOf('/');
return slashIndex === -1 ? null : remainder.slice(0, slashIndex);
}
function normalizeModuleOption(moduleOption) {
if (typeof moduleOption !== 'string') {
return null;
}
const trimmed = moduleOption.trim();
return trimmed.length > 0 ? trimmed : null;
}
// Primitive validators -----------------------------------------------------
function createNonEmptyString(label) {
return z.string().refine((value) => value.trim().length > 0, {
message: `${label} must be a non-empty string`,
});
}

View File

@@ -1,110 +0,0 @@
/**
* Agent Schema Validator CLI
*
* Scans all *.agent.yaml files in src/{core,modules/*}/agents/
* and validates them against the Zod schema.
*
* Usage: node tools/validate-agent-schema.js [project_root]
* Exit codes: 0 = success, 1 = validation failures
*
* Optional argument:
* project_root - Directory to scan (defaults to BMAD repo root)
*/
const { glob } = require('glob');
const yaml = require('js-yaml');
const fs = require('node:fs');
const path = require('node:path');
const { validateAgentFile } = require('./schema/agent.js');
/**
* Main validation routine
* @param {string} [customProjectRoot] - Optional project root to scan (for testing)
*/
async function main(customProjectRoot) {
console.log('🔍 Scanning for agent files...\n');
// Determine project root: use custom path if provided, otherwise default to repo root
const project_root = customProjectRoot || path.join(__dirname, '..');
// Find all agent files
const agentFiles = await glob('src/{core,modules/*}/agents/*.agent.yaml', {
cwd: project_root,
absolute: true,
});
if (agentFiles.length === 0) {
console.log('❌ No agent files found. This likely indicates a configuration error.');
console.log(' Expected to find *.agent.yaml files in src/{core,modules/*}/agents/');
process.exit(1);
}
console.log(`Found ${agentFiles.length} agent file(s)\n`);
const errors = [];
// Validate each file
for (const filePath of agentFiles) {
const relativePath = path.relative(process.cwd(), filePath);
try {
const fileContent = fs.readFileSync(filePath, 'utf8');
const agentData = yaml.load(fileContent);
// Convert absolute path to relative src/ path for module detection
const srcRelativePath = relativePath.startsWith('src/') ? relativePath : path.relative(project_root, filePath).replaceAll('\\', '/');
const result = validateAgentFile(srcRelativePath, agentData);
if (result.success) {
console.log(`${relativePath}`);
} else {
errors.push({
file: relativePath,
issues: result.error.issues,
});
}
} catch (error) {
errors.push({
file: relativePath,
issues: [
{
code: 'parse_error',
message: `Failed to parse YAML: ${error.message}`,
path: [],
},
],
});
}
}
// Report errors
if (errors.length > 0) {
console.log('\n❌ Validation failed for the following files:\n');
for (const { file, issues } of errors) {
console.log(`\n📄 ${file}`);
for (const issue of issues) {
const pathString = issue.path.length > 0 ? issue.path.join('.') : '(root)';
console.log(` Path: ${pathString}`);
console.log(` Error: ${issue.message}`);
if (issue.code) {
console.log(` Code: ${issue.code}`);
}
}
}
console.log(`\n\n💥 ${errors.length} file(s) failed validation`);
process.exit(1);
}
console.log(`\n✨ All ${agentFiles.length} agent file(s) passed validation!\n`);
process.exit(0);
}
// Run with optional command-line argument for project root
const customProjectRoot = process.argv[2];
main(customProjectRoot).catch((error) => {
console.error('Fatal error:', error);
process.exit(1);
});