@polymorphism-tech/morph-spec 1.0.2 → 2.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.
- package/CLAUDE.md +1381 -0
- package/LICENSE +72 -0
- package/README.md +114 -12
- package/bin/detect-agents.js +225 -0
- package/bin/morph-spec.js +120 -0
- package/bin/render-template.js +302 -0
- package/bin/semantic-detect-agents.js +246 -0
- package/bin/validate-agents-skills.js +239 -0
- package/bin/validate-agents.js +69 -0
- package/bin/validate-phase.js +263 -0
- package/content/.azure/README.md +293 -0
- package/content/.azure/docs/azure-devops-setup.md +454 -0
- package/content/.azure/docs/branch-strategy.md +398 -0
- package/content/.azure/docs/local-development.md +515 -0
- package/content/.azure/pipelines/pipeline-variables.yml +34 -0
- package/content/.azure/pipelines/prod-pipeline.yml +319 -0
- package/content/.azure/pipelines/staging-pipeline.yml +234 -0
- package/content/.azure/pipelines/templates/build-dotnet.yml +75 -0
- package/content/.azure/pipelines/templates/deploy-app-service.yml +94 -0
- package/content/.azure/pipelines/templates/deploy-container-app.yml +120 -0
- package/content/.azure/pipelines/templates/infra-deploy.yml +90 -0
- package/content/.claude/commands/morph-apply.md +118 -26
- package/content/.claude/commands/morph-archive.md +9 -9
- package/content/.claude/commands/morph-clarify.md +184 -0
- package/content/.claude/commands/morph-design.md +275 -0
- package/content/.claude/commands/morph-proposal.md +56 -15
- package/content/.claude/commands/morph-setup.md +100 -0
- package/content/.claude/commands/morph-status.md +47 -32
- package/content/.claude/commands/morph-tasks.md +319 -0
- package/content/.claude/commands/morph-uiux.md +211 -0
- package/content/.claude/skills/specialists/ai-system-architect.md +604 -0
- package/content/.claude/skills/specialists/ms-agent-expert.md +143 -89
- package/content/.claude/skills/specialists/ui-ux-designer.md +744 -9
- package/content/.claude/skills/stacks/dotnet-blazor.md +244 -8
- package/content/.claude/skills/stacks/dotnet-nextjs.md +2 -2
- package/content/.morph/.morphversion +5 -0
- package/content/.morph/config/agents.json +101 -8
- package/content/.morph/config/azure-pricing.json +70 -0
- package/content/.morph/config/azure-pricing.schema.json +50 -0
- package/content/.morph/config/config.template.json +15 -3
- package/content/.morph/docs/STORY-DRIVEN-DEVELOPMENT.md +392 -0
- package/content/.morph/hooks/README.md +239 -0
- package/content/.morph/hooks/pre-commit-agents.sh +24 -0
- package/content/.morph/hooks/pre-commit-all.sh +48 -0
- package/content/.morph/hooks/pre-commit-costs.sh +91 -0
- package/content/.morph/hooks/pre-commit-specs.sh +49 -0
- package/content/.morph/hooks/pre-commit-tests.sh +60 -0
- package/content/.morph/project.md +5 -4
- package/content/.morph/schemas/agent.schema.json +296 -0
- package/content/.morph/standards/agent-framework-setup.md +453 -0
- package/content/.morph/standards/architecture.md +142 -7
- package/content/.morph/standards/azure.md +218 -23
- package/content/.morph/standards/coding.md +47 -12
- package/content/.morph/standards/dotnet10-migration.md +494 -0
- package/content/.morph/standards/fluent-ui-setup.md +590 -0
- package/content/.morph/standards/migration-guide.md +514 -0
- package/content/.morph/standards/passkeys-auth.md +423 -0
- package/content/.morph/standards/vector-search-rag.md +536 -0
- package/content/.morph/state.json +18 -0
- package/content/.morph/templates/FluentDesignTheme.cs +149 -0
- package/content/.morph/templates/MudTheme.cs +281 -0
- package/content/.morph/templates/contracts.cs +55 -55
- package/content/.morph/templates/decisions.md +4 -4
- package/content/.morph/templates/design-system.css +226 -0
- package/content/.morph/templates/infra/.dockerignore.example +89 -0
- package/content/.morph/templates/infra/Dockerfile.example +82 -0
- package/content/.morph/templates/infra/README.md +286 -0
- package/content/.morph/templates/infra/app-service.bicep +164 -0
- package/content/.morph/templates/infra/deploy.ps1 +229 -0
- package/content/.morph/templates/infra/deploy.sh +208 -0
- package/content/.morph/templates/infra/main.bicep +41 -7
- package/content/.morph/templates/infra/parameters.dev.json +6 -0
- package/content/.morph/templates/infra/parameters.prod.json +6 -0
- package/content/.morph/templates/infra/parameters.staging.json +29 -0
- package/content/.morph/templates/proposal.md +3 -3
- package/content/.morph/templates/recap.md +3 -3
- package/content/.morph/templates/spec.md +9 -8
- package/content/.morph/templates/sprint-status.yaml +68 -0
- package/content/.morph/templates/state.template.json +222 -0
- package/content/.morph/templates/story.md +143 -0
- package/content/.morph/templates/tasks.md +1 -1
- package/content/.morph/templates/ui-components.md +276 -0
- package/content/.morph/templates/ui-design-system.md +286 -0
- package/content/.morph/templates/ui-flows.md +336 -0
- package/content/.morph/templates/ui-mockups.md +133 -0
- package/content/.morph/test-infra/example.bicep +59 -0
- package/content/CLAUDE.md +124 -0
- package/content/README.md +79 -0
- package/detectors/config-detector.js +223 -0
- package/detectors/conversation-analyzer.js +163 -0
- package/detectors/index.js +84 -0
- package/detectors/standards-generator.js +275 -0
- package/detectors/structure-detector.js +221 -0
- package/docs/README.md +149 -0
- package/docs/api/cost-calculator.js.html +513 -0
- package/docs/api/design-system-generator.js.html +382 -0
- package/docs/api/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/api/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/api/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/api/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/api/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/api/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/api/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/api/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
- package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
- package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/api/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/api/global.html +5263 -0
- package/docs/api/index.html +96 -0
- package/docs/api/scripts/collapse.js +39 -0
- package/docs/api/scripts/commonNav.js +28 -0
- package/docs/api/scripts/linenumber.js +25 -0
- package/docs/api/scripts/nav.js +12 -0
- package/docs/api/scripts/polyfill.js +4 -0
- package/docs/api/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/api/scripts/prettify/lang-css.js +2 -0
- package/docs/api/scripts/prettify/prettify.js +28 -0
- package/docs/api/scripts/search.js +99 -0
- package/docs/api/state-manager.js.html +423 -0
- package/docs/api/styles/jsdoc.css +776 -0
- package/docs/api/styles/prettify.css +80 -0
- package/docs/examples.md +328 -0
- package/docs/getting-started.md +302 -0
- package/docs/installation.md +361 -0
- package/docs/templates.md +418 -0
- package/docs/validation-checklist.md +266 -0
- package/package.json +39 -12
- package/src/commands/cost.js +181 -0
- package/src/commands/create-story.js +283 -0
- package/src/commands/detect.js +104 -0
- package/src/commands/doctor.js +67 -0
- package/src/commands/generate.js +149 -0
- package/src/commands/init.js +71 -46
- package/src/commands/shard-spec.js +224 -0
- package/src/commands/sprint-status.js +250 -0
- package/src/commands/state.js +333 -0
- package/src/commands/sync.js +167 -0
- package/src/commands/update-pricing.js +206 -0
- package/src/commands/update.js +88 -13
- package/src/lib/complexity-analyzer.js +292 -0
- package/src/lib/cost-calculator.js +429 -0
- package/src/lib/design-system-generator.js +298 -0
- package/src/lib/state-manager.js +340 -0
- package/src/utils/file-copier.js +63 -0
- package/src/utils/version-checker.js +175 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MORPH-SPEC Agent-Skill Validator
|
|
5
|
+
*
|
|
6
|
+
* Valida a consistência entre agents.json e arquivos de skills.
|
|
7
|
+
* Garante que não há agentes sem skills ou skills sem agentes (orphans).
|
|
8
|
+
*
|
|
9
|
+
* Uso:
|
|
10
|
+
* node bin/validate-agents-skills.js
|
|
11
|
+
* node bin/validate-agents-skills.js --verbose
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { readFileSync, existsSync, readdirSync, statSync } from 'fs';
|
|
15
|
+
import { join, dirname } from 'path';
|
|
16
|
+
import { fileURLToPath } from 'url';
|
|
17
|
+
|
|
18
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const AGENTS_CONFIG_PATH = join(__dirname, '../content/.morph/config/agents.json');
|
|
20
|
+
const SKILLS_BASE_PATH = join(__dirname, '../content/.claude/skills');
|
|
21
|
+
|
|
22
|
+
// Cores para output
|
|
23
|
+
const colors = {
|
|
24
|
+
reset: '\x1b[0m',
|
|
25
|
+
bright: '\x1b[1m',
|
|
26
|
+
green: '\x1b[32m',
|
|
27
|
+
yellow: '\x1b[33m',
|
|
28
|
+
red: '\x1b[31m',
|
|
29
|
+
cyan: '\x1b[36m',
|
|
30
|
+
gray: '\x1b[90m'
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function log(message, color = 'reset') {
|
|
34
|
+
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Carrega agents.json
|
|
39
|
+
*/
|
|
40
|
+
function loadAgentsConfig() {
|
|
41
|
+
try {
|
|
42
|
+
const content = readFileSync(AGENTS_CONFIG_PATH, 'utf8');
|
|
43
|
+
return JSON.parse(content);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
log(`ERROR: Failed to load agents.json: ${err.message}`, 'red');
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Recursivamente lista todos os arquivos .md no diretório de skills
|
|
52
|
+
*/
|
|
53
|
+
function getAllSkillFiles(dir, fileList = []) {
|
|
54
|
+
const files = readdirSync(dir);
|
|
55
|
+
|
|
56
|
+
files.forEach(file => {
|
|
57
|
+
const filePath = join(dir, file);
|
|
58
|
+
const stat = statSync(filePath);
|
|
59
|
+
|
|
60
|
+
if (stat.isDirectory()) {
|
|
61
|
+
getAllSkillFiles(filePath, fileList);
|
|
62
|
+
} else if (file.endsWith('.md')) {
|
|
63
|
+
// Converter para path relativo ao content/
|
|
64
|
+
const relativePath = filePath.replace(/\\/g, '/').split('/content/')[1];
|
|
65
|
+
fileList.push(relativePath);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return fileList;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Valida agents vs skills
|
|
74
|
+
*/
|
|
75
|
+
function validateAgentsSkills(config, verbose = false) {
|
|
76
|
+
const errors = [];
|
|
77
|
+
const warnings = [];
|
|
78
|
+
const info = [];
|
|
79
|
+
|
|
80
|
+
// 1. Coletar todos os agentes e seus skillPaths
|
|
81
|
+
const allAgents = [...config.agents.core, ...config.agents.specialists];
|
|
82
|
+
const agentSkillPaths = new Set();
|
|
83
|
+
|
|
84
|
+
for (const agent of allAgents) {
|
|
85
|
+
if (agent.skillPath) {
|
|
86
|
+
agentSkillPaths.add(agent.skillPath);
|
|
87
|
+
|
|
88
|
+
// Verificar se skill file existe
|
|
89
|
+
const skillFilePath = join(__dirname, '../content', agent.skillPath);
|
|
90
|
+
if (!existsSync(skillFilePath)) {
|
|
91
|
+
errors.push({
|
|
92
|
+
type: 'missing-skill',
|
|
93
|
+
agent: agent.id,
|
|
94
|
+
skillPath: agent.skillPath,
|
|
95
|
+
message: `Agent '${agent.id}' references non-existent skill: ${agent.skillPath}`
|
|
96
|
+
});
|
|
97
|
+
} else if (verbose) {
|
|
98
|
+
info.push({
|
|
99
|
+
type: 'valid-mapping',
|
|
100
|
+
agent: agent.id,
|
|
101
|
+
skillPath: agent.skillPath,
|
|
102
|
+
message: `✓ ${agent.id} → ${agent.skillPath}`
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
} else if (verbose) {
|
|
106
|
+
warnings.push({
|
|
107
|
+
type: 'no-skill',
|
|
108
|
+
agent: agent.id,
|
|
109
|
+
message: `Agent '${agent.id}' has no skillPath defined (metadata-only agent)`
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 2. Verificar skills órfãs (sem agente correspondente)
|
|
115
|
+
const allSkillFiles = getAllSkillFiles(SKILLS_BASE_PATH);
|
|
116
|
+
|
|
117
|
+
for (const skillFile of allSkillFiles) {
|
|
118
|
+
const skillPath = `.claude/skills/${skillFile.replace('.claude/skills/', '')}`;
|
|
119
|
+
|
|
120
|
+
if (!agentSkillPaths.has(skillPath)) {
|
|
121
|
+
warnings.push({
|
|
122
|
+
type: 'orphan-skill',
|
|
123
|
+
skillPath: skillPath,
|
|
124
|
+
message: `Skill '${skillPath}' has no corresponding agent in agents.json`
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return { errors, warnings, info };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Formata e exibe resultados
|
|
134
|
+
*/
|
|
135
|
+
function displayResults(results, verbose) {
|
|
136
|
+
const { errors, warnings, info } = results;
|
|
137
|
+
|
|
138
|
+
log('\n╔════════════════════════════════════════════════════════════════╗', 'cyan');
|
|
139
|
+
log('║ MORPH-SPEC AGENT-SKILL VALIDATION REPORT ║', 'cyan');
|
|
140
|
+
log('╠════════════════════════════════════════════════════════════════╣', 'cyan');
|
|
141
|
+
|
|
142
|
+
// Erros
|
|
143
|
+
if (errors.length > 0) {
|
|
144
|
+
log('║ ERRORS ║', 'red');
|
|
145
|
+
log('╠════════════════════════════════════════════════════════════════╣', 'cyan');
|
|
146
|
+
|
|
147
|
+
errors.forEach(err => {
|
|
148
|
+
log(`║ ❌ ${err.message.substring(0, 61).padEnd(61)}║`, 'red');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
log('╠════════════════════════════════════════════════════════════════╣', 'cyan');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Warnings
|
|
155
|
+
if (warnings.length > 0) {
|
|
156
|
+
log('║ WARNINGS ║', 'yellow');
|
|
157
|
+
log('╠════════════════════════════════════════════════════════════════╣', 'cyan');
|
|
158
|
+
|
|
159
|
+
warnings.forEach(warn => {
|
|
160
|
+
// Quebrar mensagens longas
|
|
161
|
+
const lines = warn.message.match(/.{1,60}/g) || [warn.message];
|
|
162
|
+
lines.forEach((line, idx) => {
|
|
163
|
+
if (idx === 0) {
|
|
164
|
+
log(`║ ⚠️ ${line.padEnd(61)}║`, 'yellow');
|
|
165
|
+
} else {
|
|
166
|
+
log(`║ ${line.padEnd(61)}║`, 'yellow');
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
log('╠════════════════════════════════════════════════════════════════╣', 'cyan');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Info (verbose mode)
|
|
175
|
+
if (verbose && info.length > 0) {
|
|
176
|
+
log('║ VALID MAPPINGS ║', 'green');
|
|
177
|
+
log('╠════════════════════════════════════════════════════════════════╣', 'cyan');
|
|
178
|
+
|
|
179
|
+
info.forEach(item => {
|
|
180
|
+
log(`║ ${item.message.substring(0, 62).padEnd(62)}║`, 'gray');
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
log('╠════════════════════════════════════════════════════════════════╣', 'cyan');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Summary
|
|
187
|
+
log('║ SUMMARY ║', 'cyan');
|
|
188
|
+
log('╠════════════════════════════════════════════════════════════════╣', 'cyan');
|
|
189
|
+
log(`║ Errors: ${errors.length.toString().padEnd(56)}║`, errors.length > 0 ? 'red' : 'green');
|
|
190
|
+
log(`║ Warnings: ${warnings.length.toString().padEnd(54)}║`, warnings.length > 0 ? 'yellow' : 'green');
|
|
191
|
+
|
|
192
|
+
if (errors.length === 0 && warnings.length === 0) {
|
|
193
|
+
log('║ ║', 'cyan');
|
|
194
|
+
log('║ ✅ All agents and skills are properly mapped! ║', 'green');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
log('╚════════════════════════════════════════════════════════════════╝\n', 'cyan');
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// ============================================================================
|
|
201
|
+
// MAIN
|
|
202
|
+
// ============================================================================
|
|
203
|
+
|
|
204
|
+
function main() {
|
|
205
|
+
const args = process.argv.slice(2);
|
|
206
|
+
const verbose = args.includes('--verbose') || args.includes('-v');
|
|
207
|
+
const hasHelp = args.includes('--help') || args.includes('-h');
|
|
208
|
+
|
|
209
|
+
if (hasHelp) {
|
|
210
|
+
log('\nMORPH-SPEC Agent-Skill Validator', 'bright');
|
|
211
|
+
log('\nUsage:', 'cyan');
|
|
212
|
+
log(' node bin/validate-agents-skills.js [options]', 'gray');
|
|
213
|
+
log('\nOptions:', 'cyan');
|
|
214
|
+
log(' -v, --verbose Show all valid mappings', 'gray');
|
|
215
|
+
log(' -h, --help Show this help', 'gray');
|
|
216
|
+
log('\nDescription:', 'cyan');
|
|
217
|
+
log(' Validates consistency between agents.json and skill files.', 'gray');
|
|
218
|
+
log(' - Checks if all skillPaths exist', 'gray');
|
|
219
|
+
log(' - Detects orphan skills (no corresponding agent)', 'gray');
|
|
220
|
+
log(' - Exit code 0 if valid, 1 if errors found\n', 'gray');
|
|
221
|
+
process.exit(0);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Load config and validate
|
|
225
|
+
const config = loadAgentsConfig();
|
|
226
|
+
const results = validateAgentsSkills(config, verbose);
|
|
227
|
+
|
|
228
|
+
// Display results
|
|
229
|
+
displayResults(results, verbose);
|
|
230
|
+
|
|
231
|
+
// Exit with appropriate code
|
|
232
|
+
if (results.errors.length > 0) {
|
|
233
|
+
process.exit(1);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
process.exit(0);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
main();
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import Ajv from 'ajv';
|
|
6
|
+
import addFormats from 'ajv-formats';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
function main() {
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
|
|
14
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
15
|
+
console.log('Usage: node bin/validate-agents.js [agents-file-path]');
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const defaultPath = path.join(process.cwd(), 'content/.morph/config/agents.json');
|
|
20
|
+
const agentsPath = args[0] || defaultPath;
|
|
21
|
+
const schemaPath = path.join(__dirname, '../content/.morph/schemas/agent.schema.json');
|
|
22
|
+
|
|
23
|
+
if (!fs.existsSync(agentsPath)) {
|
|
24
|
+
console.error('Error: agents.json not found at', agentsPath);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!fs.existsSync(schemaPath)) {
|
|
29
|
+
console.error('Error: Schema not found at', schemaPath);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const schema = JSON.parse(fs.readFileSync(schemaPath, 'utf-8'));
|
|
35
|
+
const agents = JSON.parse(fs.readFileSync(agentsPath, 'utf-8'));
|
|
36
|
+
|
|
37
|
+
const ajv = new Ajv({ allErrors: true, verbose: true, strict: true });
|
|
38
|
+
addFormats(ajv);
|
|
39
|
+
|
|
40
|
+
const validate = ajv.compile(schema);
|
|
41
|
+
const valid = validate(agents);
|
|
42
|
+
|
|
43
|
+
console.log('\n=== MORPH-SPEC Agent Validator ===\n');
|
|
44
|
+
console.log('Version:', agents.version || 'unknown');
|
|
45
|
+
console.log('Core Agents:', agents.agents?.core?.length || 0);
|
|
46
|
+
console.log('Specialist Agents:', agents.agents?.specialists?.length || 0);
|
|
47
|
+
|
|
48
|
+
if (valid) {
|
|
49
|
+
console.log('\n✓ Validation PASSED\n');
|
|
50
|
+
process.exit(0);
|
|
51
|
+
} else {
|
|
52
|
+
console.log('\n✗ Validation FAILED\n');
|
|
53
|
+
console.log('Errors:');
|
|
54
|
+
validate.errors.forEach((err, i) => {
|
|
55
|
+
console.log(`${i + 1}. ${err.instancePath || '/'}: ${err.message}`);
|
|
56
|
+
if (err.params) {
|
|
57
|
+
console.log(' Params:', JSON.stringify(err.params));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
console.log('');
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('Error:', error.message);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
main();
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MORPH-SPEC Phase Validator
|
|
5
|
+
*
|
|
6
|
+
* Validates that required previous phases have been completed before advancing.
|
|
7
|
+
* Prevents skipping phases accidentally.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* node bin/validate-phase.js <feature-name> <target-phase>
|
|
11
|
+
*
|
|
12
|
+
* Example:
|
|
13
|
+
* node bin/validate-phase.js scheduled-reports implement
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import fs from 'fs';
|
|
17
|
+
import path from 'path';
|
|
18
|
+
import { fileURLToPath } from 'url';
|
|
19
|
+
|
|
20
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
21
|
+
const __dirname = path.dirname(__filename);
|
|
22
|
+
|
|
23
|
+
// ANSI colors
|
|
24
|
+
const colors = {
|
|
25
|
+
green: '\x1b[32m',
|
|
26
|
+
red: '\x1b[31m',
|
|
27
|
+
yellow: '\x1b[33m',
|
|
28
|
+
cyan: '\x1b[36m',
|
|
29
|
+
gray: '\x1b[90m',
|
|
30
|
+
reset: '\x1b[0m'
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Phase definitions with requirements
|
|
34
|
+
const PHASES = {
|
|
35
|
+
'proposal': {
|
|
36
|
+
order: 0,
|
|
37
|
+
name: 'FASE 0: PROPOSAL',
|
|
38
|
+
requiredOutputs: ['proposal.md'],
|
|
39
|
+
description: 'Initial proposal and agent detection'
|
|
40
|
+
},
|
|
41
|
+
'setup': {
|
|
42
|
+
order: 1,
|
|
43
|
+
name: 'FASE 1: SETUP',
|
|
44
|
+
requiredOutputs: ['proposal.md'],
|
|
45
|
+
description: 'Load context and standards'
|
|
46
|
+
},
|
|
47
|
+
'uiux-design': {
|
|
48
|
+
order: 2,
|
|
49
|
+
name: 'FASE 1.5: UI/UX DESIGN',
|
|
50
|
+
requiredOutputs: ['proposal.md', 'ui-design-system.md', 'ui-mockups.md', 'ui-components.md', 'ui-flows.md'],
|
|
51
|
+
description: 'UI/UX design (conditional - only if frontend)',
|
|
52
|
+
optional: true
|
|
53
|
+
},
|
|
54
|
+
'design': {
|
|
55
|
+
order: 3,
|
|
56
|
+
name: 'FASE 2: DESIGN',
|
|
57
|
+
requiredOutputs: ['proposal.md', 'spec.md', 'contracts.cs', 'decisions.md'],
|
|
58
|
+
description: 'Technical specification and contracts'
|
|
59
|
+
},
|
|
60
|
+
'clarify': {
|
|
61
|
+
order: 4,
|
|
62
|
+
name: 'FASE 3: CLARIFY',
|
|
63
|
+
requiredOutputs: ['proposal.md', 'spec.md', 'contracts.cs'],
|
|
64
|
+
description: 'Clarify ambiguities and edge cases'
|
|
65
|
+
},
|
|
66
|
+
'tasks': {
|
|
67
|
+
order: 5,
|
|
68
|
+
name: 'FASE 4: TASKS',
|
|
69
|
+
requiredOutputs: ['proposal.md', 'spec.md', 'contracts.cs', 'tasks.json'],
|
|
70
|
+
description: 'Break down into executable tasks'
|
|
71
|
+
},
|
|
72
|
+
'implement': {
|
|
73
|
+
order: 6,
|
|
74
|
+
name: 'FASE 5: IMPLEMENT',
|
|
75
|
+
requiredOutputs: ['proposal.md', 'spec.md', 'contracts.cs', 'tasks.json'],
|
|
76
|
+
description: 'Execute tasks and implement code'
|
|
77
|
+
},
|
|
78
|
+
'sync': {
|
|
79
|
+
order: 7,
|
|
80
|
+
name: 'FASE 6: SYNC',
|
|
81
|
+
requiredOutputs: ['proposal.md', 'spec.md', 'decisions.md', 'recap.md'],
|
|
82
|
+
description: 'Sync decisions to project standards',
|
|
83
|
+
optional: true
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Check if output file exists
|
|
89
|
+
*/
|
|
90
|
+
function checkOutput(featurePath, outputFile) {
|
|
91
|
+
const filePath = path.join(featurePath, outputFile);
|
|
92
|
+
return fs.existsSync(filePath);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Validate phase requirements
|
|
97
|
+
*/
|
|
98
|
+
function validatePhase(featureName, targetPhase) {
|
|
99
|
+
const featurePath = path.join(process.cwd(), '.morph/project/outputs', featureName);
|
|
100
|
+
|
|
101
|
+
// Check if feature directory exists
|
|
102
|
+
if (!fs.existsSync(featurePath)) {
|
|
103
|
+
return {
|
|
104
|
+
valid: false,
|
|
105
|
+
error: `Feature directory not found: ${featurePath}`,
|
|
106
|
+
missingOutputs: [],
|
|
107
|
+
phase: null
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Get target phase definition
|
|
112
|
+
const phaseDefinition = PHASES[targetPhase];
|
|
113
|
+
if (!phaseDefinition) {
|
|
114
|
+
return {
|
|
115
|
+
valid: false,
|
|
116
|
+
error: `Unknown phase: ${targetPhase}`,
|
|
117
|
+
validPhases: Object.keys(PHASES),
|
|
118
|
+
missingOutputs: [],
|
|
119
|
+
phase: null
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Check required outputs
|
|
124
|
+
const missingOutputs = [];
|
|
125
|
+
for (const output of phaseDefinition.requiredOutputs) {
|
|
126
|
+
if (!checkOutput(featurePath, output)) {
|
|
127
|
+
missingOutputs.push(output);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Special validation: if target is 'implement', check tasks.json structure
|
|
132
|
+
if (targetPhase === 'implement' && checkOutput(featurePath, 'tasks.json')) {
|
|
133
|
+
try {
|
|
134
|
+
const tasksPath = path.join(featurePath, 'tasks.json');
|
|
135
|
+
const tasks = JSON.parse(fs.readFileSync(tasksPath, 'utf-8'));
|
|
136
|
+
|
|
137
|
+
if (!tasks.tasks || !Array.isArray(tasks.tasks) || tasks.tasks.length === 0) {
|
|
138
|
+
missingOutputs.push('tasks.json (must contain tasks array)');
|
|
139
|
+
}
|
|
140
|
+
} catch (error) {
|
|
141
|
+
missingOutputs.push('tasks.json (invalid JSON)');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
valid: missingOutputs.length === 0,
|
|
147
|
+
error: null,
|
|
148
|
+
missingOutputs,
|
|
149
|
+
phase: phaseDefinition,
|
|
150
|
+
featurePath
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Print validation result
|
|
156
|
+
*/
|
|
157
|
+
function printResult(result, featureName, targetPhase) {
|
|
158
|
+
console.log(`\n${colors.cyan}╔════════════════════════════════════════════════╗${colors.reset}`);
|
|
159
|
+
console.log(`${colors.cyan}║ MORPH-SPEC PHASE VALIDATOR ║${colors.reset}`);
|
|
160
|
+
console.log(`${colors.cyan}╚════════════════════════════════════════════════╝${colors.reset}\n`);
|
|
161
|
+
|
|
162
|
+
console.log(`${colors.gray}Feature:${colors.reset} ${featureName}`);
|
|
163
|
+
console.log(`${colors.gray}Target Phase:${colors.reset} ${result.phase ? result.phase.name : targetPhase}`);
|
|
164
|
+
|
|
165
|
+
if (result.phase) {
|
|
166
|
+
console.log(`${colors.gray}Description:${colors.reset} ${result.phase.description}`);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (result.valid) {
|
|
170
|
+
console.log(`\n${colors.green}✓ VALIDATION PASSED${colors.reset}`);
|
|
171
|
+
console.log(`${colors.green} All required outputs are present.${colors.reset}`);
|
|
172
|
+
console.log(`${colors.green} Safe to proceed to ${result.phase.name}${colors.reset}\n`);
|
|
173
|
+
} else {
|
|
174
|
+
console.log(`\n${colors.red}✗ VALIDATION FAILED${colors.reset}`);
|
|
175
|
+
|
|
176
|
+
if (result.error) {
|
|
177
|
+
console.log(`${colors.red} Error: ${result.error}${colors.reset}\n`);
|
|
178
|
+
|
|
179
|
+
if (result.validPhases) {
|
|
180
|
+
console.log(`${colors.yellow}Valid phases:${colors.reset}`);
|
|
181
|
+
result.validPhases.forEach(phase => {
|
|
182
|
+
console.log(` - ${phase}`);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
console.log(`${colors.red} Missing required outputs:${colors.reset}`);
|
|
187
|
+
result.missingOutputs.forEach(output => {
|
|
188
|
+
console.log(` ${colors.gray}-${colors.reset} ${output}`);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
console.log(`\n${colors.yellow}Action required:${colors.reset}`);
|
|
192
|
+
console.log(` Complete the missing outputs before advancing to ${result.phase.name}`);
|
|
193
|
+
}
|
|
194
|
+
console.log('');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Print help
|
|
200
|
+
*/
|
|
201
|
+
function printHelp() {
|
|
202
|
+
console.log(`
|
|
203
|
+
${colors.cyan}MORPH-SPEC Phase Validator${colors.reset}
|
|
204
|
+
|
|
205
|
+
Validates that required previous phases have been completed before advancing.
|
|
206
|
+
|
|
207
|
+
${colors.green}Usage:${colors.reset}
|
|
208
|
+
node bin/validate-phase.js <feature-name> <target-phase>
|
|
209
|
+
|
|
210
|
+
${colors.green}Arguments:${colors.reset}
|
|
211
|
+
feature-name Name of the feature (kebab-case)
|
|
212
|
+
target-phase Phase you want to advance to
|
|
213
|
+
|
|
214
|
+
${colors.green}Valid Phases:${colors.reset}
|
|
215
|
+
proposal FASE 0: Initial proposal
|
|
216
|
+
setup FASE 1: Load context and standards
|
|
217
|
+
uiux-design FASE 1.5: UI/UX design (optional)
|
|
218
|
+
design FASE 2: Technical specification
|
|
219
|
+
clarify FASE 3: Clarify ambiguities
|
|
220
|
+
tasks FASE 4: Break down into tasks
|
|
221
|
+
implement FASE 5: Execute implementation
|
|
222
|
+
sync FASE 6: Sync to project standards (optional)
|
|
223
|
+
|
|
224
|
+
${colors.green}Examples:${colors.reset}
|
|
225
|
+
# Check if ready to implement
|
|
226
|
+
node bin/validate-phase.js scheduled-reports implement
|
|
227
|
+
|
|
228
|
+
# Check if ready for design phase
|
|
229
|
+
node bin/validate-phase.js user-auth design
|
|
230
|
+
|
|
231
|
+
# Use in slash command
|
|
232
|
+
node bin/validate-phase.js my-feature implement || exit 1
|
|
233
|
+
|
|
234
|
+
${colors.green}Exit Codes:${colors.reset}
|
|
235
|
+
0 - Validation passed (safe to proceed)
|
|
236
|
+
1 - Validation failed (missing requirements)
|
|
237
|
+
|
|
238
|
+
${colors.green}Integration:${colors.reset}
|
|
239
|
+
This validator is designed to be called from slash commands like
|
|
240
|
+
/morph-apply to ensure phase gates are respected.
|
|
241
|
+
`);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Main function
|
|
246
|
+
*/
|
|
247
|
+
function main() {
|
|
248
|
+
const args = process.argv.slice(2);
|
|
249
|
+
|
|
250
|
+
if (args.includes('--help') || args.includes('-h') || args.length < 2) {
|
|
251
|
+
printHelp();
|
|
252
|
+
process.exit(args.length < 2 ? 1 : 0);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const [featureName, targetPhase] = args;
|
|
256
|
+
|
|
257
|
+
const result = validatePhase(featureName, targetPhase);
|
|
258
|
+
printResult(result, featureName, targetPhase);
|
|
259
|
+
|
|
260
|
+
process.exit(result.valid ? 0 : 1);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
main();
|