@gong-ym/ai-spec-auto 0.2.14 → 0.2.15
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/.agents/commands/README.md +33 -33
- package/.agents/commands/claude/spec-start-review.md +88 -88
- package/.agents/commands/codex/spec-continue.md +74 -74
- package/.agents/commands/codex/spec-orchestrate.md +35 -35
- package/.agents/commands/codex/spec-start-review.md +88 -88
- package/.agents/commands/codex/spec-start.md +67 -67
- package/.agents/commands/codex/spec-status.md +22 -22
- package/.agents/commands/codex/spec-stop.md +29 -29
- package/.agents/commands/codex/spec-update.md +40 -40
- package/.agents/commands/common/branch-review.md +117 -117
- package/.agents/commands/common/project-init.md +25 -25
- package/.agents/commands/common/spec-continue.md +74 -74
- package/.agents/commands/common/spec-orchestrate.md +35 -35
- package/.agents/commands/common/spec-start-review.md +82 -82
- package/.agents/commands/common/spec-start.md +67 -67
- package/.agents/commands/common/spec-status.md +22 -22
- package/.agents/commands/common/spec-stop.md +29 -29
- package/.agents/commands/common/spec-update.md +60 -40
- package/.agents/commands/cursor/opsx-apply.md +55 -55
- package/.agents/commands/cursor/opsx-archive.md +48 -48
- package/.agents/commands/cursor/opsx-explore.md +45 -45
- package/.agents/commands/cursor/opsx-propose.md +59 -59
- package/.agents/commands/cursor/spec-continue.md +63 -63
- package/.agents/commands/cursor/spec-orchestrate.md +53 -53
- package/.agents/commands/cursor/spec-start-review.md +78 -78
- package/.agents/commands/cursor/spec-start.md +59 -59
- package/.agents/commands/cursor/spec-status.md +30 -30
- package/.agents/commands/cursor/spec-stop.md +29 -29
- package/.agents/commands/cursor/spec-update.md +41 -41
- package/.agents/flows/FRONTMATTER.md +263 -263
- package/.agents/flows/RUN_OUTPUT.md +263 -263
- package/.agents/flows/common/README.md +29 -29
- package/.agents/flows/common/bugfix-to-verification.md +95 -95
- package/.agents/flows/common/change-to-architecture-review.md +89 -89
- package/.agents/flows/common/change-to-release.md +94 -94
- package/.agents/flows/common/prd-to-delivery.md +184 -184
- package/.agents/flows/common/requirement-to-observability.md +97 -97
- package/.agents/orchestration/README.md +22 -22
- package/.agents/orchestration/expert-dispatch-spec.md +155 -155
- package/.agents/orchestration/expert-executor-spec.md +84 -84
- package/.agents/orchestration/expert-runtime-action-spec.md +73 -73
- package/.agents/orchestration/runtime-state-handoff-spec.md +264 -264
- package/.agents/orchestration/task-anchor-spec.md +212 -212
- package/.agents/orchestration/task-orchestrator-adapter-payload.md +153 -153
- package/.agents/orchestration/task-orchestrator-bootstrap-payload.md +145 -145
- package/.agents/orchestration/task-orchestrator-output-extractor-spec.md +93 -93
- package/.agents/orchestration/task-orchestrator-run-plan-template.md +312 -312
- package/.agents/orchestration/task-orchestrator-runtime-hooks.md +214 -214
- package/.agents/registry/README.md +63 -63
- package/.agents/registry/flows.json +125 -125
- package/.agents/registry/profiles.json +101 -101
- package/.agents/registry/roles.json +1265 -1265
- package/.agents/registry/rules.json +148 -148
- package/.agents/registry/scenario-packages.json +123 -123
- package/.agents/registry/skills.json +130 -130
- package/.agents/roles/INDEX.md +346 -346
- package/.agents/roles/common/README.md +76 -76
- package/.agents/roles/common/archive-change.md +80 -80
- package/.agents/roles/common/backend-implementer.md +92 -92
- package/.agents/roles/common/code-guardian.md +151 -151
- package/.agents/roles/common/frontend-implementer.md +146 -146
- package/.agents/roles/common/requirement-analyst.md +138 -138
- package/.agents/roles/common/task-orchestrator-routing.md +301 -301
- package/.agents/roles/common/task-orchestrator.md +224 -224
- package/.agents/roles/common/tooling-implementer.md +92 -92
- package/.agents/roles/domains/README.md +35 -35
- package/.agents/roles/domains/delivery/README.md +11 -11
- package/.agents/roles/domains/delivery/container-specialist.md +50 -50
- package/.agents/roles/domains/delivery/deployment-specialist.md +50 -50
- package/.agents/roles/domains/delivery/pipeline-specialist.md +50 -50
- package/.agents/roles/domains/demand-design/README.md +16 -16
- package/.agents/roles/domains/demand-design/api-contract-specialist.md +52 -52
- package/.agents/roles/domains/demand-design/design-collaborator.md +58 -58
- package/.agents/roles/domains/documentation/README.md +11 -11
- package/.agents/roles/domains/documentation/api-doc-specialist.md +50 -50
- package/.agents/roles/domains/documentation/component-doc-specialist.md +49 -49
- package/.agents/roles/domains/documentation/technical-writing-specialist.md +48 -48
- package/.agents/roles/domains/engineering/README.md +17 -17
- package/.agents/roles/domains/engineering/architecture-advisor.md +53 -53
- package/.agents/roles/domains/engineering/build-specialist.md +51 -51
- package/.agents/roles/domains/engineering/dependency-governor.md +52 -52
- package/.agents/roles/domains/governance/README.md +17 -17
- package/.agents/roles/domains/governance/api-governance-specialist.md +51 -51
- package/.agents/roles/domains/governance/lint-policy-specialist.md +49 -49
- package/.agents/roles/domains/governance/route-governance-specialist.md +52 -52
- package/.agents/roles/domains/observability/README.md +11 -11
- package/.agents/roles/domains/observability/error-tracker.md +50 -50
- package/.agents/roles/domains/observability/event-instrumentation-specialist.md +51 -51
- package/.agents/roles/domains/observability/rum-analyst.md +50 -50
- package/.agents/roles/domains/performance/README.md +11 -11
- package/.agents/roles/domains/performance/asset-optimizer.md +50 -50
- package/.agents/roles/domains/performance/performance-auditor.md +56 -56
- package/.agents/roles/domains/performance/vitals-analyst.md +50 -50
- package/.agents/roles/domains/security-a11y/README.md +11 -11
- package/.agents/roles/domains/security-a11y/a11y-auditor.md +50 -50
- package/.agents/roles/domains/security-a11y/aria-specialist.md +51 -51
- package/.agents/roles/domains/security-a11y/security-reviewer.md +49 -49
- package/.agents/roles/domains/testing/README.md +12 -12
- package/.agents/roles/domains/testing/coverage-analyst.md +50 -50
- package/.agents/roles/domains/testing/e2e-test-specialist.md +51 -51
- package/.agents/roles/domains/testing/unit-test-specialist.md +56 -56
- package/.agents/roles/domains/testing/verification-reviewer.md +67 -67
- package/.agents/rules/README.md +87 -87
- package/.agents/rules/common/02-/347/274/226/347/240/201/350/247/204/350/214/203.md +45 -45
- package/.agents/rules/common/08-/351/200/232/347/224/250/347/272/246/346/235/237.md +63 -63
- package/.agents/rules/common/10-/346/226/207/346/241/243/350/247/204/350/214/203.md +101 -101
- package/.agents/rules/common/12-Superpowers/346/211/247/350/241/214/350/247/204/350/214/203.md +46 -46
- package/.agents/rules/common/14-/345/256/241/350/256/241/346/261/207/346/212/245/350/247/204/350/214/203.md +107 -107
- package/.agents/rules/common/15-visual-gate-wait.md +90 -90
- package/.agents/rules/profiles/nestjs/01-/351/241/271/347/233/256/346/246/202/350/277/260.md +27 -27
- package/.agents/rules/profiles/nestjs/03-/351/241/271/347/233/256/347/273/223/346/236/204.md +20 -20
- package/.agents/rules/profiles/nestjs/04-/346/250/241/345/235/227/347/273/223/346/236/204/350/247/204/350/214/203.md +24 -24
- package/.agents/rules/profiles/nestjs/05-/346/216/245/345/217/243/344/270/216/345/245/221/347/272/246/350/247/204/350/214/203.md +24 -24
- package/.agents/rules/profiles/nestjs/06-/346/225/260/346/215/256/350/256/277/351/227/256/350/247/204/350/214/203.md +24 -24
- package/.agents/rules/profiles/nestjs/07-/351/205/215/347/275/256/344/270/216/350/277/220/350/241/214/346/227/266/350/247/204/350/214/203.md +20 -20
- package/.agents/rules/profiles/nestjs/09-/345/274/202/345/270/270/344/270/216/346/227/245/345/277/227/350/247/204/350/214/203.md +20 -20
- package/.agents/rules/profiles/nestjs/11-/346/265/213/350/257/225/350/247/204/350/214/203.md +24 -24
- package/.agents/rules/profiles/nestjs/13-/344/273/243/347/240/201/346/240/274/345/274/217/345/214/226/344/270/216/346/243/200/346/237/245.md +20 -20
- package/.agents/rules/profiles/node-tooling/01-/351/241/271/347/233/256/346/246/202/350/277/260.md +30 -30
- package/.agents/rules/profiles/node-tooling/03-/351/241/271/347/233/256/347/273/223/346/236/204.md +37 -37
- package/.agents/rules/profiles/node-tooling/04-CLI/344/270/216/346/250/241/345/235/227/350/247/204/350/214/203.md +42 -42
- package/.agents/rules/profiles/node-tooling/05-Contract/344/270/216Schema/350/247/204/350/214/203.md +42 -42
- package/.agents/rules/profiles/node-tooling/06-/350/277/220/350/241/214/346/227/266/346/226/207/344/273/266/350/247/204/350/214/203.md +30 -30
- package/.agents/rules/profiles/node-tooling/07-/346/227/245/345/277/227/344/270/216/351/224/231/350/257/257/345/244/204/347/220/206/350/247/204/350/214/203.md +60 -60
- package/.agents/rules/profiles/node-tooling/09-/350/204/232/346/234/254/344/270/216/345/205/245/345/217/243/350/247/204/350/214/203.md +45 -45
- package/.agents/rules/profiles/node-tooling/11-/346/265/213/350/257/225/350/247/204/350/214/203.md +41 -41
- package/.agents/rules/profiles/node-tooling/13-/344/273/243/347/240/201/346/240/274/345/274/217/345/214/226/344/270/216/346/243/200/346/237/245.md +55 -55
- package/.agents/rules/profiles/react/01-/351/241/271/347/233/256/346/246/202/350/277/260.md +29 -29
- package/.agents/rules/profiles/react/03-/351/241/271/347/233/256/347/273/223/346/236/204.md +104 -104
- package/.agents/rules/profiles/react/04-/347/273/204/344/273/266/350/247/204/350/214/203.md +46 -46
- package/.agents/rules/profiles/react/05-API/350/247/204/350/214/203.md +67 -67
- package/.agents/rules/profiles/react/06-/350/267/257/347/224/261/350/247/204/350/214/203.md +54 -54
- package/.agents/rules/profiles/react/07-/347/212/266/346/200/201/347/256/241/347/220/206.md +226 -226
- package/.agents/rules/profiles/react/09-/346/240/267/345/274/217/350/247/204/350/214/203.md +71 -71
- package/.agents/rules/profiles/react/11-/346/265/213/350/257/225/350/247/204/350/214/203.md +80 -80
- package/.agents/rules/profiles/react/13-/344/273/243/347/240/201/346/240/274/345/274/217/345/214/226/344/270/216/346/243/200/346/237/245.md +159 -159
- package/.agents/rules/profiles/springboot/01-/351/241/271/347/233/256/346/246/202/350/277/260.md +31 -31
- package/.agents/rules/profiles/springboot/03-/351/241/271/347/233/256/347/273/223/346/236/204.md +37 -37
- package/.agents/rules/profiles/springboot/04-/345/210/206/345/261/202/350/247/204/350/214/203.md +33 -33
- package/.agents/rules/profiles/springboot/05-/346/216/245/345/217/243/344/270/216/345/245/221/347/272/246/350/247/204/350/214/203.md +51 -51
- package/.agents/rules/profiles/springboot/06-/346/225/260/346/215/256/350/256/277/351/227/256/350/247/204/350/214/203.md +34 -34
- package/.agents/rules/profiles/springboot/07-/351/205/215/347/275/256/344/270/216/350/277/220/350/241/214/346/227/266/350/247/204/350/214/203.md +38 -38
- package/.agents/rules/profiles/springboot/09-/345/274/202/345/270/270/344/270/216/346/227/245/345/277/227/350/247/204/350/214/203.md +48 -48
- package/.agents/rules/profiles/springboot/11-/346/265/213/350/257/225/350/247/204/350/214/203.md +43 -43
- package/.agents/rules/profiles/springboot/13-/344/273/243/347/240/201/346/240/274/345/274/217/345/214/226/344/270/216/346/243/200/346/237/245.md +48 -48
- package/.agents/rules/profiles/vue/01-/351/241/271/347/233/256/346/246/202/350/277/260.md +47 -47
- package/.agents/rules/profiles/vue/03-/351/241/271/347/233/256/347/273/223/346/236/204.md +106 -106
- package/.agents/rules/profiles/vue/04-/347/273/204/344/273/266/350/247/204/350/214/203.md +61 -61
- package/.agents/rules/profiles/vue/05-API/350/247/204/350/214/203.md +67 -67
- package/.agents/rules/profiles/vue/06-/350/267/257/347/224/261/350/247/204/350/214/203.md +69 -69
- package/.agents/rules/profiles/vue/07-/347/212/266/346/200/201/347/256/241/347/220/206.md +93 -93
- package/.agents/rules/profiles/vue/09-/346/240/267/345/274/217/350/247/204/350/214/203.md +67 -67
- package/.agents/rules/profiles/vue/11-/346/265/213/350/257/225/350/247/204/350/214/203.md +80 -80
- package/.agents/rules/profiles/vue/13-/344/273/243/347/240/201/346/240/274/345/274/217/345/214/226/344/270/216/346/243/200/346/237/245.md +159 -159
- package/.agents/skills/README.md +171 -171
- package/.agents/skills/common/archive-change/SKILL.md +180 -180
- package/.agents/skills/common/branch-code-reviewer/SKILL.md +533 -533
- package/.agents/skills/common/branch-code-reviewer/references/business-risk-guide.md +293 -293
- package/.agents/skills/common/branch-code-reviewer/references/html-template-guide.md +121 -121
- package/.agents/skills/common/config-and-secret-scan/SKILL.md +99 -99
- package/.agents/skills/common/create-proposal/SKILL.md +192 -192
- package/.agents/skills/common/create-proposal/evals/evals.json +16 -16
- package/.agents/skills/common/create-proposal/evals/train_queries.json +18 -18
- package/.agents/skills/common/create-proposal/evals/validation_queries.json +18 -18
- package/.agents/skills/common/create-proposal/references/interaction-spec-template.md +42 -42
- package/.agents/skills/common/create-test/SKILL.md +292 -292
- package/.agents/skills/common/dependency-impact-graph/SKILL.md +80 -80
- package/.agents/skills/common/execute-task/SKILL.md +206 -206
- package/.agents/skills/common/execute-task/evals/evals.json +16 -16
- package/.agents/skills/common/execute-task/evals/train_queries.json +18 -18
- package/.agents/skills/common/execute-task/evals/validation_queries.json +18 -18
- package/.agents/skills/common/find-skills/SKILL.md +144 -144
- package/.agents/skills/common/install-ai-spec-auto/SKILL.md +260 -260
- package/.agents/skills/common/install-ai-spec-auto/evals/evals.json +17 -17
- package/.agents/skills/common/install-ai-spec-auto/evals/train_queries.json +18 -18
- package/.agents/skills/common/install-ai-spec-auto/evals/validation_queries.json +18 -18
- package/.agents/skills/common/project-init/SKILL.md +178 -178
- package/.agents/skills/common/project-init/evals/evals.json +16 -16
- package/.agents/skills/common/project-init/evals/train_queries.json +18 -18
- package/.agents/skills/common/project-init/evals/validation_queries.json +18 -18
- package/.agents/skills/common/project-init/references/custom-rule-generation.md +89 -89
- package/.agents/skills/common/project-init/references/deep-scan-rules.md +67 -67
- package/.agents/skills/common/project-init/references/output-contracts.md +71 -71
- package/.agents/skills/common/project-init/references/repo-fact-gathering.md +83 -83
- package/.agents/skills/common/project-init/references/scope-resolution.md +76 -76
- package/.agents/skills/common/project-init/scripts/inspect-project.js +112 -112
- package/.agents/skills/common/skill-creator/LICENSE.txt +201 -201
- package/.agents/skills/common/skill-creator/SKILL.md +370 -370
- package/.agents/skills/common/skill-creator/evals/evals.json +16 -16
- package/.agents/skills/common/skill-creator/evals/train_queries.json +18 -18
- package/.agents/skills/common/skill-creator/evals/validation_queries.json +18 -18
- package/.agents/skills/common/skill-creator/references/output-patterns.md +82 -82
- package/.agents/skills/common/skill-creator/references/workflows.md +27 -27
- package/.agents/skills/common/skill-creator/scripts/init_skill.py +209 -209
- package/.agents/skills/common/skill-creator/scripts/package_skill.py +110 -110
- package/.agents/skills/common/skill-creator/scripts/quick_validate.py +51 -51
- package/.agents/skills/common/skill-optimizer/SKILL.md +102 -102
- package/.agents/skills/common/skill-optimizer/evals/evals.json +16 -16
- package/.agents/skills/common/skill-optimizer/evals/train_queries.json +18 -18
- package/.agents/skills/common/skill-optimizer/evals/validation_queries.json +18 -18
- package/.agents/skills/common/skill-optimizer/references/design-patterns.md +26 -26
- package/.agents/skills/common/skill-optimizer/references/review-checklist.md +22 -22
- package/.agents/skills/common/using-superpowers/SKILL.md +151 -151
- package/.agents/skills/common/wait-for-gate-signal/SKILL.md +85 -85
- package/.agents/skills/domains/README.md +19 -19
- package/.agents/skills/domains/ui-ux-pro-max/SKILL.md +58 -58
- package/.agents/skills/domains/web/design-analysis/SKILL.md +89 -89
- package/.agents/skills/domains/web/design-analysis/rules/analysis-order.md +61 -61
- package/.agents/skills/domains/web/design-analysis/rules/analysis-priorities.md +136 -136
- package/.agents/skills/domains/web/design-analysis/rules/checklist-common-misses.md +107 -107
- package/.agents/skills/domains/web/design-analysis/rules/implementation-common-errors.md +204 -204
- package/.agents/skills/domains/web/design-analysis/rules/implementation-guidelines.md +211 -211
- package/.agents/skills/domains/web/design-analysis/rules/output-analysis-checklist.md +247 -247
- package/.agents/skills/domains/web/design-analysis/rules/tools-design-guidelines.md +108 -108
- package/.agents/skills/domains/web/design-analysis/rules/workflow-element-extraction.md +162 -162
- package/.agents/skills/domains/web/design-analysis/rules/workflow-layout-map.md +131 -131
- package/.agents/skills/domains/web/design-analysis/rules/workflow-output-checklist.md +70 -70
- package/.agents/skills/domains/web/design-analysis/rules/workflow-style-summary.md +91 -91
- package/.agents/skills/domains/web/route-permission-map/SKILL.md +103 -103
- package/.agents/skills/domains/web/ui-verification/SKILL.md +114 -114
- package/.agents/skills/domains/web/ui-verification/evals/evals.json +16 -16
- package/.agents/skills/domains/web/ui-verification/evals/train_queries.json +18 -18
- package/.agents/skills/domains/web/ui-verification/evals/validation_queries.json +18 -18
- package/.agents/skills/domains/web/ui-verification/rules/comparison-content-image.md +34 -34
- package/.agents/skills/domains/web/ui-verification/rules/comparison-content-text.md +30 -30
- package/.agents/skills/domains/web/ui-verification/rules/comparison-hierarchy.md +33 -33
- package/.agents/skills/domains/web/ui-verification/rules/comparison-layout.md +35 -35
- package/.agents/skills/domains/web/ui-verification/rules/errors-alignment.md +42 -42
- package/.agents/skills/domains/web/ui-verification/rules/errors-button-dimensions.md +28 -28
- package/.agents/skills/domains/web/ui-verification/rules/errors-button-position.md +25 -25
- package/.agents/skills/domains/web/ui-verification/rules/errors-css-priority.md +50 -50
- package/.agents/skills/domains/web/ui-verification/rules/errors-flex-column-width.md +46 -46
- package/.agents/skills/domains/web/ui-verification/rules/errors-flex-layout.md +46 -46
- package/.agents/skills/domains/web/ui-verification/rules/errors-grid-container-width.md +44 -44
- package/.agents/skills/domains/web/ui-verification/rules/errors-page-container-width.md +39 -39
- package/.agents/skills/domains/web/ui-verification/rules/tools-browser-navigation.md +53 -53
- package/.agents/skills/domains/web/ui-verification/rules/tools-design-guidelines.md +53 -53
- package/.agents/skills/domains/web/ui-verification/rules/workflow-checklist.md +27 -27
- package/.agents/skills/domains/web/ui-verification/rules/workflow-problem-list.md +56 -56
- package/.agents/skills/domains/web/ui-verification/rules/workflow-reflection.md +44 -44
- package/.agents/skills/domains/web/ui-verification/rules/writing-alignment.md +44 -44
- package/.agents/skills/domains/web/ui-verification/rules/writing-element-completeness.md +63 -63
- package/.agents/skills/domains/web/ui-verification/rules/writing-list-layout.md +75 -75
- package/.agents/skills/domains/web/ui-verification/rules/writing-page-container-width.md +37 -37
- package/.agents/skills/domains/web/web-design-guidelines/SKILL.md +40 -40
- package/.agents/skills/profiles/nestjs/README.md +4 -4
- package/.agents/skills/profiles/node-tooling/README.md +9 -9
- package/.agents/skills/profiles/react/create-api/SKILL.md +145 -145
- package/.agents/skills/profiles/react/create-component/SKILL.md +160 -160
- package/.agents/skills/profiles/react/create-route/SKILL.md +168 -168
- package/.agents/skills/profiles/react/create-store/SKILL.md +262 -262
- package/.agents/skills/profiles/react/theme-variables/SKILL.md +82 -82
- package/.agents/skills/profiles/react/vercel-composition-patterns/AGENTS.md +899 -899
- package/.agents/skills/profiles/react/vercel-composition-patterns/SKILL.md +81 -81
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md +100 -100
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/architecture-compound-components.md +112 -112
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/patterns-children-over-render-props.md +87 -87
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/patterns-explicit-variants.md +100 -100
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/state-context-interface.md +191 -191
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/state-decouple-implementation.md +113 -113
- package/.agents/skills/profiles/react/vercel-composition-patterns/rules/state-lift-state.md +125 -125
- package/.agents/skills/profiles/react/vercel-react-best-practices/AGENTS.md +2934 -2934
- package/.agents/skills/profiles/react/vercel-react-best-practices/SKILL.md +136 -136
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -55
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/advanced-init-once.md +42 -42
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/advanced-use-latest.md +39 -39
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/async-api-routes.md +38 -38
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/async-defer-await.md +80 -80
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/async-dependencies.md +51 -51
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/async-parallel.md +28 -28
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -99
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -59
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/bundle-conditional.md +31 -31
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -49
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -35
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/bundle-preload.md +50 -50
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/client-event-listeners.md +74 -74
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -71
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -48
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/client-swr-dedup.md +56 -56
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -107
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-cache-function-results.md +80 -80
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-cache-property-access.md +28 -28
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-cache-storage.md +70 -70
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-combine-iterations.md +32 -32
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-early-exit.md +50 -50
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -45
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-index-maps.md +37 -37
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-length-check-first.md +49 -49
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-min-max-loop.md +82 -82
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -24
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -57
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-activity.md +26 -26
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -47
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -40
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -38
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -46
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -82
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -30
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -28
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -75
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -39
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-dependencies.md +45 -45
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -40
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-derived-state.md +29 -29
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -74
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -58
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -38
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-memo.md +44 -44
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -45
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -35
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-transitions.md +40 -40
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -73
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -73
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-auth-actions.md +96 -96
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-cache-lru.md +41 -41
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-cache-react.md +76 -76
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-dedup-props.md +65 -65
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -83
- package/.agents/skills/profiles/react/vercel-react-best-practices/rules/server-serialization.md +38 -38
- package/.agents/skills/profiles/springboot/README.md +10 -10
- package/.agents/skills/profiles/vue/create-api/SKILL.md +105 -105
- package/.agents/skills/profiles/vue/create-component/SKILL.md +76 -76
- package/.agents/skills/profiles/vue/create-route/SKILL.md +141 -141
- package/.agents/skills/profiles/vue/create-store/SKILL.md +97 -97
- package/.agents/skills/profiles/vue/create-view/SKILL.md +81 -81
- package/.agents/skills/profiles/vue/theme-variables/SKILL.md +73 -73
- package/.agents/skills/profiles/vue/vue-best-practices/SKILL.md +166 -166
- package/.agents/skills/profiles/vue/vue-best-practices/references/animation-class-based-technique.md +254 -254
- package/.agents/skills/profiles/vue/vue-best-practices/references/animation-state-driven-technique.md +291 -291
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-async.md +97 -97
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-data-flow.md +307 -307
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-fallthrough-attrs.md +174 -174
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-keep-alive.md +137 -137
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-slots.md +216 -216
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-suspense.md +228 -228
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-teleport.md +108 -108
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-transition-group.md +128 -128
- package/.agents/skills/profiles/vue/vue-best-practices/references/component-transition.md +125 -125
- package/.agents/skills/profiles/vue/vue-best-practices/references/composables.md +290 -290
- package/.agents/skills/profiles/vue/vue-best-practices/references/directives.md +162 -162
- package/.agents/skills/profiles/vue/vue-best-practices/references/perf-avoid-component-abstraction-in-lists.md +159 -159
- package/.agents/skills/profiles/vue/vue-best-practices/references/perf-v-once-v-memo-directives.md +182 -182
- package/.agents/skills/profiles/vue/vue-best-practices/references/perf-virtualize-large-lists.md +187 -187
- package/.agents/skills/profiles/vue/vue-best-practices/references/plugins.md +166 -166
- package/.agents/skills/profiles/vue/vue-best-practices/references/reactivity.md +344 -344
- package/.agents/skills/profiles/vue/vue-best-practices/references/render-functions.md +201 -201
- package/.agents/skills/profiles/vue/vue-best-practices/references/sfc.md +310 -310
- package/.agents/skills/profiles/vue/vue-best-practices/references/state-management.md +135 -135
- package/.agents/skills/profiles/vue/vue-best-practices/references/updated-hook-performance.md +187 -187
- package/.agents/templates/common/README.md +23 -23
- package/.agents/templates/common/bugfix.md +22 -22
- package/.agents/templates/common/create-expert-package.md +458 -458
- package/.agents/templates/common/mock-page.md +28 -28
- package/.agents/templates/common/new-component.md +25 -25
- package/.agents/templates/common/new-page.md +31 -31
- package/.cursor/mcp.json +35 -35
- package/.qoder/mcp.json +26 -26
- package/bin/archive-change.js +560 -474
- package/bin/check-command.js +62 -62
- package/bin/cli.js +0 -0
- package/bin/command-template-renderer.js +40 -40
- package/bin/context-command.js +102 -102
- package/bin/demo-runtime-smoke.js +760 -760
- package/bin/execution-semantics.js +821 -821
- package/bin/executor-command.js +93 -93
- package/bin/expert-dispatch.js +334 -334
- package/bin/expert-executor.js +1148 -1148
- package/bin/guard-command.js +52 -52
- package/bin/hub-command.js +876 -876
- package/bin/ide-command.js +242 -242
- package/bin/init-command.js +193 -193
- package/bin/install-workflow.js +35 -3
- package/bin/manifest-export.js +34 -34
- package/bin/profile-registry.js +90 -90
- package/bin/protocol-workflow.js +452 -446
- package/bin/repair-command.js +161 -161
- package/bin/repo-map.js +177 -177
- package/bin/report-command.js +236 -236
- package/bin/runtime-bootstrap.js +428 -428
- package/bin/runtime-embedded.js +101 -101
- package/bin/runtime-fallback.js +106 -106
- package/bin/runtime-launcher.js +116 -116
- package/bin/runtime-paths.js +177 -177
- package/bin/runtime-registry.js +289 -289
- package/bin/runtime-state.js +2541 -2541
- package/bin/scan.js +96 -96
- package/bin/self-upgrade.js +206 -206
- package/bin/skill-spec-validator.js +457 -457
- package/bin/spec-command.js +366 -366
- package/bin/superpowers.js +384 -384
- package/bin/sync-command.js +59 -59
- package/bin/sync.js +1904 -1904
- package/bin/task-orchestrator-adapter.js +341 -341
- package/bin/task-orchestrator-extractor.js +274 -274
- package/bin/task-orchestrator-runner.js +1208 -1208
- package/bin/telemetry/README.md +66 -66
- package/bin/telemetry/aspect.js +153 -153
- package/bin/telemetry/collect.js +67 -67
- package/bin/telemetry/config.js +114 -114
- package/bin/telemetry/defaults.json +5 -5
- package/bin/telemetry/healthcheck.js +195 -195
- package/bin/telemetry/identity.js +53 -53
- package/bin/telemetry/index.js +25 -25
- package/bin/telemetry/reporter.js +83 -83
- package/bin/telemetry/safe.js +39 -39
- package/bin/validate-registry.js +740 -740
- package/bin/visual-bridge-config.js +117 -117
- package/bin/visual-bridge.js +287 -287
- package/bin/visual-command.js +432 -432
- package/bin/worktree-command.js +194 -194
- package/configs/common/.editorconfig +15 -15
- package/configs/common/.husky/commit-msg +4 -4
- package/configs/common/.husky/pre-commit +4 -4
- package/configs/common/.lintstagedrc +11 -11
- package/configs/common/.prettierignore +11 -11
- package/configs/common/.prettierrc.json +11 -11
- package/configs/common/.stylelintignore +14 -14
- package/configs/common/.stylelintrc.json +21 -21
- package/configs/common/commitlint.config.js +3 -3
- package/configs/profiles/nestjs/.gitkeep +1 -1
- package/configs/profiles/node-tooling/.gitkeep +1 -1
- package/configs/profiles/react/.eslintignore +6 -6
- package/configs/profiles/react/.eslintrc.js +16 -16
- package/configs/profiles/react/.stylelintrc.json +18 -18
- package/configs/profiles/springboot/.gitkeep +1 -1
- package/configs/profiles/vue/.eslintignore +6 -6
- package/configs/profiles/vue/.eslintrc.cjs +17 -17
- package/contracts/README.md +28 -28
- package/contracts/fixtures/asset-package.fixture.json +26 -26
- package/contracts/fixtures/asset-usage-feedback.fixture.json +14 -14
- package/contracts/fixtures/evidence-report.fixture.json +28 -28
- package/contracts/fixtures/manifest.fixture.json +20 -20
- package/contracts/fixtures/run-event.fixture.json +15 -15
- package/contracts/schemas/asset-package.schema.json +76 -76
- package/contracts/schemas/asset-usage-feedback.schema.json +57 -57
- package/contracts/schemas/evidence-report.schema.json +60 -60
- package/contracts/schemas/manifest.schema.json +63 -63
- package/contracts/schemas/run-event.schema.json +72 -72
- package/install.ps1 +35 -35
- package/install.sh +17 -17
- package/internal/ai-protocol-workflow.js +5824 -5600
- package/internal/hub-client.js +98 -98
- package/internal/hub-sync-selection.js +69 -69
- package/internal/visual-hooks/README.md +481 -481
- package/internal/visual-hooks/config-loader.js +218 -218
- package/internal/visual-hooks/control-puller.js +206 -206
- package/internal/visual-hooks/gate-signal.js +150 -150
- package/internal/visual-hooks/inbox-consumer.js +469 -469
- package/internal/visual-hooks/index.js +197 -197
- package/internal/visual-hooks/push-client.js +189 -189
- package/internal/visual-hooks/receipt-pusher.js +176 -176
- package/internal/visual-hooks/runtime-state-pusher.js +128 -128
- package/openspec/config.yaml.template +52 -52
- package/openspec/schemas/expert-delivery/schema.yaml +68 -68
- package/openspec/schemas/expert-delivery/templates/checklist.md +39 -39
- package/openspec/schemas/expert-delivery/templates/design.md +61 -61
- package/openspec/schemas/expert-delivery/templates/iterations.md +25 -25
- package/openspec/schemas/expert-delivery/templates/proposal.md +45 -45
- package/openspec/schemas/expert-delivery/templates/spec.md +29 -29
- package/openspec/schemas/expert-delivery/templates/tasks.md +24 -24
- package/package.json +1 -1
- package/scripts/acceptance-zero-intrusion.sh +168 -168
- package/scripts/hub-sync-assets.config.example.json +296 -296
- package/scripts/hub-sync-assets.js +2038 -2038
- package/scripts/local-verify.sh +280 -280
- package/scripts/post-publish-auto-fix-check.js +404 -404
- package/scripts/post-publish-verify.sh +175 -175
- package/scripts/setup-cursor-manual-test.sh +107 -107
- package/scripts/setup-cursor-spec-archive-test.sh +111 -111
- package/scripts/setup-visual-integration.sh +225 -225
- package/scripts/test-integration.sh +176 -176
- package/scripts/update-test-project.sh +93 -93
- package/scripts/upload-four-web.sh +57 -57
- package/scripts/verify-install-ps1-bom.js +26 -26
- package/src/agent/agent-context.js +259 -259
- package/src/agent/agent-profile.js +185 -185
- package/src/agent/agent-templates.js +161 -161
- package/src/agent/agent-types.js +108 -108
- package/src/agent/collaboration-protocol.js +333 -333
- package/src/agent/conflict-handler.js +364 -364
- package/src/agent/file-permission.js +121 -121
- package/src/agent/index.js +38 -38
- package/src/agent/permission-audit.js +151 -151
- package/src/agent/review-repair-loop.js +270 -270
- package/src/agent/tool-permission.js +101 -101
- package/src/asset/asset-dependency.js +322 -322
- package/src/asset/asset-feedback.js +350 -350
- package/src/asset/asset-fork.js +300 -300
- package/src/asset/asset-install.js +278 -278
- package/src/asset/asset-installer.js +497 -497
- package/src/asset/asset-lifecycle.js +324 -324
- package/src/asset/asset-manager.js +245 -245
- package/src/asset/asset-package-manager.js +349 -349
- package/src/asset/asset-package.js +186 -186
- package/src/asset/asset-quality.js +262 -262
- package/src/asset/asset-registry.js +387 -387
- package/src/asset/asset-version.js +293 -293
- package/src/asset/index.js +86 -86
- package/src/cache/agent-profile-cache.js +59 -59
- package/src/cache/asset-cache.js +63 -63
- package/src/cache/global-cache.js +61 -61
- package/src/cache/manifest-cache.js +30 -30
- package/src/check/check-service.js +32 -32
- package/src/config/config-layer.js +343 -343
- package/src/config/config-loader.js +60 -60
- package/src/config/defaults.js +49 -49
- package/src/connectors/hub/asset-package.js +72 -72
- package/src/connectors/hub/asset-usage-feedback.js +46 -46
- package/src/connectors/hub/hub-connector.js +44 -44
- package/src/connectors/hub/index.js +21 -21
- package/src/connectors/visual/evidence-report.js +49 -49
- package/src/connectors/visual/index.js +15 -15
- package/src/connectors/visual/queue.js +41 -41
- package/src/connectors/visual/run-event.js +81 -81
- package/src/connectors/visual/visual-connector.js +77 -77
- package/src/context/context-budget.js +59 -59
- package/src/context/context-builder.js +285 -285
- package/src/context/context-loader.js +116 -116
- package/src/context/context-planner.js +158 -158
- package/src/context/types.js +96 -96
- package/src/contracts/index.js +63 -63
- package/src/executor/executor-registry.js +78 -78
- package/src/executor/executor-result-parser.js +44 -44
- package/src/executor/executor-runner.js +141 -141
- package/src/executor/executor-selector.js +139 -139
- package/src/executor/executor-timeout.js +36 -36
- package/src/executor/providers/base-provider-utils.js +189 -189
- package/src/executor/providers/claude-code-executor-provider.js +128 -128
- package/src/executor/providers/codex-executor-provider.js +126 -126
- package/src/executor/providers/cursor-executor-provider.js +99 -99
- package/src/executor/types.js +137 -137
- package/src/git/branch-manager.js +71 -71
- package/src/git/dirty-checker.js +43 -43
- package/src/git/dirty-strategy-handler.js +29 -29
- package/src/git/git-command.js +37 -37
- package/src/git/git-repository-detector.js +45 -45
- package/src/git/multi-repo-worktree-planner.js +88 -88
- package/src/git/policy.js +19 -19
- package/src/git/strategies/block-dirty-strategy.js +34 -34
- package/src/git/strategies/ignore-dirty-strategy.js +33 -33
- package/src/git/strategies/patch-snapshot-strategy.js +53 -53
- package/src/git/strategies/wip-commit-strategy.js +38 -38
- package/src/git/types.js +71 -71
- package/src/git/worktree-manager.js +85 -85
- package/src/governance/asset-review.js +351 -351
- package/src/governance/audit-log.js +368 -368
- package/src/governance/gray-release.js +312 -312
- package/src/governance/index.js +31 -31
- package/src/governance/policy-types.js +56 -56
- package/src/governance/rbac-types.js +171 -171
- package/src/governance/rbac.js +382 -382
- package/src/governance/rollback.js +360 -360
- package/src/governance/security-policy.js +354 -354
- package/src/hook/hook-config-writer.js +125 -125
- package/src/hub/hub-client.js +186 -186
- package/src/hub/hub-config.js +39 -39
- package/src/hub/project-facts.js +31 -31
- package/src/hub/runtime-feedback-reporter.js +55 -55
- package/src/ide/adapters/adapter-protocol.js +385 -385
- package/src/ide/adapters/claude-adapter.js +419 -419
- package/src/ide/adapters/codex-adapter.js +60 -60
- package/src/ide/adapters/cursor-adapter.js +484 -484
- package/src/ide/adapters/index.js +24 -24
- package/src/ide/anchors/markdown-anchor-writer.js +152 -152
- package/src/ide/ide-service.js +270 -270
- package/src/ide/ide-types.js +94 -94
- package/src/ide/links/link-mode-resolver.js +160 -160
- package/src/ide/registry/ide-registry-builder.js +165 -165
- package/src/incident/incident-writer.js +47 -47
- package/src/incident/types.js +22 -22
- package/src/init/ide-linker.js +126 -126
- package/src/init/ide-pointer-injector.js +75 -75
- package/src/init/init-applier.js +197 -197
- package/src/init/init-plan.js +294 -294
- package/src/init/init-service.js +65 -65
- package/src/init/manifest-installer.js +302 -302
- package/src/init/types.js +26 -26
- package/src/project/config-writer.js +83 -83
- package/src/project/context-index-writer.js +82 -82
- package/src/project/json-utils.js +72 -72
- package/src/project/local-state-writer.js +50 -50
- package/src/project/lock-file-writer.js +98 -98
- package/src/project/manifest-writer.js +126 -126
- package/src/project/policy-config-writer.js +91 -91
- package/src/project/project-config-writer.js +74 -74
- package/src/project/project-files.js +39 -39
- package/src/project/registry-index-writer.js +43 -43
- package/src/project/workspace-config-writer.js +63 -63
- package/src/run/index.js +11 -11
- package/src/run/run-id.js +32 -32
- package/src/run/run-service.js +269 -269
- package/src/run/run-store.js +80 -80
- package/src/scanner/aggregator/detection-aggregator.js +23 -23
- package/src/scanner/boundary/boundary-resolver.js +229 -229
- package/src/scanner/detectors/detector-registry.js +44 -44
- package/src/scanner/detectors/fastapi-detector.js +46 -46
- package/src/scanner/detectors/go-detector.js +46 -46
- package/src/scanner/detectors/nestjs-detector.js +57 -57
- package/src/scanner/detectors/nextjs-detector.js +52 -52
- package/src/scanner/detectors/react-vite-detector.js +52 -52
- package/src/scanner/detectors/react-webpack-detector.js +57 -57
- package/src/scanner/detectors/springboot-detector.js +46 -46
- package/src/scanner/detectors/springcloud-detector.js +46 -46
- package/src/scanner/detectors/springmvc-detector.js +46 -46
- package/src/scanner/detectors/vue-vite-detector.js +52 -52
- package/src/scanner/engine.js +72 -72
- package/src/scanner/facts/fact-extractor.js +211 -211
- package/src/scanner/types.js +30 -30
- package/src/security/asset-tamper-checker.js +188 -188
- package/src/security/checksum.js +40 -40
- package/src/spec/spec-writer.js +302 -302
- package/src/state-machine/circuit-breaker.js +112 -112
- package/src/state-machine/escape-hatch.js +49 -49
- package/src/state-machine/stage-runner.js +281 -281
- package/src/state-machine/state-machine.js +24 -24
- package/src/state-machine/transition-guard.js +36 -36
- package/src/state-machine/types.js +37 -37
- package/src/sync/sync-service.js +192 -192
- package/src/visual/agent-visual.js +142 -142
- package/src/visual/event-gateway.js +357 -357
- package/src/visual/event-mapper.js +128 -128
- package/src/visual/hook-dashboard.js +216 -216
- package/src/visual/index.js +27 -27
- package/src/visual/metrics.js +287 -287
- package/src/visual/privacy-filter.js +100 -100
- package/src/visual/risk-board.js +252 -252
- package/src/visual/timeline.js +245 -245
- package/src/visual/visual-client.js +94 -94
- package/src/visual/visual-config.js +40 -40
- package/src/visual/visual-reporter.js +88 -88
package/bin/validate-registry.js
CHANGED
|
@@ -1,740 +1,740 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const {
|
|
5
|
-
getProfileIds,
|
|
6
|
-
readProfilesRegistry,
|
|
7
|
-
} = require('./profile-registry');
|
|
8
|
-
const {
|
|
9
|
-
validateSkillSpec,
|
|
10
|
-
} = require('./skill-spec-validator');
|
|
11
|
-
|
|
12
|
-
function printUsage() {
|
|
13
|
-
console.log(`Usage:
|
|
14
|
-
ai-spec-auto validate-registry [options]
|
|
15
|
-
|
|
16
|
-
Options:
|
|
17
|
-
--source <dir> Source workspace root (default: current package)
|
|
18
|
-
--json Print JSON result only
|
|
19
|
-
--help Show this help
|
|
20
|
-
`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function parseArgs(argv) {
|
|
24
|
-
const args = [...argv];
|
|
25
|
-
const options = {
|
|
26
|
-
json: false,
|
|
27
|
-
pretty: true,
|
|
28
|
-
source: null,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
while (args.length > 0) {
|
|
32
|
-
const arg = args.shift();
|
|
33
|
-
switch (arg) {
|
|
34
|
-
case '--source':
|
|
35
|
-
options.source = args.shift();
|
|
36
|
-
break;
|
|
37
|
-
case '--json':
|
|
38
|
-
options.json = true;
|
|
39
|
-
options.pretty = false;
|
|
40
|
-
break;
|
|
41
|
-
case '--pretty':
|
|
42
|
-
options.pretty = true;
|
|
43
|
-
options.json = false;
|
|
44
|
-
break;
|
|
45
|
-
case '--help':
|
|
46
|
-
case '-h':
|
|
47
|
-
options.help = true;
|
|
48
|
-
break;
|
|
49
|
-
default:
|
|
50
|
-
throw new Error(`Unknown argument: ${arg}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return options;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function getSourceDir(explicitSource) {
|
|
58
|
-
if (explicitSource) {
|
|
59
|
-
return path.resolve(explicitSource);
|
|
60
|
-
}
|
|
61
|
-
if (process.env.ENGINEERED_SPEC_LOCAL) {
|
|
62
|
-
return process.env.ENGINEERED_SPEC_LOCAL;
|
|
63
|
-
}
|
|
64
|
-
return path.join(__dirname, '..');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function readJsonFile(filePath, label) {
|
|
68
|
-
const raw = fs.readFileSync(filePath, 'utf8');
|
|
69
|
-
try {
|
|
70
|
-
return JSON.parse(raw);
|
|
71
|
-
} catch (error) {
|
|
72
|
-
throw new Error(`${label} is not valid JSON: ${filePath}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function readOptionalJsonFile(filePath, label) {
|
|
77
|
-
if (!fs.existsSync(filePath)) {
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
return readJsonFile(filePath, label);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function buildSupportedProfileSet(profilesRegistry) {
|
|
84
|
-
return new Set(getProfileIds(profilesRegistry));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function normalizeList(value) {
|
|
88
|
-
if (!value) return [];
|
|
89
|
-
if (Array.isArray(value)) {
|
|
90
|
-
return value.map((item) => String(item).trim()).filter(Boolean);
|
|
91
|
-
}
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function fileExists(sourceDir, relPath) {
|
|
96
|
-
return fs.existsSync(path.join(sourceDir, relPath));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function assertArrayOfStrings(report, value, label) {
|
|
100
|
-
if (!Array.isArray(value)) {
|
|
101
|
-
report.errors.push(`${label} must be an array`);
|
|
102
|
-
return [];
|
|
103
|
-
}
|
|
104
|
-
const invalid = value.filter((item) => typeof item !== 'string' || !item.trim());
|
|
105
|
-
if (invalid.length > 0) {
|
|
106
|
-
report.errors.push(`${label} must contain non-empty string items`);
|
|
107
|
-
}
|
|
108
|
-
return value;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function assertOptionalString(report, value, label) {
|
|
112
|
-
if (value === undefined || value === null) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
if (typeof value !== 'string' || !value.trim()) {
|
|
116
|
-
report.errors.push(`${label} must be a non-empty string`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function validateSourceDefinition(report, sourceDir, entry, label, supportedProfiles) {
|
|
121
|
-
const hasSource = typeof entry.source === 'string';
|
|
122
|
-
const hasSourceByProfile = entry.sourceByProfile && typeof entry.sourceByProfile === 'object';
|
|
123
|
-
|
|
124
|
-
if (hasSource) {
|
|
125
|
-
if (!entry.source.trim()) {
|
|
126
|
-
report.errors.push(`${label} source must be a non-empty string`);
|
|
127
|
-
} else if (!fileExists(sourceDir, entry.source)) {
|
|
128
|
-
report.errors.push(`${label} references missing source: ${entry.source}`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (hasSourceByProfile) {
|
|
133
|
-
for (const [profile, relPath] of Object.entries(entry.sourceByProfile)) {
|
|
134
|
-
if (!supportedProfiles.has(profile)) {
|
|
135
|
-
report.errors.push(`${label} has unsupported profile key: ${profile}`);
|
|
136
|
-
}
|
|
137
|
-
if (typeof relPath !== 'string' || !relPath.trim()) {
|
|
138
|
-
report.errors.push(`${label} sourceByProfile.${profile} must be a non-empty string`);
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
if (!fileExists(sourceDir, relPath)) {
|
|
142
|
-
report.errors.push(`${label} references missing profile source: ${relPath}`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
hasSource,
|
|
149
|
-
hasSourceByProfile,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function validateRuntimeTransition(report, value, label) {
|
|
154
|
-
if (value === undefined || value === null) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
158
|
-
report.errors.push(`${label} must be an object`);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
assertOptionalString(report, value.action, `${label}.action`);
|
|
162
|
-
assertOptionalString(report, value.to_role, `${label}.to_role`);
|
|
163
|
-
if (value.next_role !== undefined && value.next_role !== null) {
|
|
164
|
-
assertOptionalString(report, value.next_role, `${label}.next_role`);
|
|
165
|
-
}
|
|
166
|
-
assertOptionalString(report, value.status, `${label}.status`);
|
|
167
|
-
assertOptionalString(report, value.message, `${label}.message`);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function validateRuleContractProfiles(report, value, label, supportedProfiles) {
|
|
171
|
-
if (value === undefined || value === null) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
175
|
-
report.errors.push(`${label} must be an object`);
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
for (const [profile, entry] of Object.entries(value)) {
|
|
180
|
-
if (profile !== 'default' && !supportedProfiles.has(profile)) {
|
|
181
|
-
report.errors.push(`${label} has unsupported profile key: ${profile}`);
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
185
|
-
report.errors.push(`${label}.${profile} must be an object`);
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
if (entry.must_follow !== undefined) {
|
|
189
|
-
assertArrayOfStrings(report, entry.must_follow, `${label}.${profile}.must_follow`);
|
|
190
|
-
}
|
|
191
|
-
if (entry.blocked_when !== undefined) {
|
|
192
|
-
assertArrayOfStrings(report, entry.blocked_when, `${label}.${profile}.blocked_when`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function validateProfileList(report, value, label, supportedProfiles) {
|
|
198
|
-
const profiles = assertArrayOfStrings(report, value, label);
|
|
199
|
-
for (const profile of profiles) {
|
|
200
|
-
if (!supportedProfiles.has(profile)) {
|
|
201
|
-
report.errors.push(`${label} references unsupported profile: ${profile}`);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return profiles;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function validateProfilesRegistry(sourceDir, profilesRegistry, report) {
|
|
208
|
-
if (typeof profilesRegistry.version !== 'number') {
|
|
209
|
-
report.errors.push('profiles.json version must be a number');
|
|
210
|
-
}
|
|
211
|
-
if (!profilesRegistry.profiles || typeof profilesRegistry.profiles !== 'object') {
|
|
212
|
-
report.errors.push('profiles.json is missing "profiles" object');
|
|
213
|
-
return new Set();
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const profileIds = new Set();
|
|
217
|
-
for (const [profileId, entry] of Object.entries(profilesRegistry.profiles)) {
|
|
218
|
-
profileIds.add(profileId);
|
|
219
|
-
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
220
|
-
report.errors.push(`profiles.json entry "${profileId}" must be an object`);
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
assertOptionalString(report, entry.status, `profiles.json entry "${profileId}" status`);
|
|
225
|
-
assertOptionalString(report, entry.label, `profiles.json entry "${profileId}" label`);
|
|
226
|
-
assertOptionalString(report, entry.rules_dir, `profiles.json entry "${profileId}" rules_dir`);
|
|
227
|
-
assertOptionalString(report, entry.skills_dir, `profiles.json entry "${profileId}" skills_dir`);
|
|
228
|
-
assertOptionalString(report, entry.configs_dir, `profiles.json entry "${profileId}" configs_dir`);
|
|
229
|
-
if (entry.aliases !== undefined) {
|
|
230
|
-
assertArrayOfStrings(report, entry.aliases, `profiles.json entry "${profileId}" aliases`);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (typeof entry.rules_dir === 'string' && entry.rules_dir.trim() && !fileExists(sourceDir, entry.rules_dir)) {
|
|
234
|
-
report.errors.push(`profiles.json entry "${profileId}" references missing rules_dir: ${entry.rules_dir}`);
|
|
235
|
-
}
|
|
236
|
-
if (typeof entry.skills_dir === 'string' && entry.skills_dir.trim() && !fileExists(sourceDir, entry.skills_dir)) {
|
|
237
|
-
report.errors.push(`profiles.json entry "${profileId}" references missing skills_dir: ${entry.skills_dir}`);
|
|
238
|
-
}
|
|
239
|
-
if (typeof entry.configs_dir === 'string' && entry.configs_dir.trim() && !fileExists(sourceDir, entry.configs_dir)) {
|
|
240
|
-
report.errors.push(`profiles.json entry "${profileId}" references missing configs_dir: ${entry.configs_dir}`);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return profileIds;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function validateRulesRegistry(sourceDir, rulesRegistry, report, supportedProfiles) {
|
|
248
|
-
if (typeof rulesRegistry.version !== 'number') {
|
|
249
|
-
report.errors.push('rules.json version must be a number');
|
|
250
|
-
}
|
|
251
|
-
if (!rulesRegistry.rules || typeof rulesRegistry.rules !== 'object') {
|
|
252
|
-
report.errors.push('rules.json is missing "rules" object');
|
|
253
|
-
return new Set();
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
const ruleIds = new Set();
|
|
257
|
-
for (const [ruleId, entry] of Object.entries(rulesRegistry.rules)) {
|
|
258
|
-
ruleIds.add(ruleId);
|
|
259
|
-
if (!entry || typeof entry !== 'object') {
|
|
260
|
-
report.errors.push(`rules.json entry "${ruleId}" must be an object`);
|
|
261
|
-
continue;
|
|
262
|
-
}
|
|
263
|
-
const { hasSource, hasSourceByProfile } = validateSourceDefinition(
|
|
264
|
-
report,
|
|
265
|
-
sourceDir,
|
|
266
|
-
entry,
|
|
267
|
-
`rules.json entry "${ruleId}"`,
|
|
268
|
-
supportedProfiles,
|
|
269
|
-
);
|
|
270
|
-
if (!hasSource && !hasSourceByProfile) {
|
|
271
|
-
report.errors.push(`rules.json entry "${ruleId}" must define source or sourceByProfile`);
|
|
272
|
-
}
|
|
273
|
-
if (entry.domains !== undefined) {
|
|
274
|
-
assertArrayOfStrings(report, entry.domains, `rules.json entry "${ruleId}" domains`);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return ruleIds;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
function validateSkillsRegistry(sourceDir, skillsRegistry, report, supportedProfiles) {
|
|
282
|
-
if (typeof skillsRegistry.version !== 'number') {
|
|
283
|
-
report.errors.push('skills.json version must be a number');
|
|
284
|
-
}
|
|
285
|
-
if (!skillsRegistry.skills || typeof skillsRegistry.skills !== 'object') {
|
|
286
|
-
report.errors.push('skills.json is missing "skills" object');
|
|
287
|
-
return new Set();
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const skillIds = new Set();
|
|
291
|
-
for (const [skillId, entry] of Object.entries(skillsRegistry.skills)) {
|
|
292
|
-
skillIds.add(skillId);
|
|
293
|
-
if (!entry || typeof entry !== 'object') {
|
|
294
|
-
report.errors.push(`skills.json entry "${skillId}" must be an object`);
|
|
295
|
-
continue;
|
|
296
|
-
}
|
|
297
|
-
const { hasSource, hasSourceByProfile } = validateSourceDefinition(
|
|
298
|
-
report,
|
|
299
|
-
sourceDir,
|
|
300
|
-
entry,
|
|
301
|
-
`skills.json entry "${skillId}"`,
|
|
302
|
-
supportedProfiles,
|
|
303
|
-
);
|
|
304
|
-
if (!hasSource && !hasSourceByProfile) {
|
|
305
|
-
report.errors.push(`skills.json entry "${skillId}" must define source or sourceByProfile`);
|
|
306
|
-
}
|
|
307
|
-
if (entry.domains !== undefined) {
|
|
308
|
-
assertArrayOfStrings(report, entry.domains, `skills.json entry "${skillId}" domains`);
|
|
309
|
-
}
|
|
310
|
-
if (entry.profiles !== undefined) {
|
|
311
|
-
validateProfileList(report, entry.profiles, `skills.json entry "${skillId}" profiles`, supportedProfiles);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return skillIds;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
function collectSkillSourceEntries(skillsRegistry) {
|
|
319
|
-
const entries = [];
|
|
320
|
-
for (const [skillId, entry] of Object.entries(skillsRegistry.skills || {})) {
|
|
321
|
-
if (entry && typeof entry.source === 'string' && entry.source.trim()) {
|
|
322
|
-
entries.push({
|
|
323
|
-
skillId,
|
|
324
|
-
profile: null,
|
|
325
|
-
relPath: entry.source,
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
if (entry && entry.sourceByProfile && typeof entry.sourceByProfile === 'object') {
|
|
329
|
-
for (const [profile, relPath] of Object.entries(entry.sourceByProfile)) {
|
|
330
|
-
if (typeof relPath === 'string' && relPath.trim()) {
|
|
331
|
-
entries.push({
|
|
332
|
-
skillId,
|
|
333
|
-
profile,
|
|
334
|
-
relPath,
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
return entries;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function validateSkillSourceSpecs(sourceDir, skillsRegistry, report) {
|
|
344
|
-
const skillSourceEntries = collectSkillSourceEntries(skillsRegistry);
|
|
345
|
-
const stats = {
|
|
346
|
-
checked: 0,
|
|
347
|
-
error_count: 0,
|
|
348
|
-
warning_count: 0,
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
for (const entry of skillSourceEntries) {
|
|
352
|
-
const absPath = path.join(sourceDir, entry.relPath);
|
|
353
|
-
const label = entry.profile
|
|
354
|
-
? `skills.json entry "${entry.skillId}" (${entry.profile})`
|
|
355
|
-
: `skills.json entry "${entry.skillId}"`;
|
|
356
|
-
|
|
357
|
-
if (!fs.existsSync(absPath)) {
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
const skillReport = validateSkillSpec(absPath);
|
|
362
|
-
stats.checked += 1;
|
|
363
|
-
stats.error_count += skillReport.errors.length;
|
|
364
|
-
stats.warning_count += skillReport.warnings.length;
|
|
365
|
-
report.checked_files.push(entry.relPath);
|
|
366
|
-
|
|
367
|
-
for (const error of skillReport.errors) {
|
|
368
|
-
report.errors.push(`${label} skill-spec: ${error}`);
|
|
369
|
-
}
|
|
370
|
-
for (const warning of skillReport.warnings) {
|
|
371
|
-
report.warnings.push(`${label} skill-spec: ${warning}`);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
return stats;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
function validateRolesRegistry(sourceDir, rolesRegistry, report, supportedProfiles) {
|
|
379
|
-
if (typeof rolesRegistry.version !== 'number') {
|
|
380
|
-
report.errors.push('roles.json version must be a number');
|
|
381
|
-
}
|
|
382
|
-
if (rolesRegistry.support_files !== undefined) {
|
|
383
|
-
const supportFiles = assertArrayOfStrings(report, rolesRegistry.support_files, 'roles.json support_files');
|
|
384
|
-
for (const relPath of supportFiles) {
|
|
385
|
-
if (!fileExists(sourceDir, relPath)) {
|
|
386
|
-
report.errors.push(`roles.json support file is missing: ${relPath}`);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
if (!rolesRegistry.roles || typeof rolesRegistry.roles !== 'object') {
|
|
391
|
-
report.errors.push('roles.json is missing "roles" object');
|
|
392
|
-
return new Set();
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
const roleIds = new Set();
|
|
396
|
-
for (const [roleId, entry] of Object.entries(rolesRegistry.roles)) {
|
|
397
|
-
roleIds.add(roleId);
|
|
398
|
-
if (!entry || typeof entry !== 'object') {
|
|
399
|
-
report.errors.push(`roles.json entry "${roleId}" must be an object`);
|
|
400
|
-
continue;
|
|
401
|
-
}
|
|
402
|
-
if (typeof entry.source !== 'string' || !entry.source.trim()) {
|
|
403
|
-
report.errors.push(`roles.json entry "${roleId}" must define source`);
|
|
404
|
-
} else if (!fileExists(sourceDir, entry.source)) {
|
|
405
|
-
report.errors.push(`roles.json entry "${roleId}" references missing source: ${entry.source}`);
|
|
406
|
-
}
|
|
407
|
-
if (entry.domains !== undefined) {
|
|
408
|
-
assertArrayOfStrings(report, entry.domains, `roles.json entry "${roleId}" domains`);
|
|
409
|
-
}
|
|
410
|
-
if (entry.profiles !== undefined) {
|
|
411
|
-
validateProfileList(report, entry.profiles, `roles.json entry "${roleId}" profiles`, supportedProfiles);
|
|
412
|
-
}
|
|
413
|
-
if (entry.openspec_actions !== undefined) {
|
|
414
|
-
assertArrayOfStrings(report, entry.openspec_actions, `roles.json entry "${roleId}" openspec_actions`);
|
|
415
|
-
}
|
|
416
|
-
if (entry.rule_ids !== undefined) {
|
|
417
|
-
assertArrayOfStrings(report, entry.rule_ids, `roles.json entry "${roleId}" rule_ids`);
|
|
418
|
-
}
|
|
419
|
-
if (entry.skill_priority !== undefined) {
|
|
420
|
-
assertArrayOfStrings(report, entry.skill_priority, `roles.json entry "${roleId}" skill_priority`);
|
|
421
|
-
}
|
|
422
|
-
if (entry.micro_skill_allowlist !== undefined) {
|
|
423
|
-
assertArrayOfStrings(report, entry.micro_skill_allowlist, `roles.json entry "${roleId}" micro_skill_allowlist`);
|
|
424
|
-
}
|
|
425
|
-
if (entry.rule_contract_profiles !== undefined) {
|
|
426
|
-
validateRuleContractProfiles(report, entry.rule_contract_profiles, `roles.json entry "${roleId}" rule_contract_profiles`, supportedProfiles);
|
|
427
|
-
}
|
|
428
|
-
if (entry.openspec_rule_sections !== undefined) {
|
|
429
|
-
assertArrayOfStrings(report, entry.openspec_rule_sections, `roles.json entry "${roleId}" openspec_rule_sections`);
|
|
430
|
-
}
|
|
431
|
-
if (entry.required_inputs !== undefined) {
|
|
432
|
-
assertArrayOfStrings(report, entry.required_inputs, `roles.json entry "${roleId}" required_inputs`);
|
|
433
|
-
}
|
|
434
|
-
if (entry.required_outputs !== undefined) {
|
|
435
|
-
assertArrayOfStrings(report, entry.required_outputs, `roles.json entry "${roleId}" required_outputs`);
|
|
436
|
-
}
|
|
437
|
-
if (entry.approval_gates !== undefined) {
|
|
438
|
-
assertArrayOfStrings(report, entry.approval_gates, `roles.json entry "${roleId}" approval_gates`);
|
|
439
|
-
}
|
|
440
|
-
if (entry.runtime_transition !== undefined) {
|
|
441
|
-
validateRuntimeTransition(report, entry.runtime_transition, `roles.json entry "${roleId}" runtime_transition`);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
return roleIds;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
function validateFlowsRegistry(sourceDir, flowsRegistry, report, supportedProfiles) {
|
|
449
|
-
if (typeof flowsRegistry.version !== 'number') {
|
|
450
|
-
report.errors.push('flows.json version must be a number');
|
|
451
|
-
}
|
|
452
|
-
if (flowsRegistry.support_files !== undefined) {
|
|
453
|
-
const supportFiles = assertArrayOfStrings(report, flowsRegistry.support_files, 'flows.json support_files');
|
|
454
|
-
for (const relPath of supportFiles) {
|
|
455
|
-
if (!fileExists(sourceDir, relPath)) {
|
|
456
|
-
report.errors.push(`flows.json support file is missing: ${relPath}`);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
if (!flowsRegistry.flows || typeof flowsRegistry.flows !== 'object') {
|
|
461
|
-
report.errors.push('flows.json is missing "flows" object');
|
|
462
|
-
return new Set();
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
const flowIds = new Set();
|
|
466
|
-
for (const [flowId, entry] of Object.entries(flowsRegistry.flows)) {
|
|
467
|
-
flowIds.add(flowId);
|
|
468
|
-
if (!entry || typeof entry !== 'object') {
|
|
469
|
-
report.errors.push(`flows.json entry "${flowId}" must be an object`);
|
|
470
|
-
continue;
|
|
471
|
-
}
|
|
472
|
-
if (typeof entry.source !== 'string' || !entry.source.trim()) {
|
|
473
|
-
report.errors.push(`flows.json entry "${flowId}" must define source`);
|
|
474
|
-
} else if (!fileExists(sourceDir, entry.source)) {
|
|
475
|
-
report.errors.push(`flows.json entry "${flowId}" references missing source: ${entry.source}`);
|
|
476
|
-
}
|
|
477
|
-
if (entry.default_schema !== undefined) {
|
|
478
|
-
assertOptionalString(report, entry.default_schema, `flows.json entry "${flowId}" default_schema`);
|
|
479
|
-
}
|
|
480
|
-
if (entry.profiles !== undefined) {
|
|
481
|
-
validateProfileList(report, entry.profiles, `flows.json entry "${flowId}" profiles`, supportedProfiles);
|
|
482
|
-
}
|
|
483
|
-
if (entry.artifact_profile !== undefined) {
|
|
484
|
-
assertOptionalString(report, entry.artifact_profile, `flows.json entry "${flowId}" artifact_profile`);
|
|
485
|
-
}
|
|
486
|
-
if (entry.required_roles !== undefined) {
|
|
487
|
-
assertArrayOfStrings(report, entry.required_roles, `flows.json entry "${flowId}" required_roles`);
|
|
488
|
-
}
|
|
489
|
-
if (entry.first_handoff !== undefined) {
|
|
490
|
-
assertOptionalString(report, entry.first_handoff, `flows.json entry "${flowId}" first_handoff`);
|
|
491
|
-
}
|
|
492
|
-
if (entry.approval_gates !== undefined) {
|
|
493
|
-
assertArrayOfStrings(report, entry.approval_gates, `flows.json entry "${flowId}" approval_gates`);
|
|
494
|
-
}
|
|
495
|
-
if (entry.core_artifacts !== undefined) {
|
|
496
|
-
assertArrayOfStrings(report, entry.core_artifacts, `flows.json entry "${flowId}" core_artifacts`);
|
|
497
|
-
}
|
|
498
|
-
if (entry.required_artifacts !== undefined) {
|
|
499
|
-
assertArrayOfStrings(report, entry.required_artifacts, `flows.json entry "${flowId}" required_artifacts`);
|
|
500
|
-
}
|
|
501
|
-
if (entry.handoff_policy !== undefined) {
|
|
502
|
-
assertOptionalString(report, entry.handoff_policy, `flows.json entry "${flowId}" handoff_policy`);
|
|
503
|
-
}
|
|
504
|
-
if (entry.completion_policy !== undefined) {
|
|
505
|
-
assertOptionalString(report, entry.completion_policy, `flows.json entry "${flowId}" completion_policy`);
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
return flowIds;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
function validateRoleAndFlowReferences(rolesRegistry, flowsRegistry, report, ids) {
|
|
513
|
-
for (const [roleId, entry] of Object.entries(rolesRegistry.roles || {})) {
|
|
514
|
-
for (const ruleId of normalizeList(entry.rule_ids)) {
|
|
515
|
-
if (!ids.rules.has(ruleId)) {
|
|
516
|
-
report.errors.push(`roles.json entry "${roleId}" references unknown rule: ${ruleId}`);
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
for (const skillId of normalizeList(entry.skill_priority)) {
|
|
520
|
-
if (!ids.skills.has(skillId)) {
|
|
521
|
-
report.errors.push(`roles.json entry "${roleId}" skill_priority references unknown skill: ${skillId}`);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
for (const skillId of normalizeList(entry.micro_skill_allowlist)) {
|
|
525
|
-
if (!ids.skills.has(skillId)) {
|
|
526
|
-
report.errors.push(`roles.json entry "${roleId}" micro_skill_allowlist references unknown skill: ${skillId}`);
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
for (const skillId of normalizeList(entry.preferred_skills)) {
|
|
530
|
-
if (!ids.skills.has(skillId)) {
|
|
531
|
-
report.errors.push(`roles.json entry "${roleId}" preferred_skills references unknown skill: ${skillId}`);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
for (const handoffRole of normalizeList(entry.handoff_to)) {
|
|
535
|
-
if (!ids.roles.has(handoffRole)) {
|
|
536
|
-
report.errors.push(`roles.json entry "${roleId}" handoff_to references unknown role: ${handoffRole}`);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
for (const [flowId, entry] of Object.entries(flowsRegistry.flows || {})) {
|
|
542
|
-
for (const roleId of normalizeList(entry.required_roles)) {
|
|
543
|
-
if (!ids.roles.has(roleId)) {
|
|
544
|
-
report.errors.push(`flows.json entry "${flowId}" references unknown role in required_roles: ${roleId}`);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
if (entry.first_handoff && !ids.roles.has(entry.first_handoff)) {
|
|
548
|
-
report.errors.push(`flows.json entry "${flowId}" references unknown first_handoff role: ${entry.first_handoff}`);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
function validateScenarioPackagesRegistry(scenariosRegistry, report, ids, supportedProfiles) {
|
|
554
|
-
if (!scenariosRegistry) {
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
if (typeof scenariosRegistry.version !== 'number') {
|
|
558
|
-
report.errors.push('scenario-packages.json version must be a number');
|
|
559
|
-
}
|
|
560
|
-
if (!scenariosRegistry.scenario_packages || typeof scenariosRegistry.scenario_packages !== 'object') {
|
|
561
|
-
report.errors.push('scenario-packages.json is missing "scenario_packages" object');
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
for (const [scenarioId, entry] of Object.entries(scenariosRegistry.scenario_packages)) {
|
|
566
|
-
if (!entry || typeof entry !== 'object') {
|
|
567
|
-
report.errors.push(`scenario-packages.json entry "${scenarioId}" must be an object`);
|
|
568
|
-
continue;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
const roles = assertArrayOfStrings(report, entry.roles || [], `scenario-packages.json entry "${scenarioId}" roles`);
|
|
572
|
-
const skills = assertArrayOfStrings(report, entry.skills || [], `scenario-packages.json entry "${scenarioId}" skills`);
|
|
573
|
-
const rules = assertArrayOfStrings(report, entry.rules || [], `scenario-packages.json entry "${scenarioId}" rules`);
|
|
574
|
-
if (entry.domains !== undefined) {
|
|
575
|
-
assertArrayOfStrings(report, entry.domains, `scenario-packages.json entry "${scenarioId}" domains`);
|
|
576
|
-
}
|
|
577
|
-
if (entry.profiles !== undefined) {
|
|
578
|
-
validateProfileList(report, entry.profiles, `scenario-packages.json entry "${scenarioId}" profiles`, supportedProfiles);
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
for (const roleId of roles) {
|
|
582
|
-
if (!ids.roles.has(roleId)) {
|
|
583
|
-
report.errors.push(`scenario-packages.json entry "${scenarioId}" references unknown role: ${roleId}`);
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
for (const skillId of skills) {
|
|
587
|
-
if (!ids.skills.has(skillId)) {
|
|
588
|
-
report.errors.push(`scenario-packages.json entry "${scenarioId}" references unknown skill: ${skillId}`);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
for (const ruleId of rules) {
|
|
592
|
-
if (!ids.rules.has(ruleId)) {
|
|
593
|
-
report.errors.push(`scenario-packages.json entry "${scenarioId}" references unknown rule: ${ruleId}`);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
function validateRegistry(sourceDir) {
|
|
600
|
-
const report = {
|
|
601
|
-
schema_version: 1,
|
|
602
|
-
kind: 'registry-validation-result',
|
|
603
|
-
status: 'success',
|
|
604
|
-
source: sourceDir,
|
|
605
|
-
checked_files: [],
|
|
606
|
-
warnings: [],
|
|
607
|
-
errors: [],
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
const registryDir = path.join(sourceDir, '.agents/registry');
|
|
611
|
-
if (!fs.existsSync(registryDir)) {
|
|
612
|
-
report.errors.push(`Registry directory not found: ${registryDir}`);
|
|
613
|
-
report.status = 'failed';
|
|
614
|
-
return report;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
const rulesPath = path.join(registryDir, 'rules.json');
|
|
618
|
-
const skillsPath = path.join(registryDir, 'skills.json');
|
|
619
|
-
const rolesPath = path.join(registryDir, 'roles.json');
|
|
620
|
-
const flowsPath = path.join(registryDir, 'flows.json');
|
|
621
|
-
const scenariosPath = path.join(registryDir, 'scenario-packages.json');
|
|
622
|
-
|
|
623
|
-
const profilesRegistry = readProfilesRegistry(sourceDir);
|
|
624
|
-
const rulesRegistry = readJsonFile(rulesPath, 'rules.json');
|
|
625
|
-
const skillsRegistry = readJsonFile(skillsPath, 'skills.json');
|
|
626
|
-
const rolesRegistry = readJsonFile(rolesPath, 'roles.json');
|
|
627
|
-
const flowsRegistry = readJsonFile(flowsPath, 'flows.json');
|
|
628
|
-
const scenariosRegistry = readOptionalJsonFile(scenariosPath, 'scenario-packages.json');
|
|
629
|
-
|
|
630
|
-
report.checked_files.push(
|
|
631
|
-
'.agents/registry/profiles.json',
|
|
632
|
-
'.agents/registry/rules.json',
|
|
633
|
-
'.agents/registry/skills.json',
|
|
634
|
-
'.agents/registry/roles.json',
|
|
635
|
-
'.agents/registry/flows.json'
|
|
636
|
-
);
|
|
637
|
-
if (scenariosRegistry) {
|
|
638
|
-
report.checked_files.push('.agents/registry/scenario-packages.json');
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
const profileIds = validateProfilesRegistry(sourceDir, profilesRegistry, report);
|
|
642
|
-
const supportedProfiles = buildSupportedProfileSet(profilesRegistry);
|
|
643
|
-
const ruleIds = validateRulesRegistry(sourceDir, rulesRegistry, report, supportedProfiles);
|
|
644
|
-
const skillIds = validateSkillsRegistry(sourceDir, skillsRegistry, report, supportedProfiles);
|
|
645
|
-
const roleIds = validateRolesRegistry(sourceDir, rolesRegistry, report, supportedProfiles);
|
|
646
|
-
const flowIds = validateFlowsRegistry(sourceDir, flowsRegistry, report, supportedProfiles);
|
|
647
|
-
const skillSpecStats = validateSkillSourceSpecs(sourceDir, skillsRegistry, report);
|
|
648
|
-
const ids = {
|
|
649
|
-
profiles: profileIds,
|
|
650
|
-
roles: roleIds,
|
|
651
|
-
skills: skillIds,
|
|
652
|
-
rules: ruleIds,
|
|
653
|
-
flows: flowIds,
|
|
654
|
-
};
|
|
655
|
-
validateRoleAndFlowReferences(rolesRegistry, flowsRegistry, report, ids);
|
|
656
|
-
validateScenarioPackagesRegistry(scenariosRegistry, report, ids, supportedProfiles);
|
|
657
|
-
|
|
658
|
-
if (report.errors.length > 0) {
|
|
659
|
-
report.status = 'failed';
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
report.summary = {
|
|
663
|
-
profile_count: profileIds.size,
|
|
664
|
-
rule_count: ruleIds.size,
|
|
665
|
-
skill_count: skillIds.size,
|
|
666
|
-
role_count: roleIds.size,
|
|
667
|
-
flow_count: flowIds.size,
|
|
668
|
-
scenario_package_count: scenariosRegistry ? Object.keys(scenariosRegistry.scenario_packages || {}).length : 0,
|
|
669
|
-
};
|
|
670
|
-
report.stats = {
|
|
671
|
-
...report.summary,
|
|
672
|
-
checked_file_count: report.checked_files.length,
|
|
673
|
-
warning_count: report.warnings.length,
|
|
674
|
-
error_count: report.errors.length,
|
|
675
|
-
skill_spec: skillSpecStats,
|
|
676
|
-
};
|
|
677
|
-
|
|
678
|
-
return report;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
function printPretty(report) {
|
|
682
|
-
console.log(`registry-validation(注册表校验): ${report.status}`);
|
|
683
|
-
console.log(`source(源码目录): ${report.source}`);
|
|
684
|
-
if (report.summary) {
|
|
685
|
-
console.log(`profiles(技术栈): ${report.summary.profile_count}`);
|
|
686
|
-
console.log(`rules(规则): ${report.summary.rule_count}`);
|
|
687
|
-
console.log(`skills(技能): ${report.summary.skill_count}`);
|
|
688
|
-
console.log(`roles(专家角色): ${report.summary.role_count}`);
|
|
689
|
-
console.log(`flows(流程模板): ${report.summary.flow_count}`);
|
|
690
|
-
console.log(`scenario_packages(场景方案包): ${report.summary.scenario_package_count}`);
|
|
691
|
-
if (report.stats && report.stats.skill_spec) {
|
|
692
|
-
console.log(`skill_spec_sources(技能源码校验): ${report.stats.skill_spec.checked}`);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
if (report.warnings.length > 0) {
|
|
696
|
-
console.log('warnings(警告):');
|
|
697
|
-
for (const warning of report.warnings) {
|
|
698
|
-
console.log(`- ${warning}`);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
if (report.errors.length > 0) {
|
|
702
|
-
console.log('errors(错误):');
|
|
703
|
-
for (const error of report.errors) {
|
|
704
|
-
console.log(`- ${error}`);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
function main(argv) {
|
|
710
|
-
try {
|
|
711
|
-
const options = parseArgs(argv);
|
|
712
|
-
if (options.help) {
|
|
713
|
-
printUsage();
|
|
714
|
-
return 0;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
const sourceDir = getSourceDir(options.source);
|
|
718
|
-
const report = validateRegistry(sourceDir);
|
|
719
|
-
|
|
720
|
-
if (options.json) {
|
|
721
|
-
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
722
|
-
} else {
|
|
723
|
-
printPretty(report);
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
return report.status === 'success' ? 0 : 1;
|
|
727
|
-
} catch (error) {
|
|
728
|
-
console.error(`validate-registry(校验注册表) failed: ${error.message}`);
|
|
729
|
-
return 1;
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
module.exports = {
|
|
734
|
-
validateRegistry,
|
|
735
|
-
main,
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
if (require.main === module) {
|
|
739
|
-
process.exit(main(process.argv.slice(2)));
|
|
740
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const {
|
|
5
|
+
getProfileIds,
|
|
6
|
+
readProfilesRegistry,
|
|
7
|
+
} = require('./profile-registry');
|
|
8
|
+
const {
|
|
9
|
+
validateSkillSpec,
|
|
10
|
+
} = require('./skill-spec-validator');
|
|
11
|
+
|
|
12
|
+
function printUsage() {
|
|
13
|
+
console.log(`Usage:
|
|
14
|
+
ai-spec-auto validate-registry [options]
|
|
15
|
+
|
|
16
|
+
Options:
|
|
17
|
+
--source <dir> Source workspace root (default: current package)
|
|
18
|
+
--json Print JSON result only
|
|
19
|
+
--help Show this help
|
|
20
|
+
`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function parseArgs(argv) {
|
|
24
|
+
const args = [...argv];
|
|
25
|
+
const options = {
|
|
26
|
+
json: false,
|
|
27
|
+
pretty: true,
|
|
28
|
+
source: null,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
while (args.length > 0) {
|
|
32
|
+
const arg = args.shift();
|
|
33
|
+
switch (arg) {
|
|
34
|
+
case '--source':
|
|
35
|
+
options.source = args.shift();
|
|
36
|
+
break;
|
|
37
|
+
case '--json':
|
|
38
|
+
options.json = true;
|
|
39
|
+
options.pretty = false;
|
|
40
|
+
break;
|
|
41
|
+
case '--pretty':
|
|
42
|
+
options.pretty = true;
|
|
43
|
+
options.json = false;
|
|
44
|
+
break;
|
|
45
|
+
case '--help':
|
|
46
|
+
case '-h':
|
|
47
|
+
options.help = true;
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
throw new Error(`Unknown argument: ${arg}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return options;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getSourceDir(explicitSource) {
|
|
58
|
+
if (explicitSource) {
|
|
59
|
+
return path.resolve(explicitSource);
|
|
60
|
+
}
|
|
61
|
+
if (process.env.ENGINEERED_SPEC_LOCAL) {
|
|
62
|
+
return process.env.ENGINEERED_SPEC_LOCAL;
|
|
63
|
+
}
|
|
64
|
+
return path.join(__dirname, '..');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function readJsonFile(filePath, label) {
|
|
68
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
69
|
+
try {
|
|
70
|
+
return JSON.parse(raw);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
throw new Error(`${label} is not valid JSON: ${filePath}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function readOptionalJsonFile(filePath, label) {
|
|
77
|
+
if (!fs.existsSync(filePath)) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return readJsonFile(filePath, label);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function buildSupportedProfileSet(profilesRegistry) {
|
|
84
|
+
return new Set(getProfileIds(profilesRegistry));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function normalizeList(value) {
|
|
88
|
+
if (!value) return [];
|
|
89
|
+
if (Array.isArray(value)) {
|
|
90
|
+
return value.map((item) => String(item).trim()).filter(Boolean);
|
|
91
|
+
}
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function fileExists(sourceDir, relPath) {
|
|
96
|
+
return fs.existsSync(path.join(sourceDir, relPath));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function assertArrayOfStrings(report, value, label) {
|
|
100
|
+
if (!Array.isArray(value)) {
|
|
101
|
+
report.errors.push(`${label} must be an array`);
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
const invalid = value.filter((item) => typeof item !== 'string' || !item.trim());
|
|
105
|
+
if (invalid.length > 0) {
|
|
106
|
+
report.errors.push(`${label} must contain non-empty string items`);
|
|
107
|
+
}
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function assertOptionalString(report, value, label) {
|
|
112
|
+
if (value === undefined || value === null) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
116
|
+
report.errors.push(`${label} must be a non-empty string`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function validateSourceDefinition(report, sourceDir, entry, label, supportedProfiles) {
|
|
121
|
+
const hasSource = typeof entry.source === 'string';
|
|
122
|
+
const hasSourceByProfile = entry.sourceByProfile && typeof entry.sourceByProfile === 'object';
|
|
123
|
+
|
|
124
|
+
if (hasSource) {
|
|
125
|
+
if (!entry.source.trim()) {
|
|
126
|
+
report.errors.push(`${label} source must be a non-empty string`);
|
|
127
|
+
} else if (!fileExists(sourceDir, entry.source)) {
|
|
128
|
+
report.errors.push(`${label} references missing source: ${entry.source}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (hasSourceByProfile) {
|
|
133
|
+
for (const [profile, relPath] of Object.entries(entry.sourceByProfile)) {
|
|
134
|
+
if (!supportedProfiles.has(profile)) {
|
|
135
|
+
report.errors.push(`${label} has unsupported profile key: ${profile}`);
|
|
136
|
+
}
|
|
137
|
+
if (typeof relPath !== 'string' || !relPath.trim()) {
|
|
138
|
+
report.errors.push(`${label} sourceByProfile.${profile} must be a non-empty string`);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (!fileExists(sourceDir, relPath)) {
|
|
142
|
+
report.errors.push(`${label} references missing profile source: ${relPath}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
hasSource,
|
|
149
|
+
hasSourceByProfile,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function validateRuntimeTransition(report, value, label) {
|
|
154
|
+
if (value === undefined || value === null) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
158
|
+
report.errors.push(`${label} must be an object`);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
assertOptionalString(report, value.action, `${label}.action`);
|
|
162
|
+
assertOptionalString(report, value.to_role, `${label}.to_role`);
|
|
163
|
+
if (value.next_role !== undefined && value.next_role !== null) {
|
|
164
|
+
assertOptionalString(report, value.next_role, `${label}.next_role`);
|
|
165
|
+
}
|
|
166
|
+
assertOptionalString(report, value.status, `${label}.status`);
|
|
167
|
+
assertOptionalString(report, value.message, `${label}.message`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function validateRuleContractProfiles(report, value, label, supportedProfiles) {
|
|
171
|
+
if (value === undefined || value === null) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
175
|
+
report.errors.push(`${label} must be an object`);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
for (const [profile, entry] of Object.entries(value)) {
|
|
180
|
+
if (profile !== 'default' && !supportedProfiles.has(profile)) {
|
|
181
|
+
report.errors.push(`${label} has unsupported profile key: ${profile}`);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
185
|
+
report.errors.push(`${label}.${profile} must be an object`);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (entry.must_follow !== undefined) {
|
|
189
|
+
assertArrayOfStrings(report, entry.must_follow, `${label}.${profile}.must_follow`);
|
|
190
|
+
}
|
|
191
|
+
if (entry.blocked_when !== undefined) {
|
|
192
|
+
assertArrayOfStrings(report, entry.blocked_when, `${label}.${profile}.blocked_when`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function validateProfileList(report, value, label, supportedProfiles) {
|
|
198
|
+
const profiles = assertArrayOfStrings(report, value, label);
|
|
199
|
+
for (const profile of profiles) {
|
|
200
|
+
if (!supportedProfiles.has(profile)) {
|
|
201
|
+
report.errors.push(`${label} references unsupported profile: ${profile}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return profiles;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function validateProfilesRegistry(sourceDir, profilesRegistry, report) {
|
|
208
|
+
if (typeof profilesRegistry.version !== 'number') {
|
|
209
|
+
report.errors.push('profiles.json version must be a number');
|
|
210
|
+
}
|
|
211
|
+
if (!profilesRegistry.profiles || typeof profilesRegistry.profiles !== 'object') {
|
|
212
|
+
report.errors.push('profiles.json is missing "profiles" object');
|
|
213
|
+
return new Set();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const profileIds = new Set();
|
|
217
|
+
for (const [profileId, entry] of Object.entries(profilesRegistry.profiles)) {
|
|
218
|
+
profileIds.add(profileId);
|
|
219
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
220
|
+
report.errors.push(`profiles.json entry "${profileId}" must be an object`);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
assertOptionalString(report, entry.status, `profiles.json entry "${profileId}" status`);
|
|
225
|
+
assertOptionalString(report, entry.label, `profiles.json entry "${profileId}" label`);
|
|
226
|
+
assertOptionalString(report, entry.rules_dir, `profiles.json entry "${profileId}" rules_dir`);
|
|
227
|
+
assertOptionalString(report, entry.skills_dir, `profiles.json entry "${profileId}" skills_dir`);
|
|
228
|
+
assertOptionalString(report, entry.configs_dir, `profiles.json entry "${profileId}" configs_dir`);
|
|
229
|
+
if (entry.aliases !== undefined) {
|
|
230
|
+
assertArrayOfStrings(report, entry.aliases, `profiles.json entry "${profileId}" aliases`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (typeof entry.rules_dir === 'string' && entry.rules_dir.trim() && !fileExists(sourceDir, entry.rules_dir)) {
|
|
234
|
+
report.errors.push(`profiles.json entry "${profileId}" references missing rules_dir: ${entry.rules_dir}`);
|
|
235
|
+
}
|
|
236
|
+
if (typeof entry.skills_dir === 'string' && entry.skills_dir.trim() && !fileExists(sourceDir, entry.skills_dir)) {
|
|
237
|
+
report.errors.push(`profiles.json entry "${profileId}" references missing skills_dir: ${entry.skills_dir}`);
|
|
238
|
+
}
|
|
239
|
+
if (typeof entry.configs_dir === 'string' && entry.configs_dir.trim() && !fileExists(sourceDir, entry.configs_dir)) {
|
|
240
|
+
report.errors.push(`profiles.json entry "${profileId}" references missing configs_dir: ${entry.configs_dir}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return profileIds;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function validateRulesRegistry(sourceDir, rulesRegistry, report, supportedProfiles) {
|
|
248
|
+
if (typeof rulesRegistry.version !== 'number') {
|
|
249
|
+
report.errors.push('rules.json version must be a number');
|
|
250
|
+
}
|
|
251
|
+
if (!rulesRegistry.rules || typeof rulesRegistry.rules !== 'object') {
|
|
252
|
+
report.errors.push('rules.json is missing "rules" object');
|
|
253
|
+
return new Set();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const ruleIds = new Set();
|
|
257
|
+
for (const [ruleId, entry] of Object.entries(rulesRegistry.rules)) {
|
|
258
|
+
ruleIds.add(ruleId);
|
|
259
|
+
if (!entry || typeof entry !== 'object') {
|
|
260
|
+
report.errors.push(`rules.json entry "${ruleId}" must be an object`);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const { hasSource, hasSourceByProfile } = validateSourceDefinition(
|
|
264
|
+
report,
|
|
265
|
+
sourceDir,
|
|
266
|
+
entry,
|
|
267
|
+
`rules.json entry "${ruleId}"`,
|
|
268
|
+
supportedProfiles,
|
|
269
|
+
);
|
|
270
|
+
if (!hasSource && !hasSourceByProfile) {
|
|
271
|
+
report.errors.push(`rules.json entry "${ruleId}" must define source or sourceByProfile`);
|
|
272
|
+
}
|
|
273
|
+
if (entry.domains !== undefined) {
|
|
274
|
+
assertArrayOfStrings(report, entry.domains, `rules.json entry "${ruleId}" domains`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return ruleIds;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function validateSkillsRegistry(sourceDir, skillsRegistry, report, supportedProfiles) {
|
|
282
|
+
if (typeof skillsRegistry.version !== 'number') {
|
|
283
|
+
report.errors.push('skills.json version must be a number');
|
|
284
|
+
}
|
|
285
|
+
if (!skillsRegistry.skills || typeof skillsRegistry.skills !== 'object') {
|
|
286
|
+
report.errors.push('skills.json is missing "skills" object');
|
|
287
|
+
return new Set();
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const skillIds = new Set();
|
|
291
|
+
for (const [skillId, entry] of Object.entries(skillsRegistry.skills)) {
|
|
292
|
+
skillIds.add(skillId);
|
|
293
|
+
if (!entry || typeof entry !== 'object') {
|
|
294
|
+
report.errors.push(`skills.json entry "${skillId}" must be an object`);
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
const { hasSource, hasSourceByProfile } = validateSourceDefinition(
|
|
298
|
+
report,
|
|
299
|
+
sourceDir,
|
|
300
|
+
entry,
|
|
301
|
+
`skills.json entry "${skillId}"`,
|
|
302
|
+
supportedProfiles,
|
|
303
|
+
);
|
|
304
|
+
if (!hasSource && !hasSourceByProfile) {
|
|
305
|
+
report.errors.push(`skills.json entry "${skillId}" must define source or sourceByProfile`);
|
|
306
|
+
}
|
|
307
|
+
if (entry.domains !== undefined) {
|
|
308
|
+
assertArrayOfStrings(report, entry.domains, `skills.json entry "${skillId}" domains`);
|
|
309
|
+
}
|
|
310
|
+
if (entry.profiles !== undefined) {
|
|
311
|
+
validateProfileList(report, entry.profiles, `skills.json entry "${skillId}" profiles`, supportedProfiles);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return skillIds;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function collectSkillSourceEntries(skillsRegistry) {
|
|
319
|
+
const entries = [];
|
|
320
|
+
for (const [skillId, entry] of Object.entries(skillsRegistry.skills || {})) {
|
|
321
|
+
if (entry && typeof entry.source === 'string' && entry.source.trim()) {
|
|
322
|
+
entries.push({
|
|
323
|
+
skillId,
|
|
324
|
+
profile: null,
|
|
325
|
+
relPath: entry.source,
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
if (entry && entry.sourceByProfile && typeof entry.sourceByProfile === 'object') {
|
|
329
|
+
for (const [profile, relPath] of Object.entries(entry.sourceByProfile)) {
|
|
330
|
+
if (typeof relPath === 'string' && relPath.trim()) {
|
|
331
|
+
entries.push({
|
|
332
|
+
skillId,
|
|
333
|
+
profile,
|
|
334
|
+
relPath,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return entries;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function validateSkillSourceSpecs(sourceDir, skillsRegistry, report) {
|
|
344
|
+
const skillSourceEntries = collectSkillSourceEntries(skillsRegistry);
|
|
345
|
+
const stats = {
|
|
346
|
+
checked: 0,
|
|
347
|
+
error_count: 0,
|
|
348
|
+
warning_count: 0,
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
for (const entry of skillSourceEntries) {
|
|
352
|
+
const absPath = path.join(sourceDir, entry.relPath);
|
|
353
|
+
const label = entry.profile
|
|
354
|
+
? `skills.json entry "${entry.skillId}" (${entry.profile})`
|
|
355
|
+
: `skills.json entry "${entry.skillId}"`;
|
|
356
|
+
|
|
357
|
+
if (!fs.existsSync(absPath)) {
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const skillReport = validateSkillSpec(absPath);
|
|
362
|
+
stats.checked += 1;
|
|
363
|
+
stats.error_count += skillReport.errors.length;
|
|
364
|
+
stats.warning_count += skillReport.warnings.length;
|
|
365
|
+
report.checked_files.push(entry.relPath);
|
|
366
|
+
|
|
367
|
+
for (const error of skillReport.errors) {
|
|
368
|
+
report.errors.push(`${label} skill-spec: ${error}`);
|
|
369
|
+
}
|
|
370
|
+
for (const warning of skillReport.warnings) {
|
|
371
|
+
report.warnings.push(`${label} skill-spec: ${warning}`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return stats;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function validateRolesRegistry(sourceDir, rolesRegistry, report, supportedProfiles) {
|
|
379
|
+
if (typeof rolesRegistry.version !== 'number') {
|
|
380
|
+
report.errors.push('roles.json version must be a number');
|
|
381
|
+
}
|
|
382
|
+
if (rolesRegistry.support_files !== undefined) {
|
|
383
|
+
const supportFiles = assertArrayOfStrings(report, rolesRegistry.support_files, 'roles.json support_files');
|
|
384
|
+
for (const relPath of supportFiles) {
|
|
385
|
+
if (!fileExists(sourceDir, relPath)) {
|
|
386
|
+
report.errors.push(`roles.json support file is missing: ${relPath}`);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (!rolesRegistry.roles || typeof rolesRegistry.roles !== 'object') {
|
|
391
|
+
report.errors.push('roles.json is missing "roles" object');
|
|
392
|
+
return new Set();
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const roleIds = new Set();
|
|
396
|
+
for (const [roleId, entry] of Object.entries(rolesRegistry.roles)) {
|
|
397
|
+
roleIds.add(roleId);
|
|
398
|
+
if (!entry || typeof entry !== 'object') {
|
|
399
|
+
report.errors.push(`roles.json entry "${roleId}" must be an object`);
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
if (typeof entry.source !== 'string' || !entry.source.trim()) {
|
|
403
|
+
report.errors.push(`roles.json entry "${roleId}" must define source`);
|
|
404
|
+
} else if (!fileExists(sourceDir, entry.source)) {
|
|
405
|
+
report.errors.push(`roles.json entry "${roleId}" references missing source: ${entry.source}`);
|
|
406
|
+
}
|
|
407
|
+
if (entry.domains !== undefined) {
|
|
408
|
+
assertArrayOfStrings(report, entry.domains, `roles.json entry "${roleId}" domains`);
|
|
409
|
+
}
|
|
410
|
+
if (entry.profiles !== undefined) {
|
|
411
|
+
validateProfileList(report, entry.profiles, `roles.json entry "${roleId}" profiles`, supportedProfiles);
|
|
412
|
+
}
|
|
413
|
+
if (entry.openspec_actions !== undefined) {
|
|
414
|
+
assertArrayOfStrings(report, entry.openspec_actions, `roles.json entry "${roleId}" openspec_actions`);
|
|
415
|
+
}
|
|
416
|
+
if (entry.rule_ids !== undefined) {
|
|
417
|
+
assertArrayOfStrings(report, entry.rule_ids, `roles.json entry "${roleId}" rule_ids`);
|
|
418
|
+
}
|
|
419
|
+
if (entry.skill_priority !== undefined) {
|
|
420
|
+
assertArrayOfStrings(report, entry.skill_priority, `roles.json entry "${roleId}" skill_priority`);
|
|
421
|
+
}
|
|
422
|
+
if (entry.micro_skill_allowlist !== undefined) {
|
|
423
|
+
assertArrayOfStrings(report, entry.micro_skill_allowlist, `roles.json entry "${roleId}" micro_skill_allowlist`);
|
|
424
|
+
}
|
|
425
|
+
if (entry.rule_contract_profiles !== undefined) {
|
|
426
|
+
validateRuleContractProfiles(report, entry.rule_contract_profiles, `roles.json entry "${roleId}" rule_contract_profiles`, supportedProfiles);
|
|
427
|
+
}
|
|
428
|
+
if (entry.openspec_rule_sections !== undefined) {
|
|
429
|
+
assertArrayOfStrings(report, entry.openspec_rule_sections, `roles.json entry "${roleId}" openspec_rule_sections`);
|
|
430
|
+
}
|
|
431
|
+
if (entry.required_inputs !== undefined) {
|
|
432
|
+
assertArrayOfStrings(report, entry.required_inputs, `roles.json entry "${roleId}" required_inputs`);
|
|
433
|
+
}
|
|
434
|
+
if (entry.required_outputs !== undefined) {
|
|
435
|
+
assertArrayOfStrings(report, entry.required_outputs, `roles.json entry "${roleId}" required_outputs`);
|
|
436
|
+
}
|
|
437
|
+
if (entry.approval_gates !== undefined) {
|
|
438
|
+
assertArrayOfStrings(report, entry.approval_gates, `roles.json entry "${roleId}" approval_gates`);
|
|
439
|
+
}
|
|
440
|
+
if (entry.runtime_transition !== undefined) {
|
|
441
|
+
validateRuntimeTransition(report, entry.runtime_transition, `roles.json entry "${roleId}" runtime_transition`);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
return roleIds;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function validateFlowsRegistry(sourceDir, flowsRegistry, report, supportedProfiles) {
|
|
449
|
+
if (typeof flowsRegistry.version !== 'number') {
|
|
450
|
+
report.errors.push('flows.json version must be a number');
|
|
451
|
+
}
|
|
452
|
+
if (flowsRegistry.support_files !== undefined) {
|
|
453
|
+
const supportFiles = assertArrayOfStrings(report, flowsRegistry.support_files, 'flows.json support_files');
|
|
454
|
+
for (const relPath of supportFiles) {
|
|
455
|
+
if (!fileExists(sourceDir, relPath)) {
|
|
456
|
+
report.errors.push(`flows.json support file is missing: ${relPath}`);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
if (!flowsRegistry.flows || typeof flowsRegistry.flows !== 'object') {
|
|
461
|
+
report.errors.push('flows.json is missing "flows" object');
|
|
462
|
+
return new Set();
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const flowIds = new Set();
|
|
466
|
+
for (const [flowId, entry] of Object.entries(flowsRegistry.flows)) {
|
|
467
|
+
flowIds.add(flowId);
|
|
468
|
+
if (!entry || typeof entry !== 'object') {
|
|
469
|
+
report.errors.push(`flows.json entry "${flowId}" must be an object`);
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
if (typeof entry.source !== 'string' || !entry.source.trim()) {
|
|
473
|
+
report.errors.push(`flows.json entry "${flowId}" must define source`);
|
|
474
|
+
} else if (!fileExists(sourceDir, entry.source)) {
|
|
475
|
+
report.errors.push(`flows.json entry "${flowId}" references missing source: ${entry.source}`);
|
|
476
|
+
}
|
|
477
|
+
if (entry.default_schema !== undefined) {
|
|
478
|
+
assertOptionalString(report, entry.default_schema, `flows.json entry "${flowId}" default_schema`);
|
|
479
|
+
}
|
|
480
|
+
if (entry.profiles !== undefined) {
|
|
481
|
+
validateProfileList(report, entry.profiles, `flows.json entry "${flowId}" profiles`, supportedProfiles);
|
|
482
|
+
}
|
|
483
|
+
if (entry.artifact_profile !== undefined) {
|
|
484
|
+
assertOptionalString(report, entry.artifact_profile, `flows.json entry "${flowId}" artifact_profile`);
|
|
485
|
+
}
|
|
486
|
+
if (entry.required_roles !== undefined) {
|
|
487
|
+
assertArrayOfStrings(report, entry.required_roles, `flows.json entry "${flowId}" required_roles`);
|
|
488
|
+
}
|
|
489
|
+
if (entry.first_handoff !== undefined) {
|
|
490
|
+
assertOptionalString(report, entry.first_handoff, `flows.json entry "${flowId}" first_handoff`);
|
|
491
|
+
}
|
|
492
|
+
if (entry.approval_gates !== undefined) {
|
|
493
|
+
assertArrayOfStrings(report, entry.approval_gates, `flows.json entry "${flowId}" approval_gates`);
|
|
494
|
+
}
|
|
495
|
+
if (entry.core_artifacts !== undefined) {
|
|
496
|
+
assertArrayOfStrings(report, entry.core_artifacts, `flows.json entry "${flowId}" core_artifacts`);
|
|
497
|
+
}
|
|
498
|
+
if (entry.required_artifacts !== undefined) {
|
|
499
|
+
assertArrayOfStrings(report, entry.required_artifacts, `flows.json entry "${flowId}" required_artifacts`);
|
|
500
|
+
}
|
|
501
|
+
if (entry.handoff_policy !== undefined) {
|
|
502
|
+
assertOptionalString(report, entry.handoff_policy, `flows.json entry "${flowId}" handoff_policy`);
|
|
503
|
+
}
|
|
504
|
+
if (entry.completion_policy !== undefined) {
|
|
505
|
+
assertOptionalString(report, entry.completion_policy, `flows.json entry "${flowId}" completion_policy`);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
return flowIds;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function validateRoleAndFlowReferences(rolesRegistry, flowsRegistry, report, ids) {
|
|
513
|
+
for (const [roleId, entry] of Object.entries(rolesRegistry.roles || {})) {
|
|
514
|
+
for (const ruleId of normalizeList(entry.rule_ids)) {
|
|
515
|
+
if (!ids.rules.has(ruleId)) {
|
|
516
|
+
report.errors.push(`roles.json entry "${roleId}" references unknown rule: ${ruleId}`);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
for (const skillId of normalizeList(entry.skill_priority)) {
|
|
520
|
+
if (!ids.skills.has(skillId)) {
|
|
521
|
+
report.errors.push(`roles.json entry "${roleId}" skill_priority references unknown skill: ${skillId}`);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
for (const skillId of normalizeList(entry.micro_skill_allowlist)) {
|
|
525
|
+
if (!ids.skills.has(skillId)) {
|
|
526
|
+
report.errors.push(`roles.json entry "${roleId}" micro_skill_allowlist references unknown skill: ${skillId}`);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
for (const skillId of normalizeList(entry.preferred_skills)) {
|
|
530
|
+
if (!ids.skills.has(skillId)) {
|
|
531
|
+
report.errors.push(`roles.json entry "${roleId}" preferred_skills references unknown skill: ${skillId}`);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
for (const handoffRole of normalizeList(entry.handoff_to)) {
|
|
535
|
+
if (!ids.roles.has(handoffRole)) {
|
|
536
|
+
report.errors.push(`roles.json entry "${roleId}" handoff_to references unknown role: ${handoffRole}`);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
for (const [flowId, entry] of Object.entries(flowsRegistry.flows || {})) {
|
|
542
|
+
for (const roleId of normalizeList(entry.required_roles)) {
|
|
543
|
+
if (!ids.roles.has(roleId)) {
|
|
544
|
+
report.errors.push(`flows.json entry "${flowId}" references unknown role in required_roles: ${roleId}`);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (entry.first_handoff && !ids.roles.has(entry.first_handoff)) {
|
|
548
|
+
report.errors.push(`flows.json entry "${flowId}" references unknown first_handoff role: ${entry.first_handoff}`);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
function validateScenarioPackagesRegistry(scenariosRegistry, report, ids, supportedProfiles) {
|
|
554
|
+
if (!scenariosRegistry) {
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
if (typeof scenariosRegistry.version !== 'number') {
|
|
558
|
+
report.errors.push('scenario-packages.json version must be a number');
|
|
559
|
+
}
|
|
560
|
+
if (!scenariosRegistry.scenario_packages || typeof scenariosRegistry.scenario_packages !== 'object') {
|
|
561
|
+
report.errors.push('scenario-packages.json is missing "scenario_packages" object');
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
for (const [scenarioId, entry] of Object.entries(scenariosRegistry.scenario_packages)) {
|
|
566
|
+
if (!entry || typeof entry !== 'object') {
|
|
567
|
+
report.errors.push(`scenario-packages.json entry "${scenarioId}" must be an object`);
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const roles = assertArrayOfStrings(report, entry.roles || [], `scenario-packages.json entry "${scenarioId}" roles`);
|
|
572
|
+
const skills = assertArrayOfStrings(report, entry.skills || [], `scenario-packages.json entry "${scenarioId}" skills`);
|
|
573
|
+
const rules = assertArrayOfStrings(report, entry.rules || [], `scenario-packages.json entry "${scenarioId}" rules`);
|
|
574
|
+
if (entry.domains !== undefined) {
|
|
575
|
+
assertArrayOfStrings(report, entry.domains, `scenario-packages.json entry "${scenarioId}" domains`);
|
|
576
|
+
}
|
|
577
|
+
if (entry.profiles !== undefined) {
|
|
578
|
+
validateProfileList(report, entry.profiles, `scenario-packages.json entry "${scenarioId}" profiles`, supportedProfiles);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
for (const roleId of roles) {
|
|
582
|
+
if (!ids.roles.has(roleId)) {
|
|
583
|
+
report.errors.push(`scenario-packages.json entry "${scenarioId}" references unknown role: ${roleId}`);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
for (const skillId of skills) {
|
|
587
|
+
if (!ids.skills.has(skillId)) {
|
|
588
|
+
report.errors.push(`scenario-packages.json entry "${scenarioId}" references unknown skill: ${skillId}`);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
for (const ruleId of rules) {
|
|
592
|
+
if (!ids.rules.has(ruleId)) {
|
|
593
|
+
report.errors.push(`scenario-packages.json entry "${scenarioId}" references unknown rule: ${ruleId}`);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
function validateRegistry(sourceDir) {
|
|
600
|
+
const report = {
|
|
601
|
+
schema_version: 1,
|
|
602
|
+
kind: 'registry-validation-result',
|
|
603
|
+
status: 'success',
|
|
604
|
+
source: sourceDir,
|
|
605
|
+
checked_files: [],
|
|
606
|
+
warnings: [],
|
|
607
|
+
errors: [],
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
const registryDir = path.join(sourceDir, '.agents/registry');
|
|
611
|
+
if (!fs.existsSync(registryDir)) {
|
|
612
|
+
report.errors.push(`Registry directory not found: ${registryDir}`);
|
|
613
|
+
report.status = 'failed';
|
|
614
|
+
return report;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
const rulesPath = path.join(registryDir, 'rules.json');
|
|
618
|
+
const skillsPath = path.join(registryDir, 'skills.json');
|
|
619
|
+
const rolesPath = path.join(registryDir, 'roles.json');
|
|
620
|
+
const flowsPath = path.join(registryDir, 'flows.json');
|
|
621
|
+
const scenariosPath = path.join(registryDir, 'scenario-packages.json');
|
|
622
|
+
|
|
623
|
+
const profilesRegistry = readProfilesRegistry(sourceDir);
|
|
624
|
+
const rulesRegistry = readJsonFile(rulesPath, 'rules.json');
|
|
625
|
+
const skillsRegistry = readJsonFile(skillsPath, 'skills.json');
|
|
626
|
+
const rolesRegistry = readJsonFile(rolesPath, 'roles.json');
|
|
627
|
+
const flowsRegistry = readJsonFile(flowsPath, 'flows.json');
|
|
628
|
+
const scenariosRegistry = readOptionalJsonFile(scenariosPath, 'scenario-packages.json');
|
|
629
|
+
|
|
630
|
+
report.checked_files.push(
|
|
631
|
+
'.agents/registry/profiles.json',
|
|
632
|
+
'.agents/registry/rules.json',
|
|
633
|
+
'.agents/registry/skills.json',
|
|
634
|
+
'.agents/registry/roles.json',
|
|
635
|
+
'.agents/registry/flows.json'
|
|
636
|
+
);
|
|
637
|
+
if (scenariosRegistry) {
|
|
638
|
+
report.checked_files.push('.agents/registry/scenario-packages.json');
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
const profileIds = validateProfilesRegistry(sourceDir, profilesRegistry, report);
|
|
642
|
+
const supportedProfiles = buildSupportedProfileSet(profilesRegistry);
|
|
643
|
+
const ruleIds = validateRulesRegistry(sourceDir, rulesRegistry, report, supportedProfiles);
|
|
644
|
+
const skillIds = validateSkillsRegistry(sourceDir, skillsRegistry, report, supportedProfiles);
|
|
645
|
+
const roleIds = validateRolesRegistry(sourceDir, rolesRegistry, report, supportedProfiles);
|
|
646
|
+
const flowIds = validateFlowsRegistry(sourceDir, flowsRegistry, report, supportedProfiles);
|
|
647
|
+
const skillSpecStats = validateSkillSourceSpecs(sourceDir, skillsRegistry, report);
|
|
648
|
+
const ids = {
|
|
649
|
+
profiles: profileIds,
|
|
650
|
+
roles: roleIds,
|
|
651
|
+
skills: skillIds,
|
|
652
|
+
rules: ruleIds,
|
|
653
|
+
flows: flowIds,
|
|
654
|
+
};
|
|
655
|
+
validateRoleAndFlowReferences(rolesRegistry, flowsRegistry, report, ids);
|
|
656
|
+
validateScenarioPackagesRegistry(scenariosRegistry, report, ids, supportedProfiles);
|
|
657
|
+
|
|
658
|
+
if (report.errors.length > 0) {
|
|
659
|
+
report.status = 'failed';
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
report.summary = {
|
|
663
|
+
profile_count: profileIds.size,
|
|
664
|
+
rule_count: ruleIds.size,
|
|
665
|
+
skill_count: skillIds.size,
|
|
666
|
+
role_count: roleIds.size,
|
|
667
|
+
flow_count: flowIds.size,
|
|
668
|
+
scenario_package_count: scenariosRegistry ? Object.keys(scenariosRegistry.scenario_packages || {}).length : 0,
|
|
669
|
+
};
|
|
670
|
+
report.stats = {
|
|
671
|
+
...report.summary,
|
|
672
|
+
checked_file_count: report.checked_files.length,
|
|
673
|
+
warning_count: report.warnings.length,
|
|
674
|
+
error_count: report.errors.length,
|
|
675
|
+
skill_spec: skillSpecStats,
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
return report;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
function printPretty(report) {
|
|
682
|
+
console.log(`registry-validation(注册表校验): ${report.status}`);
|
|
683
|
+
console.log(`source(源码目录): ${report.source}`);
|
|
684
|
+
if (report.summary) {
|
|
685
|
+
console.log(`profiles(技术栈): ${report.summary.profile_count}`);
|
|
686
|
+
console.log(`rules(规则): ${report.summary.rule_count}`);
|
|
687
|
+
console.log(`skills(技能): ${report.summary.skill_count}`);
|
|
688
|
+
console.log(`roles(专家角色): ${report.summary.role_count}`);
|
|
689
|
+
console.log(`flows(流程模板): ${report.summary.flow_count}`);
|
|
690
|
+
console.log(`scenario_packages(场景方案包): ${report.summary.scenario_package_count}`);
|
|
691
|
+
if (report.stats && report.stats.skill_spec) {
|
|
692
|
+
console.log(`skill_spec_sources(技能源码校验): ${report.stats.skill_spec.checked}`);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
if (report.warnings.length > 0) {
|
|
696
|
+
console.log('warnings(警告):');
|
|
697
|
+
for (const warning of report.warnings) {
|
|
698
|
+
console.log(`- ${warning}`);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
if (report.errors.length > 0) {
|
|
702
|
+
console.log('errors(错误):');
|
|
703
|
+
for (const error of report.errors) {
|
|
704
|
+
console.log(`- ${error}`);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
function main(argv) {
|
|
710
|
+
try {
|
|
711
|
+
const options = parseArgs(argv);
|
|
712
|
+
if (options.help) {
|
|
713
|
+
printUsage();
|
|
714
|
+
return 0;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
const sourceDir = getSourceDir(options.source);
|
|
718
|
+
const report = validateRegistry(sourceDir);
|
|
719
|
+
|
|
720
|
+
if (options.json) {
|
|
721
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
722
|
+
} else {
|
|
723
|
+
printPretty(report);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
return report.status === 'success' ? 0 : 1;
|
|
727
|
+
} catch (error) {
|
|
728
|
+
console.error(`validate-registry(校验注册表) failed: ${error.message}`);
|
|
729
|
+
return 1;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
module.exports = {
|
|
734
|
+
validateRegistry,
|
|
735
|
+
main,
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
if (require.main === module) {
|
|
739
|
+
process.exit(main(process.argv.slice(2)));
|
|
740
|
+
}
|