@jaimevalasek/aioson 1.3.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/CHANGELOG.md +456 -0
- package/CODE_OF_CONDUCT.md +12 -0
- package/CONTRIBUTING.md +13 -0
- package/LICENSE +21 -0
- package/README.md +254 -0
- package/bin/aioson.js +4 -0
- package/docs/en/cli-reference.md +398 -0
- package/docs/en/i18n.md +52 -0
- package/docs/en/json-schemas.md +41 -0
- package/docs/en/mcp.md +56 -0
- package/docs/en/parallel.md +82 -0
- package/docs/en/qa-browser.md +339 -0
- package/docs/en/release-flow.md +22 -0
- package/docs/en/release-notes-template.md +41 -0
- package/docs/en/release.md +28 -0
- package/docs/en/schemas/agent-prompt.schema.json +17 -0
- package/docs/en/schemas/agents.schema.json +32 -0
- package/docs/en/schemas/context-validate.schema.json +36 -0
- package/docs/en/schemas/doctor.schema.json +89 -0
- package/docs/en/schemas/error.schema.json +24 -0
- package/docs/en/schemas/i18n-add.schema.json +15 -0
- package/docs/en/schemas/index.json +116 -0
- package/docs/en/schemas/info.schema.json +39 -0
- package/docs/en/schemas/init.schema.json +48 -0
- package/docs/en/schemas/install.schema.json +60 -0
- package/docs/en/schemas/locale-apply.schema.json +30 -0
- package/docs/en/schemas/mcp-doctor.schema.json +95 -0
- package/docs/en/schemas/mcp-init.schema.json +122 -0
- package/docs/en/schemas/package-test.schema.json +24 -0
- package/docs/en/schemas/parallel-assign.schema.json +57 -0
- package/docs/en/schemas/parallel-doctor.schema.json +86 -0
- package/docs/en/schemas/parallel-init.schema.json +53 -0
- package/docs/en/schemas/parallel-status.schema.json +94 -0
- package/docs/en/schemas/setup-context.schema.json +39 -0
- package/docs/en/schemas/smoke.schema.json +23 -0
- package/docs/en/schemas/update.schema.json +48 -0
- package/docs/en/schemas/workflow-plan.schema.json +30 -0
- package/docs/en/web3.md +54 -0
- package/docs/pt/README.md +46 -0
- package/docs/pt/advisor-spec.md +335 -0
- package/docs/pt/agentes.md +453 -0
- package/docs/pt/cenarios.md +1230 -0
- package/docs/pt/clientes-ai.md +224 -0
- package/docs/pt/comandos-cli.md +511 -0
- package/docs/pt/genome-3.0-spec.md +296 -0
- package/docs/pt/guia-engineer.md +226 -0
- package/docs/pt/inicio-rapido.md +138 -0
- package/docs/pt/profiler-system.md +214 -0
- package/docs/pt/runtime-observability.md +72 -0
- package/docs/pt/squad-genoma.md +777 -0
- package/docs/pt/web3.md +797 -0
- package/docs/testing/genome-2.0-manual-regression.md +23 -0
- package/docs/testing/genome-2.0-matrix.md +36 -0
- package/docs/testing/genome-2.0-rollout.md +184 -0
- package/package.json +50 -0
- package/src/agents.js +56 -0
- package/src/cli.js +497 -0
- package/src/commands/agents.js +142 -0
- package/src/commands/cloud.js +1767 -0
- package/src/commands/config.js +90 -0
- package/src/commands/context-validate.js +91 -0
- package/src/commands/doctor.js +123 -0
- package/src/commands/genome-doctor.js +41 -0
- package/src/commands/genome-migrate.js +49 -0
- package/src/commands/i18n-add.js +56 -0
- package/src/commands/info.js +41 -0
- package/src/commands/init.js +75 -0
- package/src/commands/install.js +68 -0
- package/src/commands/locale-apply.js +51 -0
- package/src/commands/locale-diff.js +126 -0
- package/src/commands/mcp-doctor.js +406 -0
- package/src/commands/mcp-init.js +379 -0
- package/src/commands/package-e2e.js +273 -0
- package/src/commands/parallel-assign.js +403 -0
- package/src/commands/parallel-doctor.js +437 -0
- package/src/commands/parallel-init.js +249 -0
- package/src/commands/parallel-status.js +290 -0
- package/src/commands/qa-doctor.js +185 -0
- package/src/commands/qa-init.js +161 -0
- package/src/commands/qa-report.js +58 -0
- package/src/commands/qa-run.js +873 -0
- package/src/commands/qa-scan.js +337 -0
- package/src/commands/runtime.js +948 -0
- package/src/commands/scan-project.js +1107 -0
- package/src/commands/setup-context.js +650 -0
- package/src/commands/smoke.js +426 -0
- package/src/commands/squad-doctor.js +358 -0
- package/src/commands/squad-export.js +46 -0
- package/src/commands/squad-pipeline.js +97 -0
- package/src/commands/squad-repair-genomes.js +39 -0
- package/src/commands/squad-status.js +424 -0
- package/src/commands/squad-validate.js +230 -0
- package/src/commands/test-agents.js +194 -0
- package/src/commands/update.js +55 -0
- package/src/commands/workflow-next.js +594 -0
- package/src/commands/workflow-plan.js +108 -0
- package/src/constants.js +314 -0
- package/src/context-parse-reason.js +22 -0
- package/src/context-writer.js +150 -0
- package/src/context.js +217 -0
- package/src/detector.js +261 -0
- package/src/doctor.js +289 -0
- package/src/execution-gateway.js +461 -0
- package/src/genome-files.js +198 -0
- package/src/genome-format.js +442 -0
- package/src/genome-schema.js +215 -0
- package/src/genomes/bindings.js +281 -0
- package/src/genomes.js +467 -0
- package/src/i18n/index.js +103 -0
- package/src/i18n/messages/en.js +784 -0
- package/src/i18n/messages/es.js +718 -0
- package/src/i18n/messages/fr.js +725 -0
- package/src/i18n/messages/pt-BR.js +818 -0
- package/src/i18n/scaffold.js +64 -0
- package/src/installer.js +232 -0
- package/src/lib/genomes/compat.js +206 -0
- package/src/lib/genomes/migrate.js +90 -0
- package/src/lib/squads/genome-repair.js +49 -0
- package/src/locales.js +84 -0
- package/src/onboarding.js +305 -0
- package/src/parser.js +53 -0
- package/src/prompt-tool.js +20 -0
- package/src/qa-html-report.js +472 -0
- package/src/runtime-store.js +1527 -0
- package/src/squads/apply-genome.js +21 -0
- package/src/squads/genome-binding-service.js +154 -0
- package/src/updater.js +32 -0
- package/src/utils.js +46 -0
- package/src/version.js +50 -0
- package/template/.aioson/advisors/.gitkeep +1 -0
- package/template/.aioson/agents/analyst.md +225 -0
- package/template/.aioson/agents/architect.md +221 -0
- package/template/.aioson/agents/dev.md +201 -0
- package/template/.aioson/agents/discovery-design-doc.md +196 -0
- package/template/.aioson/agents/genoma.md +300 -0
- package/template/.aioson/agents/orchestrator.md +107 -0
- package/template/.aioson/agents/pm.md +89 -0
- package/template/.aioson/agents/product.md +361 -0
- package/template/.aioson/agents/profiler-enricher.md +266 -0
- package/template/.aioson/agents/profiler-forge.md +188 -0
- package/template/.aioson/agents/profiler-researcher.md +245 -0
- package/template/.aioson/agents/qa.md +344 -0
- package/template/.aioson/agents/setup.md +381 -0
- package/template/.aioson/agents/squad.md +837 -0
- package/template/.aioson/agents/ux-ui.md +416 -0
- package/template/.aioson/config.md +56 -0
- package/template/.aioson/context/.gitkeep +0 -0
- package/template/.aioson/context/parallel/.gitkeep +0 -0
- package/template/.aioson/context/spec.md.template +37 -0
- package/template/.aioson/genomas/.gitkeep +0 -0
- package/template/.aioson/locales/en/agents/analyst.md +214 -0
- package/template/.aioson/locales/en/agents/architect.md +210 -0
- package/template/.aioson/locales/en/agents/dev.md +187 -0
- package/template/.aioson/locales/en/agents/discovery-design-doc.md +27 -0
- package/template/.aioson/locales/en/agents/genoma.md +212 -0
- package/template/.aioson/locales/en/agents/orchestrator.md +105 -0
- package/template/.aioson/locales/en/agents/pm.md +77 -0
- package/template/.aioson/locales/en/agents/product.md +310 -0
- package/template/.aioson/locales/en/agents/profiler-enricher.md +5 -0
- package/template/.aioson/locales/en/agents/profiler-forge.md +5 -0
- package/template/.aioson/locales/en/agents/profiler-researcher.md +5 -0
- package/template/.aioson/locales/en/agents/qa.md +214 -0
- package/template/.aioson/locales/en/agents/setup.md +342 -0
- package/template/.aioson/locales/en/agents/squad.md +247 -0
- package/template/.aioson/locales/en/agents/ux-ui.md +320 -0
- package/template/.aioson/locales/es/agents/analyst.md +203 -0
- package/template/.aioson/locales/es/agents/architect.md +208 -0
- package/template/.aioson/locales/es/agents/dev.md +183 -0
- package/template/.aioson/locales/es/agents/discovery-design-doc.md +19 -0
- package/template/.aioson/locales/es/agents/genoma.md +102 -0
- package/template/.aioson/locales/es/agents/orchestrator.md +108 -0
- package/template/.aioson/locales/es/agents/pm.md +81 -0
- package/template/.aioson/locales/es/agents/product.md +310 -0
- package/template/.aioson/locales/es/agents/profiler-enricher.md +5 -0
- package/template/.aioson/locales/es/agents/profiler-forge.md +5 -0
- package/template/.aioson/locales/es/agents/profiler-researcher.md +5 -0
- package/template/.aioson/locales/es/agents/qa.md +163 -0
- package/template/.aioson/locales/es/agents/setup.md +347 -0
- package/template/.aioson/locales/es/agents/squad.md +247 -0
- package/template/.aioson/locales/es/agents/ux-ui.md +201 -0
- package/template/.aioson/locales/fr/agents/analyst.md +203 -0
- package/template/.aioson/locales/fr/agents/architect.md +208 -0
- package/template/.aioson/locales/fr/agents/dev.md +183 -0
- package/template/.aioson/locales/fr/agents/discovery-design-doc.md +19 -0
- package/template/.aioson/locales/fr/agents/genoma.md +102 -0
- package/template/.aioson/locales/fr/agents/orchestrator.md +108 -0
- package/template/.aioson/locales/fr/agents/pm.md +81 -0
- package/template/.aioson/locales/fr/agents/product.md +310 -0
- package/template/.aioson/locales/fr/agents/profiler-enricher.md +5 -0
- package/template/.aioson/locales/fr/agents/profiler-forge.md +5 -0
- package/template/.aioson/locales/fr/agents/profiler-researcher.md +5 -0
- package/template/.aioson/locales/fr/agents/qa.md +163 -0
- package/template/.aioson/locales/fr/agents/setup.md +347 -0
- package/template/.aioson/locales/fr/agents/squad.md +247 -0
- package/template/.aioson/locales/fr/agents/ux-ui.md +201 -0
- package/template/.aioson/locales/pt-BR/agents/analyst.md +217 -0
- package/template/.aioson/locales/pt-BR/agents/architect.md +213 -0
- package/template/.aioson/locales/pt-BR/agents/dev.md +198 -0
- package/template/.aioson/locales/pt-BR/agents/discovery-design-doc.md +198 -0
- package/template/.aioson/locales/pt-BR/agents/genoma.md +297 -0
- package/template/.aioson/locales/pt-BR/agents/orchestrator.md +108 -0
- package/template/.aioson/locales/pt-BR/agents/pm.md +81 -0
- package/template/.aioson/locales/pt-BR/agents/product.md +316 -0
- package/template/.aioson/locales/pt-BR/agents/profiler-enricher.md +5 -0
- package/template/.aioson/locales/pt-BR/agents/profiler-forge.md +5 -0
- package/template/.aioson/locales/pt-BR/agents/profiler-researcher.md +5 -0
- package/template/.aioson/locales/pt-BR/agents/qa.md +217 -0
- package/template/.aioson/locales/pt-BR/agents/setup.md +371 -0
- package/template/.aioson/locales/pt-BR/agents/squad.md +772 -0
- package/template/.aioson/locales/pt-BR/agents/ux-ui.md +322 -0
- package/template/.aioson/mcp/servers.md +24 -0
- package/template/.aioson/profiler-reports/.gitkeep +1 -0
- package/template/.aioson/schemas/content-blueprint.schema.json +30 -0
- package/template/.aioson/schemas/genome-meta.schema.json +150 -0
- package/template/.aioson/schemas/genome.schema.json +115 -0
- package/template/.aioson/schemas/readiness.schema.json +27 -0
- package/template/.aioson/schemas/squad-blueprint.schema.json +172 -0
- package/template/.aioson/schemas/squad-manifest.schema.json +276 -0
- package/template/.aioson/skills/dynamic/README.md +30 -0
- package/template/.aioson/skills/dynamic/cardano-docs.md +16 -0
- package/template/.aioson/skills/dynamic/ethereum-docs.md +17 -0
- package/template/.aioson/skills/dynamic/flux-ui-docs.md +13 -0
- package/template/.aioson/skills/dynamic/laravel-docs.md +41 -0
- package/template/.aioson/skills/dynamic/npm-packages.md +16 -0
- package/template/.aioson/skills/dynamic/solana-docs.md +16 -0
- package/template/.aioson/skills/references/premium-command-center-ui/master-application-prompt.md +79 -0
- package/template/.aioson/skills/references/premium-command-center-ui/operational-ux-playbook.md +253 -0
- package/template/.aioson/skills/references/premium-command-center-ui/quality-validation-checklist.md +82 -0
- package/template/.aioson/skills/references/premium-command-center-ui/visual-system-and-component-patterns.md +270 -0
- package/template/.aioson/skills/static/django-patterns.md +342 -0
- package/template/.aioson/skills/static/fastapi-patterns.md +344 -0
- package/template/.aioson/skills/static/filament-patterns.md +267 -0
- package/template/.aioson/skills/static/flux-ui-components.md +262 -0
- package/template/.aioson/skills/static/git-conventions.md +227 -0
- package/template/.aioson/skills/static/interface-design.md +372 -0
- package/template/.aioson/skills/static/jetstream-setup.md +200 -0
- package/template/.aioson/skills/static/laravel-conventions.md +491 -0
- package/template/.aioson/skills/static/nextjs-patterns.md +321 -0
- package/template/.aioson/skills/static/node-express-patterns.md +317 -0
- package/template/.aioson/skills/static/node-typescript-patterns.md +282 -0
- package/template/.aioson/skills/static/premium-command-center-ui.md +190 -0
- package/template/.aioson/skills/static/rails-conventions.md +307 -0
- package/template/.aioson/skills/static/react-motion-patterns.md +577 -0
- package/template/.aioson/skills/static/static-html-patterns.md +1935 -0
- package/template/.aioson/skills/static/tall-stack-patterns.md +286 -0
- package/template/.aioson/skills/static/ui-ux-modern.md +75 -0
- package/template/.aioson/skills/static/web3-cardano-patterns.md +337 -0
- package/template/.aioson/skills/static/web3-ethereum-patterns.md +310 -0
- package/template/.aioson/skills/static/web3-security-checklist.md +284 -0
- package/template/.aioson/skills/static/web3-solana-patterns.md +324 -0
- package/template/.aioson/squads/.artisan/.gitkeep +0 -0
- package/template/.aioson/squads/.gitkeep +0 -0
- package/template/.aioson/squads/memory.md +5 -0
- package/template/.aioson/tasks/squad-analyze.md +83 -0
- package/template/.aioson/tasks/squad-create.md +99 -0
- package/template/.aioson/tasks/squad-design.md +100 -0
- package/template/.aioson/tasks/squad-export.md +20 -0
- package/template/.aioson/tasks/squad-extend.md +68 -0
- package/template/.aioson/tasks/squad-pipeline.md +122 -0
- package/template/.aioson/tasks/squad-repair.md +85 -0
- package/template/.aioson/tasks/squad-validate.md +58 -0
- package/template/.aioson/templates/squads/content-basic/template.json +21 -0
- package/template/.aioson/templates/squads/media-channel/template.json +24 -0
- package/template/.aioson/templates/squads/research-analysis/template.json +22 -0
- package/template/.aioson/templates/squads/software-delivery/template.json +21 -0
- package/template/.claude/commands/aioson/analyst.md +5 -0
- package/template/.claude/commands/aioson/architect.md +5 -0
- package/template/.claude/commands/aioson/dev.md +5 -0
- package/template/.claude/commands/aioson/orchestrator.md +5 -0
- package/template/.claude/commands/aioson/pm.md +5 -0
- package/template/.claude/commands/aioson/qa.md +5 -0
- package/template/.claude/commands/aioson/setup.md +5 -0
- package/template/.claude/commands/aioson/ux-ui.md +5 -0
- package/template/.gemini/GEMINI.md +10 -0
- package/template/.gemini/commands/aios-analyst.toml +4 -0
- package/template/.gemini/commands/aios-architect.toml +7 -0
- package/template/.gemini/commands/aios-dev.toml +8 -0
- package/template/.gemini/commands/aios-discovery-design-doc.toml +4 -0
- package/template/.gemini/commands/aios-orchestrator.toml +8 -0
- package/template/.gemini/commands/aios-pm.toml +8 -0
- package/template/.gemini/commands/aios-product.toml +4 -0
- package/template/.gemini/commands/aios-qa.toml +6 -0
- package/template/.gemini/commands/aios-setup.toml +3 -0
- package/template/.gemini/commands/aios-ux-ui.toml +8 -0
- package/template/AGENTS.md +67 -0
- package/template/CLAUDE.md +31 -0
- package/template/OPENCODE.md +24 -0
- package/template/aioson-models.json +40 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs/promises');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { TEMPLATE_DIR } = require('../installer');
|
|
6
|
+
|
|
7
|
+
const AGENTS = ['setup', 'analyst', 'architect', 'pm', 'ux-ui', 'dev', 'qa', 'orchestrator'];
|
|
8
|
+
const LOCALES = ['en', 'pt-BR', 'es', 'fr'];
|
|
9
|
+
|
|
10
|
+
// Extract ## Section headings from markdown content
|
|
11
|
+
function extractSections(content) {
|
|
12
|
+
const sections = [];
|
|
13
|
+
for (const line of content.split('\n')) {
|
|
14
|
+
if (/^#{1,3} /.test(line)) {
|
|
15
|
+
sections.push(line.trim());
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return sections;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Normalize a heading to a comparable key (remove locale-specific punctuation/accents)
|
|
22
|
+
function normalizeHeading(heading) {
|
|
23
|
+
return heading
|
|
24
|
+
.toLowerCase()
|
|
25
|
+
.replace(/[áàâãä]/g, 'a')
|
|
26
|
+
.replace(/[éèêë]/g, 'e')
|
|
27
|
+
.replace(/[íìîï]/g, 'i')
|
|
28
|
+
.replace(/[óòôõö]/g, 'o')
|
|
29
|
+
.replace(/[úùûü]/g, 'u')
|
|
30
|
+
.replace(/[ç]/g, 'c')
|
|
31
|
+
.replace(/[ñ]/g, 'n')
|
|
32
|
+
.replace(/[^a-z0-9# ]/g, '')
|
|
33
|
+
.replace(/\s+/g, ' ')
|
|
34
|
+
.trim();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function readFile(filePath) {
|
|
38
|
+
try {
|
|
39
|
+
return await fs.readFile(filePath, 'utf8');
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function runLocaleDiff({ args, options, logger }) {
|
|
46
|
+
const jsonMode = Boolean(options.json);
|
|
47
|
+
const log = jsonMode ? () => {} : logger.log.bind(logger);
|
|
48
|
+
|
|
49
|
+
const filterAgent = args[0] || null; // optional: check only one agent
|
|
50
|
+
const filterLocale = options.lang || options.language || null;
|
|
51
|
+
|
|
52
|
+
const baseAgentsDir = path.join(TEMPLATE_DIR, '.aioson', 'agents');
|
|
53
|
+
const localesDir = path.join(TEMPLATE_DIR, '.aioson', 'locales');
|
|
54
|
+
|
|
55
|
+
const agentsToCheck = filterAgent
|
|
56
|
+
? AGENTS.filter(a => a === filterAgent)
|
|
57
|
+
: AGENTS;
|
|
58
|
+
const localesToCheck = filterLocale
|
|
59
|
+
? LOCALES.filter(l => l === filterLocale)
|
|
60
|
+
: LOCALES;
|
|
61
|
+
|
|
62
|
+
const report = [];
|
|
63
|
+
let totalMissing = 0;
|
|
64
|
+
|
|
65
|
+
for (const agent of agentsToCheck) {
|
|
66
|
+
const baseFile = path.join(baseAgentsDir, `${agent}.md`);
|
|
67
|
+
const baseContent = await readFile(baseFile);
|
|
68
|
+
if (!baseContent) {
|
|
69
|
+
log(`WARN: base agent @${agent} not found`);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const baseSections = extractSections(baseContent);
|
|
74
|
+
const baseNorm = baseSections.map(s => ({ original: s, key: normalizeHeading(s) }));
|
|
75
|
+
|
|
76
|
+
for (const locale of localesToCheck) {
|
|
77
|
+
const localeFile = path.join(localesDir, locale, 'agents', `${agent}.md`);
|
|
78
|
+
const localeContent = await readFile(localeFile);
|
|
79
|
+
if (!localeContent) {
|
|
80
|
+
log(`WARN: @${agent} (${locale}) not found`);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const localeSections = extractSections(localeContent);
|
|
85
|
+
const localeNormSet = new Set(localeSections.map(s => normalizeHeading(s)));
|
|
86
|
+
|
|
87
|
+
const missing = baseNorm.filter(({ key }) => !localeNormSet.has(key));
|
|
88
|
+
|
|
89
|
+
if (missing.length > 0) {
|
|
90
|
+
totalMissing += missing.length;
|
|
91
|
+
const entry = {
|
|
92
|
+
agent,
|
|
93
|
+
locale,
|
|
94
|
+
missingSections: missing.map(m => m.original)
|
|
95
|
+
};
|
|
96
|
+
report.push(entry);
|
|
97
|
+
if (!jsonMode) {
|
|
98
|
+
log(`@${agent} (${locale}) — ${missing.length} section(s) missing in locale:`);
|
|
99
|
+
for (const m of missing) {
|
|
100
|
+
log(` - ${m.original}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!jsonMode) {
|
|
108
|
+
log('');
|
|
109
|
+
if (totalMissing === 0) {
|
|
110
|
+
log('No drift detected — all locale files contain equivalent sections to base.');
|
|
111
|
+
} else {
|
|
112
|
+
log(`${totalMissing} section(s) present in base but missing in locale files.`);
|
|
113
|
+
log('These may be intentional simplifications or unintentional drift.');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
ok: totalMissing === 0,
|
|
119
|
+
totalMissing,
|
|
120
|
+
agents: agentsToCheck,
|
|
121
|
+
locales: localesToCheck,
|
|
122
|
+
drifts: report
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = { runLocaleDiff };
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('node:fs/promises');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { validateProjectContextFile } = require('../context');
|
|
6
|
+
const { localizeContextParseReason } = require('../context-parse-reason');
|
|
7
|
+
const { exists, readTextIfExists } = require('../utils');
|
|
8
|
+
const { extractStackValue, normalizeDatabaseEngine } = require('./mcp-init');
|
|
9
|
+
|
|
10
|
+
const REQUIRED_CORE_SERVERS = ['filesystem', 'context7'];
|
|
11
|
+
const TOOL_PRESETS = ['claude', 'codex', 'gemini', 'opencode'];
|
|
12
|
+
|
|
13
|
+
function normalizeBoolean(value, fallback = false) {
|
|
14
|
+
if (typeof value === 'boolean') return value;
|
|
15
|
+
if (value === undefined || value === null) return fallback;
|
|
16
|
+
const text = String(value).trim().toLowerCase();
|
|
17
|
+
if (['1', 'true', 'yes', 'y', 'on'].includes(text)) return true;
|
|
18
|
+
if (['0', 'false', 'no', 'n', 'off'].includes(text)) return false;
|
|
19
|
+
return fallback;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function makeCheck(id, ok, severity, message, hint = '') {
|
|
23
|
+
return {
|
|
24
|
+
id,
|
|
25
|
+
ok: Boolean(ok),
|
|
26
|
+
severity,
|
|
27
|
+
message: String(message || ''),
|
|
28
|
+
hint: String(hint || '')
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function uniqueStrings(values) {
|
|
33
|
+
return Array.from(new Set((values || []).filter(Boolean).map((value) => String(value))));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function readJsonFileIfExists(filePath) {
|
|
37
|
+
if (!(await exists(filePath))) {
|
|
38
|
+
return {
|
|
39
|
+
exists: false,
|
|
40
|
+
parsed: false,
|
|
41
|
+
data: null,
|
|
42
|
+
error: ''
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const raw = await fs.readFile(filePath, 'utf8');
|
|
47
|
+
try {
|
|
48
|
+
return {
|
|
49
|
+
exists: true,
|
|
50
|
+
parsed: true,
|
|
51
|
+
data: JSON.parse(raw),
|
|
52
|
+
error: ''
|
|
53
|
+
};
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return {
|
|
56
|
+
exists: true,
|
|
57
|
+
parsed: false,
|
|
58
|
+
data: null,
|
|
59
|
+
error: error.message
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function summarizeChecks(checks) {
|
|
65
|
+
const passed = checks.filter((item) => item.ok).length;
|
|
66
|
+
const failed = checks.filter((item) => !item.ok && item.severity === 'error').length;
|
|
67
|
+
const warnings = checks.filter((item) => !item.ok && item.severity === 'warn').length;
|
|
68
|
+
return {
|
|
69
|
+
total: checks.length,
|
|
70
|
+
passed,
|
|
71
|
+
failed,
|
|
72
|
+
warnings
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function buildServerMap(plan) {
|
|
77
|
+
const servers = Array.isArray(plan && plan.servers) ? plan.servers : [];
|
|
78
|
+
const map = new Map();
|
|
79
|
+
for (const server of servers) {
|
|
80
|
+
const id = String(server && server.id ? server.id : '').trim();
|
|
81
|
+
if (!id) continue;
|
|
82
|
+
map.set(id, server);
|
|
83
|
+
}
|
|
84
|
+
return map;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isWeb3Context(contextData) {
|
|
88
|
+
if (!contextData || typeof contextData !== 'object') return false;
|
|
89
|
+
return Boolean(contextData.web3_enabled) || String(contextData.project_type) === 'dapp';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function formatCheckPrefix(check, t) {
|
|
93
|
+
if (check.ok) return t('mcp_doctor.prefix_ok');
|
|
94
|
+
if (check.severity === 'warn') return t('mcp_doctor.prefix_warn');
|
|
95
|
+
return t('mcp_doctor.prefix_fail');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function runMcpDoctor({ args, options = {}, logger, t }) {
|
|
99
|
+
const targetDir = path.resolve(process.cwd(), args[0] || '.');
|
|
100
|
+
const strictEnv = normalizeBoolean(options['strict-env'], false);
|
|
101
|
+
const planPath = path.join(targetDir, '.aioson/mcp/servers.local.json');
|
|
102
|
+
const presetsDir = path.join(targetDir, '.aioson/mcp/presets');
|
|
103
|
+
const contextPath = path.join(targetDir, '.aioson/context/project.context.md');
|
|
104
|
+
|
|
105
|
+
const checks = [];
|
|
106
|
+
|
|
107
|
+
const contextResult = await validateProjectContextFile(targetDir);
|
|
108
|
+
const contextMarkdown = (await readTextIfExists(contextPath)) || '';
|
|
109
|
+
const contextData = contextResult.parsed && contextResult.data ? contextResult.data : {};
|
|
110
|
+
|
|
111
|
+
if (!contextResult.exists) {
|
|
112
|
+
checks.push(
|
|
113
|
+
makeCheck(
|
|
114
|
+
'context.exists',
|
|
115
|
+
false,
|
|
116
|
+
'warn',
|
|
117
|
+
t('mcp_doctor.context_missing'),
|
|
118
|
+
t('mcp_doctor.context_missing_hint')
|
|
119
|
+
)
|
|
120
|
+
);
|
|
121
|
+
} else if (!contextResult.parsed) {
|
|
122
|
+
checks.push(
|
|
123
|
+
makeCheck(
|
|
124
|
+
'context.parsed',
|
|
125
|
+
false,
|
|
126
|
+
'warn',
|
|
127
|
+
t('mcp_doctor.context_parse_invalid', {
|
|
128
|
+
reason: localizeContextParseReason(contextResult.parseError, t)
|
|
129
|
+
}),
|
|
130
|
+
t('mcp_doctor.context_parse_invalid_hint')
|
|
131
|
+
)
|
|
132
|
+
);
|
|
133
|
+
} else {
|
|
134
|
+
checks.push(
|
|
135
|
+
makeCheck(
|
|
136
|
+
'context.parsed',
|
|
137
|
+
true,
|
|
138
|
+
'info',
|
|
139
|
+
t('mcp_doctor.context_ok')
|
|
140
|
+
)
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const planFile = await readJsonFileIfExists(planPath);
|
|
145
|
+
if (!planFile.exists) {
|
|
146
|
+
checks.push(
|
|
147
|
+
makeCheck(
|
|
148
|
+
'plan.exists',
|
|
149
|
+
false,
|
|
150
|
+
'error',
|
|
151
|
+
t('mcp_doctor.plan_missing'),
|
|
152
|
+
t('mcp_doctor.plan_missing_hint')
|
|
153
|
+
)
|
|
154
|
+
);
|
|
155
|
+
} else if (!planFile.parsed) {
|
|
156
|
+
checks.push(
|
|
157
|
+
makeCheck(
|
|
158
|
+
'plan.parsed',
|
|
159
|
+
false,
|
|
160
|
+
'error',
|
|
161
|
+
t('mcp_doctor.plan_invalid', { error: planFile.error }),
|
|
162
|
+
t('mcp_doctor.plan_invalid_hint')
|
|
163
|
+
)
|
|
164
|
+
);
|
|
165
|
+
} else {
|
|
166
|
+
checks.push(
|
|
167
|
+
makeCheck(
|
|
168
|
+
'plan.parsed',
|
|
169
|
+
true,
|
|
170
|
+
'info',
|
|
171
|
+
t('mcp_doctor.plan_ok')
|
|
172
|
+
)
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const plan = planFile.parsed && planFile.data ? planFile.data : {};
|
|
177
|
+
const serverMap = buildServerMap(plan);
|
|
178
|
+
const enabledServers = Array.from(serverMap.values()).filter((server) => server.enabled);
|
|
179
|
+
|
|
180
|
+
if (planFile.parsed) {
|
|
181
|
+
checks.push(
|
|
182
|
+
makeCheck(
|
|
183
|
+
'plan.servers',
|
|
184
|
+
serverMap.size > 0,
|
|
185
|
+
'error',
|
|
186
|
+
serverMap.size > 0
|
|
187
|
+
? t('mcp_doctor.plan_servers_ok', { count: serverMap.size })
|
|
188
|
+
: t('mcp_doctor.plan_servers_missing'),
|
|
189
|
+
serverMap.size > 0 ? '' : t('mcp_doctor.plan_servers_hint')
|
|
190
|
+
)
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
for (const serverId of REQUIRED_CORE_SERVERS) {
|
|
194
|
+
const server = serverMap.get(serverId);
|
|
195
|
+
const ok = Boolean(server && server.enabled === true);
|
|
196
|
+
checks.push(
|
|
197
|
+
makeCheck(
|
|
198
|
+
`plan.core.${serverId}`,
|
|
199
|
+
ok,
|
|
200
|
+
'error',
|
|
201
|
+
ok
|
|
202
|
+
? t('mcp_doctor.core_enabled', { server: serverId })
|
|
203
|
+
: t('mcp_doctor.core_missing', { server: serverId }),
|
|
204
|
+
ok ? '' : t('mcp_doctor.core_missing_hint')
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const presetChecks = [];
|
|
211
|
+
for (const tool of TOOL_PRESETS) {
|
|
212
|
+
const presetPath = path.join(presetsDir, `${tool}.json`);
|
|
213
|
+
const present = await exists(presetPath);
|
|
214
|
+
presetChecks.push({
|
|
215
|
+
tool,
|
|
216
|
+
path: presetPath,
|
|
217
|
+
exists: present
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const existingPresetCount = presetChecks.filter((item) => item.exists).length;
|
|
222
|
+
checks.push(
|
|
223
|
+
makeCheck(
|
|
224
|
+
'presets.any',
|
|
225
|
+
existingPresetCount > 0,
|
|
226
|
+
'error',
|
|
227
|
+
existingPresetCount > 0
|
|
228
|
+
? t('mcp_doctor.presets_any_ok', { count: existingPresetCount })
|
|
229
|
+
: t('mcp_doctor.presets_any_missing'),
|
|
230
|
+
existingPresetCount > 0 ? '' : t('mcp_doctor.presets_any_hint')
|
|
231
|
+
)
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
if (existingPresetCount > 0 && existingPresetCount < TOOL_PRESETS.length) {
|
|
235
|
+
checks.push(
|
|
236
|
+
makeCheck(
|
|
237
|
+
'presets.coverage',
|
|
238
|
+
false,
|
|
239
|
+
'warn',
|
|
240
|
+
t('mcp_doctor.presets_coverage_partial', {
|
|
241
|
+
existing: existingPresetCount,
|
|
242
|
+
total: TOOL_PRESETS.length
|
|
243
|
+
}),
|
|
244
|
+
t('mcp_doctor.presets_coverage_partial_hint')
|
|
245
|
+
)
|
|
246
|
+
);
|
|
247
|
+
} else if (existingPresetCount === TOOL_PRESETS.length) {
|
|
248
|
+
checks.push(
|
|
249
|
+
makeCheck(
|
|
250
|
+
'presets.coverage',
|
|
251
|
+
true,
|
|
252
|
+
'info',
|
|
253
|
+
t('mcp_doctor.presets_coverage_full')
|
|
254
|
+
)
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const requiredEnv = uniqueStrings(enabledServers.flatMap((server) => server.env || []));
|
|
259
|
+
const missingEnv = requiredEnv.filter((key) => !process.env[key]);
|
|
260
|
+
const envSeverity = strictEnv ? 'error' : 'warn';
|
|
261
|
+
if (requiredEnv.length === 0) {
|
|
262
|
+
checks.push(
|
|
263
|
+
makeCheck(
|
|
264
|
+
'env.required',
|
|
265
|
+
true,
|
|
266
|
+
'info',
|
|
267
|
+
t('mcp_doctor.env_none_required')
|
|
268
|
+
)
|
|
269
|
+
);
|
|
270
|
+
} else if (missingEnv.length > 0) {
|
|
271
|
+
checks.push(
|
|
272
|
+
makeCheck(
|
|
273
|
+
'env.required',
|
|
274
|
+
false,
|
|
275
|
+
envSeverity,
|
|
276
|
+
t('mcp_doctor.env_missing', {
|
|
277
|
+
missing: missingEnv.length,
|
|
278
|
+
total: requiredEnv.length,
|
|
279
|
+
vars: missingEnv.join(', ')
|
|
280
|
+
}),
|
|
281
|
+
strictEnv
|
|
282
|
+
? t('mcp_doctor.env_missing_hint_strict')
|
|
283
|
+
: t('mcp_doctor.env_missing_hint_relaxed')
|
|
284
|
+
)
|
|
285
|
+
);
|
|
286
|
+
} else {
|
|
287
|
+
checks.push(
|
|
288
|
+
makeCheck(
|
|
289
|
+
'env.required',
|
|
290
|
+
true,
|
|
291
|
+
'info',
|
|
292
|
+
t('mcp_doctor.env_all_present', { count: requiredEnv.length })
|
|
293
|
+
)
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (contextResult.parsed && planFile.parsed) {
|
|
298
|
+
const stackDatabase = normalizeDatabaseEngine(extractStackValue(contextMarkdown, 'Database'));
|
|
299
|
+
if (stackDatabase) {
|
|
300
|
+
const databaseServer = serverMap.get('database');
|
|
301
|
+
const actualEngine = String(databaseServer && databaseServer.engine ? databaseServer.engine : '');
|
|
302
|
+
const matches = Boolean(databaseServer && databaseServer.enabled && actualEngine === stackDatabase);
|
|
303
|
+
checks.push(
|
|
304
|
+
makeCheck(
|
|
305
|
+
'compat.database',
|
|
306
|
+
matches,
|
|
307
|
+
matches ? 'info' : 'warn',
|
|
308
|
+
matches
|
|
309
|
+
? t('mcp_doctor.compat_database_ok', { engine: stackDatabase })
|
|
310
|
+
: t('mcp_doctor.compat_database_mismatch', { engine: stackDatabase }),
|
|
311
|
+
matches
|
|
312
|
+
? ''
|
|
313
|
+
: t('mcp_doctor.compat_database_hint')
|
|
314
|
+
)
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const web3Enabled = isWeb3Context(contextData);
|
|
319
|
+
const chainRpcServer = serverMap.get('chain-rpc');
|
|
320
|
+
if (web3Enabled) {
|
|
321
|
+
const chainOk = Boolean(chainRpcServer && chainRpcServer.enabled);
|
|
322
|
+
checks.push(
|
|
323
|
+
makeCheck(
|
|
324
|
+
'compat.web3',
|
|
325
|
+
chainOk,
|
|
326
|
+
'error',
|
|
327
|
+
chainOk
|
|
328
|
+
? t('mcp_doctor.compat_web3_ok')
|
|
329
|
+
: t('mcp_doctor.compat_web3_missing'),
|
|
330
|
+
chainOk ? '' : t('mcp_doctor.compat_web3_missing_hint')
|
|
331
|
+
)
|
|
332
|
+
);
|
|
333
|
+
} else if (chainRpcServer && chainRpcServer.enabled) {
|
|
334
|
+
checks.push(
|
|
335
|
+
makeCheck(
|
|
336
|
+
'compat.web3',
|
|
337
|
+
false,
|
|
338
|
+
'warn',
|
|
339
|
+
t('mcp_doctor.compat_web3_unneeded'),
|
|
340
|
+
t('mcp_doctor.compat_web3_unneeded_hint')
|
|
341
|
+
)
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const summary = summarizeChecks(checks);
|
|
347
|
+
const output = {
|
|
348
|
+
ok: summary.failed === 0,
|
|
349
|
+
targetDir,
|
|
350
|
+
strictEnv,
|
|
351
|
+
context: {
|
|
352
|
+
exists: contextResult.exists,
|
|
353
|
+
parsed: contextResult.parsed,
|
|
354
|
+
filePath: contextPath,
|
|
355
|
+
projectType: String(contextData.project_type || ''),
|
|
356
|
+
framework: String(contextData.framework || ''),
|
|
357
|
+
conversationLanguage: String(contextData.conversation_language || '')
|
|
358
|
+
},
|
|
359
|
+
plan: {
|
|
360
|
+
filePath: planPath,
|
|
361
|
+
exists: planFile.exists,
|
|
362
|
+
parsed: planFile.parsed,
|
|
363
|
+
serverCount: serverMap.size,
|
|
364
|
+
enabledServers: enabledServers.map((server) => String(server.id || ''))
|
|
365
|
+
},
|
|
366
|
+
env: {
|
|
367
|
+
required: requiredEnv,
|
|
368
|
+
missing: missingEnv
|
|
369
|
+
},
|
|
370
|
+
presets: presetChecks,
|
|
371
|
+
checks,
|
|
372
|
+
summary
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
if (options.json) {
|
|
376
|
+
return output;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
logger.log(t('mcp_doctor.report_title', { path: targetDir }));
|
|
380
|
+
for (const check of checks) {
|
|
381
|
+
logger.log(
|
|
382
|
+
t('mcp_doctor.check_line', {
|
|
383
|
+
prefix: formatCheckPrefix(check, t),
|
|
384
|
+
id: check.id,
|
|
385
|
+
message: check.message
|
|
386
|
+
})
|
|
387
|
+
);
|
|
388
|
+
if (check.hint) {
|
|
389
|
+
logger.log(t('mcp_doctor.hint_line', { hint: check.hint }));
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
logger.log(
|
|
393
|
+
t('mcp_doctor.summary', {
|
|
394
|
+
passed: summary.passed,
|
|
395
|
+
failed: summary.failed,
|
|
396
|
+
warnings: summary.warnings
|
|
397
|
+
})
|
|
398
|
+
);
|
|
399
|
+
|
|
400
|
+
return output;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
module.exports = {
|
|
404
|
+
runMcpDoctor,
|
|
405
|
+
summarizeChecks
|
|
406
|
+
};
|