@bovinphang/frontend-craft 2.7.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +378 -305
- package/CHANGELOG.zh-CN.md +377 -304
- package/CONTRIBUTING.md +371 -361
- package/CONTRIBUTING.zh-CN.md +371 -361
- package/README.md +545 -493
- package/README.openclaw.md +359 -264
- package/README.openclaw.zh-CN.md +359 -264
- package/README.zh-CN.md +545 -493
- package/agents/fec-architect.md +70 -70
- package/agents/fec-code-reviewer.md +103 -82
- package/agents/fec-debugger.md +20 -20
- package/agents/fec-design-token-mapper.md +36 -36
- package/agents/fec-doc-updater.md +13 -13
- package/agents/fec-e2e-runner.md +45 -45
- package/agents/fec-figma-implementer.md +59 -59
- package/agents/fec-performance-optimizer.md +128 -128
- package/agents/fec-refactor-cleaner.md +17 -14
- package/agents/fec-refactoring-expert.md +81 -0
- package/agents/fec-security-reviewer.md +82 -67
- package/agents/fec-test-planner.md +27 -27
- package/agents/fec-typescript-reviewer.md +103 -87
- package/agents/fec-ui-checker.md +64 -64
- package/commands/fec-debug.md +19 -19
- package/commands/fec-doc-sync.md +11 -11
- package/commands/fec-init.md +37 -38
- package/commands/fec-plan.md +58 -58
- package/commands/fec-refactor-clean.md +11 -11
- package/commands/fec-refactor-plan.md +17 -0
- package/commands/fec-refactor.md +18 -0
- package/commands/fec-review.md +71 -41
- package/commands/fec-scaffold.md +41 -41
- package/commands/fec-smell.md +17 -0
- package/commands/fec-tdd.md +17 -13
- package/dist/bin/frontend-craft.js +190 -36
- package/dist/hooks/fec-run-tests.js +5 -1
- package/dist/hooks/fec-session-start.js +1 -1
- package/docs/example-prompts.md +157 -137
- package/docs/ja-JP/README.md +534 -493
- package/docs/ko-KR/README.md +534 -493
- package/docs/project-structure.md +151 -123
- package/docs/refactoring/README.md +50 -0
- package/docs/refactoring/catalog.md +105 -0
- package/docs/refactoring/smell-refactoring-matrix.md +41 -0
- package/docs/review-and-diagram-workflows.md +39 -0
- package/docs/runtimes/antigravity.md +18 -10
- package/docs/runtimes/augment.md +18 -10
- package/docs/runtimes/claude.md +191 -177
- package/docs/runtimes/claude.zh-CN.md +189 -175
- package/docs/runtimes/cline.md +18 -10
- package/docs/runtimes/codebuddy.md +18 -10
- package/docs/runtimes/codex.md +18 -10
- package/docs/runtimes/compatibility.md +27 -0
- package/docs/runtimes/copilot.md +18 -10
- package/docs/runtimes/cursor.md +18 -10
- package/docs/runtimes/gemini.md +18 -10
- package/docs/runtimes/kilo.md +18 -10
- package/docs/runtimes/openclaw.md +18 -10
- package/docs/runtimes/opencode.md +18 -10
- package/docs/runtimes/qoder.md +18 -19
- package/docs/runtimes/trae.md +18 -10
- package/docs/runtimes/windsurf.md +18 -10
- package/docs/superpowers/plans/2026-09-26-content-integrity.md +145 -0
- package/docs/superpowers/plans/2026-09-26-diagram-quality.md +170 -0
- package/docs/superpowers/specs/2026-09-26-diagram-quality-design.md +77 -0
- package/docs/superpowers/specs/2026-09-26-project-optimization-design.md +95 -0
- package/docs/zh-CN/example-prompts.md +157 -137
- package/docs/zh-CN/project-structure.md +148 -123
- package/docs/zh-CN/review-and-diagram-workflows.md +39 -0
- package/docs/zh-TW/README.md +534 -493
- package/localized/zh-CN/agents/fec-architect.md +125 -0
- package/localized/zh-CN/agents/fec-code-reviewer.md +171 -0
- package/localized/zh-CN/agents/fec-debugger.md +44 -0
- package/localized/zh-CN/agents/fec-design-token-mapper.md +75 -0
- package/localized/zh-CN/agents/fec-doc-updater.md +30 -0
- package/localized/zh-CN/agents/fec-e2e-runner.md +107 -0
- package/localized/zh-CN/agents/fec-figma-implementer.md +104 -0
- package/localized/zh-CN/agents/fec-performance-optimizer.md +293 -0
- package/localized/zh-CN/agents/fec-refactor-cleaner.md +35 -0
- package/localized/zh-CN/agents/fec-refactoring-expert.md +53 -0
- package/localized/zh-CN/agents/fec-security-reviewer.md +132 -0
- package/localized/zh-CN/agents/fec-test-planner.md +50 -0
- package/localized/zh-CN/agents/fec-typescript-reviewer.md +158 -0
- package/localized/zh-CN/agents/fec-ui-checker.md +120 -0
- package/localized/zh-CN/commands/fec-debug.md +30 -0
- package/localized/zh-CN/commands/fec-doc-sync.md +19 -0
- package/localized/zh-CN/commands/fec-init.md +70 -0
- package/localized/zh-CN/commands/fec-plan.md +94 -0
- package/localized/zh-CN/commands/fec-refactor-clean.md +19 -0
- package/localized/zh-CN/commands/fec-refactor-plan.md +15 -0
- package/localized/zh-CN/commands/fec-refactor.md +14 -0
- package/localized/zh-CN/commands/fec-review.md +97 -0
- package/localized/zh-CN/commands/fec-scaffold.md +205 -0
- package/localized/zh-CN/commands/fec-smell.md +13 -0
- package/localized/zh-CN/commands/fec-tdd.md +25 -0
- package/localized/zh-CN/skills/TEMPLATE.md +155 -0
- package/localized/zh-CN/skills/eval_queries.json +1257 -0
- package/localized/zh-CN/skills/fec-accessibility-check/SKILL.md +39 -0
- package/localized/zh-CN/skills/fec-accessibility-check/references/report-template.md +23 -0
- package/localized/zh-CN/skills/fec-accessibility-check/references/screen-reader-testing.md +33 -0
- package/localized/zh-CN/skills/fec-alchemy/SKILL.md +74 -0
- package/localized/zh-CN/skills/fec-alchemy/assets/absorption-plan-template.md +47 -0
- package/localized/zh-CN/skills/fec-alchemy/assets/intake-template.md +55 -0
- package/localized/zh-CN/skills/fec-alchemy/assets/review-checklist.md +31 -0
- package/localized/zh-CN/skills/fec-alchemy/references/methodology.md +94 -0
- package/localized/zh-CN/skills/fec-alchemy/references/originality-and-licensing.md +57 -0
- package/localized/zh-CN/skills/fec-api-integration/SKILL.md +78 -0
- package/localized/zh-CN/skills/fec-api-integration/references/integration-patterns.md +80 -0
- package/localized/zh-CN/skills/fec-backend-requirements-handoff/SKILL.md +45 -0
- package/localized/zh-CN/skills/fec-browser-storage/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-browser-storage/references/storage-patterns.md +65 -0
- package/localized/zh-CN/skills/fec-canvas-threejs/SKILL.md +66 -0
- package/localized/zh-CN/skills/fec-canvas-threejs/references/rendering-patterns.md +67 -0
- package/localized/zh-CN/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +67 -0
- package/localized/zh-CN/skills/fec-code-review/SKILL.md +162 -0
- package/localized/zh-CN/skills/fec-code-review/references/report-template.md +39 -0
- package/localized/zh-CN/skills/fec-code-smells/SKILL.md +33 -0
- package/localized/zh-CN/skills/fec-code-smells/references/detection-guide.md +25 -0
- package/localized/zh-CN/skills/fec-code-smells/references/smell-catalog.md +817 -0
- package/localized/zh-CN/skills/fec-code-smells/references/smell-to-refactoring-map.md +265 -0
- package/localized/zh-CN/skills/fec-component-testing/SKILL.md +119 -0
- package/localized/zh-CN/skills/fec-data-fetching/SKILL.md +62 -0
- package/localized/zh-CN/skills/fec-data-fetching/references/query-patterns.md +103 -0
- package/localized/zh-CN/skills/fec-debug-framework/SKILL.md +157 -0
- package/localized/zh-CN/skills/fec-debug-framework/references/report-template.md +58 -0
- package/localized/zh-CN/skills/fec-dependency-upgrade/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +56 -0
- package/localized/zh-CN/skills/fec-doc-sync/SKILL.md +39 -0
- package/localized/zh-CN/skills/fec-drawio-studio/SKILL.md +73 -0
- package/localized/zh-CN/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +10 -0
- package/localized/zh-CN/skills/fec-drawio-studio/data/brand-icons.json +878 -0
- package/localized/zh-CN/skills/fec-drawio-studio/data/shape-index.json +83570 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/data-residency.md +27 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/diagram-patterns.md +60 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/layout-and-export.md +72 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/troubleshooting.md +29 -0
- package/localized/zh-CN/skills/fec-drawio-studio/references/xml-and-mermaid.md +58 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/brand-symbols.mjs +99 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-lint.mjs +205 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/diagram-url.mjs +102 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/layout-graph.mjs +107 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/png-embed-fix.mjs +26 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-go-packages.mjs +36 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-js-modules.mjs +52 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-classes.mjs +30 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-python-modules.mjs +55 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-rust-modules.mjs +35 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/scan-ts-modules.mjs +7 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/shape-query.mjs +121 -0
- package/localized/zh-CN/skills/fec-drawio-studio/scripts/studio-core.mjs +139 -0
- package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/corporate.json +49 -0
- package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/default.json +49 -0
- package/localized/zh-CN/skills/fec-drawio-studio/styles/built-in/handdrawn.json +49 -0
- package/localized/zh-CN/skills/fec-drawio-studio/styles/schema.json +112 -0
- package/localized/zh-CN/skills/fec-e2e-testing/SKILL.md +42 -0
- package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-ci-reporting.md +62 -0
- package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-special-scenarios.md +52 -0
- package/localized/zh-CN/skills/fec-e2e-testing/references/e2e-visual-regression.md +60 -0
- package/localized/zh-CN/skills/fec-e2e-testing/references/playwright-patterns.md +95 -0
- package/localized/zh-CN/skills/fec-form-handling/SKILL.md +76 -0
- package/localized/zh-CN/skills/fec-form-handling/references/advanced-form-patterns.md +101 -0
- package/localized/zh-CN/skills/fec-image-generation/SKILL.md +110 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/README.md +14 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/architecture.json +121 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/invalid-explicit.json +41 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/sequence.json +53 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/sequence.mmd +21 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/workflow.json +98 -0
- package/localized/zh-CN/skills/fec-image-generation/assets/quality-examples/workflow.mmd +7 -0
- package/localized/zh-CN/skills/fec-image-generation/references/artifact-routing.md +80 -0
- package/localized/zh-CN/skills/fec-image-generation/references/diagram-workflows.md +81 -0
- package/localized/zh-CN/skills/fec-image-generation/references/html-technical-diagrams.md +243 -0
- package/localized/zh-CN/skills/fec-image-generation/references/png-qa-autofix.md +37 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/diagram-browser.mjs +90 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/diagram-layout.mjs +176 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/export-diagram.mjs +332 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/mermaid-render.mjs +64 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/png-qa.mjs +462 -0
- package/localized/zh-CN/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1537 -0
- package/localized/zh-CN/skills/fec-implement-from-design/SKILL.md +129 -0
- package/localized/zh-CN/skills/fec-implement-from-design/references/design-plan-template.md +36 -0
- package/localized/zh-CN/skills/fec-legacy-to-modern-migration/SKILL.md +46 -0
- package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +110 -0
- package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +41 -0
- package/localized/zh-CN/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +48 -0
- package/localized/zh-CN/skills/fec-legacy-web-standard/SKILL.md +35 -0
- package/localized/zh-CN/skills/fec-legacy-web-standard/references/legacy-patterns.md +85 -0
- package/localized/zh-CN/skills/fec-list-virtualization/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-list-virtualization/references/virtualization-patterns.md +80 -0
- package/localized/zh-CN/skills/fec-monorepo-project-standard/SKILL.md +142 -0
- package/localized/zh-CN/skills/fec-motion-interaction/SKILL.md +73 -0
- package/localized/zh-CN/skills/fec-motion-interaction/references/motion-patterns.md +112 -0
- package/localized/zh-CN/skills/fec-nextjs-project-standard/SKILL.md +123 -0
- package/localized/zh-CN/skills/fec-nuxt-project-standard/SKILL.md +122 -0
- package/localized/zh-CN/skills/fec-performance-optimization/SKILL.md +80 -0
- package/localized/zh-CN/skills/fec-performance-optimization/references/framework-performance-patterns.md +38 -0
- package/localized/zh-CN/skills/fec-performance-optimization/references/report-template.md +59 -0
- package/localized/zh-CN/skills/fec-pwa-implementation/SKILL.md +35 -0
- package/localized/zh-CN/skills/fec-pwa-implementation/references/manifest-and-icons.md +53 -0
- package/localized/zh-CN/skills/fec-pwa-implementation/references/service-worker-workbox.md +68 -0
- package/localized/zh-CN/skills/fec-react-project-standard/SKILL.md +91 -0
- package/localized/zh-CN/skills/fec-react-project-standard/references/react-performance-patterns.md +35 -0
- package/localized/zh-CN/skills/fec-react-project-standard/references/react-project-structure.md +197 -0
- package/localized/zh-CN/skills/fec-react-project-standard/references/react-quality-patterns.md +131 -0
- package/localized/zh-CN/skills/fec-react-project-standard/references/react-runtime-patterns.md +293 -0
- package/localized/zh-CN/skills/fec-refactor-clean/SKILL.md +54 -0
- package/localized/zh-CN/skills/fec-refactor-clean/references/report-template.md +42 -0
- package/localized/zh-CN/skills/fec-refactoring/SKILL.md +83 -0
- package/localized/zh-CN/skills/fec-refactoring/references/principles.md +43 -0
- package/localized/zh-CN/skills/fec-refactoring/references/refactoring-vs-feature-change.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring/references/when-to-refactor.md +17 -0
- package/localized/zh-CN/skills/fec-refactoring/references/workflow.md +59 -0
- package/localized/zh-CN/skills/fec-refactoring-api/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-api/references/api-refactorings.md +496 -0
- package/localized/zh-CN/skills/fec-refactoring-catalog/SKILL.md +21 -0
- package/localized/zh-CN/skills/fec-refactoring-catalog/references/catalog-index.md +99 -0
- package/localized/zh-CN/skills/fec-refactoring-catalog/references/composition-guide.md +49 -0
- package/localized/zh-CN/skills/fec-refactoring-catalog/references/selection-guide.md +41 -0
- package/localized/zh-CN/skills/fec-refactoring-control/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-control/references/conditional-refactorings.md +299 -0
- package/localized/zh-CN/skills/fec-refactoring-data/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-data/references/data-refactorings.md +248 -0
- package/localized/zh-CN/skills/fec-refactoring-encapsulation/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-encapsulation/references/encapsulation-refactorings.md +452 -0
- package/localized/zh-CN/skills/fec-refactoring-functions/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-functions/references/function-refactorings.md +567 -0
- package/localized/zh-CN/skills/fec-refactoring-inheritance/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-inheritance/references/inheritance-refactorings.md +550 -0
- package/localized/zh-CN/skills/fec-refactoring-move-features/SKILL.md +25 -0
- package/localized/zh-CN/skills/fec-refactoring-move-features/references/moving-refactorings.md +453 -0
- package/localized/zh-CN/skills/fec-refactoring-validation/SKILL.md +52 -0
- package/localized/zh-CN/skills/fec-refactoring-validation/references/behavior-preservation.md +15 -0
- package/localized/zh-CN/skills/fec-refactoring-validation/references/refactoring-test-checklist.md +25 -0
- package/localized/zh-CN/skills/fec-responsive-layout/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-responsive-layout/references/responsive-layout-patterns.md +70 -0
- package/localized/zh-CN/skills/fec-route-protection/SKILL.md +135 -0
- package/localized/zh-CN/skills/fec-security-review/SKILL.md +54 -0
- package/localized/zh-CN/skills/fec-security-review/references/report-template.md +37 -0
- package/localized/zh-CN/skills/fec-security-review/references/security-checklist.md +64 -0
- package/localized/zh-CN/skills/fec-source-driven-development/SKILL.md +87 -0
- package/localized/zh-CN/skills/fec-state-management/SKILL.md +140 -0
- package/localized/zh-CN/skills/fec-state-management/references/state-patterns.md +109 -0
- package/localized/zh-CN/skills/fec-storybook-component-doc/SKILL.md +37 -0
- package/localized/zh-CN/skills/fec-storybook-component-doc/references/story-patterns.md +118 -0
- package/localized/zh-CN/skills/fec-svg-animation/SKILL.md +148 -0
- package/localized/zh-CN/skills/fec-tailwind-design-system/SKILL.md +34 -0
- package/localized/zh-CN/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +59 -0
- package/localized/zh-CN/skills/fec-tdd-workflow/SKILL.md +55 -0
- package/localized/zh-CN/skills/fec-testing-strategy/SKILL.md +45 -0
- package/localized/zh-CN/skills/fec-typescript-project-standard/SKILL.md +54 -0
- package/localized/zh-CN/skills/fec-typescript-project-standard/references/type-safety-patterns.md +102 -0
- package/localized/zh-CN/skills/fec-typescript-project-standard/references/type-safety.md +148 -0
- package/localized/zh-CN/skills/fec-ui-design/SKILL.md +108 -0
- package/localized/zh-CN/skills/fec-ui-design/data/product-rules.json +231 -0
- package/localized/zh-CN/skills/fec-ui-design/data/stack-ui-rules.json +146 -0
- package/localized/zh-CN/skills/fec-ui-design/data/style-archetypes.json +373 -0
- package/localized/zh-CN/skills/fec-ui-design/data/ux-quality-rules.json +203 -0
- package/localized/zh-CN/skills/fec-ui-design/references/design-intelligence.md +97 -0
- package/localized/zh-CN/skills/fec-ui-design/references/master-page-overrides.md +30 -0
- package/localized/zh-CN/skills/fec-ui-design/references/pre-delivery-checklist.md +39 -0
- package/localized/zh-CN/skills/fec-ui-design/scripts/design-system.mjs +648 -0
- package/localized/zh-CN/skills/fec-validation-fix/SKILL.md +51 -0
- package/localized/zh-CN/skills/fec-validation-fix/references/report-template.md +43 -0
- package/localized/zh-CN/skills/fec-vite-project-standard/SKILL.md +83 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/SKILL.md +58 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +162 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +13 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-project-structure.md +176 -0
- package/localized/zh-CN/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +216 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/SKILL.md +61 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/data/starter-themes.json +59 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/references/chapter-craft.md +37 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/references/content-plan.md +38 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/references/recording-and-audio.md +33 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/references/theme-system.md +36 -0
- package/localized/zh-CN/skills/fec-web-video-presentation/scripts/create-video-presentation.mjs +430 -0
- package/localized/zh-CN/skills/fec-web-workers/SKILL.md +35 -0
- package/localized/zh-CN/skills/fec-web-workers/references/advanced-workers.md +54 -0
- package/localized/zh-CN/skills/fec-web-workers/references/basic-worker.md +67 -0
- package/localized/zh-CN/skills/metadata.json +2004 -0
- package/localized/zh-CN/skills/relations.json +1023 -0
- package/localized/zh-CN/templates/claude/CLAUDE.md +106 -0
- package/localized/zh-CN/templates/claude/settings.json +62 -0
- package/localized/zh-CN/templates/codex/AGENTS.md +105 -0
- package/localized/zh-CN/templates/codex/config.toml +32 -0
- package/localized/zh-CN/templates/openclaw/AGENTS.md +101 -0
- package/localized/zh-CN/templates/openclaw/OPENCLAW-CONFIG.md +12 -0
- package/localized/zh-CN/templates/shared/rules/fec-agent-workflow.md +55 -0
- package/localized/zh-CN/templates/shared/rules/fec-api-layer.md +99 -0
- package/localized/zh-CN/templates/shared/rules/fec-ci-cd.md +40 -0
- package/localized/zh-CN/templates/shared/rules/fec-code-comments.md +33 -0
- package/localized/zh-CN/templates/shared/rules/fec-design-system.md +72 -0
- package/localized/zh-CN/templates/shared/rules/fec-error-handling.md +56 -0
- package/localized/zh-CN/templates/shared/rules/fec-git-conventions.md +73 -0
- package/localized/zh-CN/templates/shared/rules/fec-i18n.md +64 -0
- package/localized/zh-CN/templates/shared/rules/fec-naming-conventions.md +120 -0
- package/localized/zh-CN/templates/shared/rules/fec-performance.md +101 -0
- package/localized/zh-CN/templates/shared/rules/fec-react.md +82 -0
- package/localized/zh-CN/templates/shared/rules/fec-refactoring.md +47 -0
- package/localized/zh-CN/templates/shared/rules/fec-rendering-patterns.md +40 -0
- package/localized/zh-CN/templates/shared/rules/fec-responsive-design.md +50 -0
- package/localized/zh-CN/templates/shared/rules/fec-source-driven-development.md +31 -0
- package/localized/zh-CN/templates/shared/rules/fec-state-management.md +60 -0
- package/localized/zh-CN/templates/shared/rules/fec-testing.md +98 -0
- package/localized/zh-CN/templates/shared/rules/fec-typescript.md +112 -0
- package/localized/zh-CN/templates/shared/rules/fec-vue.md +64 -0
- package/localized/zh-CN/templates/shared/rules/fec-working-modes.md +50 -0
- package/openclaw.plugin.json +2 -3
- package/package.json +28 -17
- package/skills/TEMPLATE.md +74 -74
- package/skills/eval_queries.json +922 -678
- package/skills/fec-accessibility-check/SKILL.md +21 -21
- package/skills/fec-accessibility-check/references/report-template.md +12 -12
- package/skills/fec-accessibility-check/references/screen-reader-testing.md +24 -24
- package/skills/fec-alchemy/SKILL.md +50 -50
- package/skills/fec-alchemy/assets/absorption-plan-template.md +32 -32
- package/skills/fec-alchemy/assets/intake-template.md +55 -55
- package/skills/fec-alchemy/assets/review-checklist.md +23 -23
- package/skills/fec-alchemy/references/methodology.md +66 -66
- package/skills/fec-alchemy/references/originality-and-licensing.md +42 -42
- package/skills/fec-api-integration/SKILL.md +61 -61
- package/skills/fec-api-integration/references/integration-patterns.md +30 -30
- package/skills/fec-backend-requirements-handoff/SKILL.md +25 -25
- package/skills/fec-browser-storage/SKILL.md +16 -16
- package/skills/fec-browser-storage/references/storage-patterns.md +16 -16
- package/skills/fec-canvas-threejs/SKILL.md +21 -21
- package/skills/fec-canvas-threejs/references/rendering-patterns.md +10 -10
- package/skills/fec-canvas-threejs/references/shader-webgl-patterns.md +37 -37
- package/skills/fec-code-review/SKILL.md +113 -94
- package/skills/fec-code-review/references/report-template.md +23 -13
- package/skills/fec-code-smells/SKILL.md +33 -0
- package/skills/fec-code-smells/references/detection-guide.md +25 -0
- package/skills/fec-code-smells/references/smell-catalog.md +861 -0
- package/skills/fec-code-smells/references/smell-to-refactoring-map.md +265 -0
- package/skills/fec-component-testing/SKILL.md +39 -39
- package/skills/fec-data-fetching/SKILL.md +16 -16
- package/skills/fec-data-fetching/references/query-patterns.md +27 -27
- package/skills/fec-debug-framework/SKILL.md +95 -95
- package/skills/fec-debug-framework/references/report-template.md +34 -34
- package/skills/fec-dependency-upgrade/SKILL.md +17 -17
- package/skills/fec-dependency-upgrade/references/dependency-upgrade-workflow.md +31 -31
- package/skills/fec-doc-sync/SKILL.md +23 -23
- package/skills/fec-drawio-studio/SKILL.md +42 -38
- package/skills/fec-drawio-studio/data/THIRD_PARTY_NOTICES.md +1 -1
- package/skills/fec-drawio-studio/data/shape-index.json +83570 -0
- package/skills/fec-drawio-studio/references/diagram-patterns.md +19 -0
- package/skills/fec-drawio-studio/references/flowchart-quality.md +49 -0
- package/skills/fec-drawio-studio/references/layout-and-export.md +18 -3
- package/skills/fec-drawio-studio/references/xml-and-mermaid.md +5 -1
- package/skills/fec-drawio-studio/scripts/diagram-lint.mjs +62 -0
- package/skills/fec-drawio-studio/scripts/drawio-export.mjs +134 -0
- package/skills/fec-drawio-studio/scripts/shape-query.mjs +55 -15
- package/skills/fec-e2e-testing/SKILL.md +24 -24
- package/skills/fec-e2e-testing/references/e2e-ci-reporting.md +20 -20
- package/skills/fec-e2e-testing/references/e2e-special-scenarios.md +10 -10
- package/skills/fec-e2e-testing/references/e2e-visual-regression.md +17 -17
- package/skills/fec-e2e-testing/references/playwright-patterns.md +6 -6
- package/skills/fec-form-handling/SKILL.md +21 -21
- package/skills/fec-form-handling/references/advanced-form-patterns.md +41 -41
- package/skills/fec-image-generation/SKILL.md +84 -29
- package/skills/fec-image-generation/assets/interactive-diagram.html +371 -0
- package/skills/fec-image-generation/assets/quality-examples/README.md +14 -0
- package/skills/fec-image-generation/assets/quality-examples/architecture.json +121 -0
- package/skills/fec-image-generation/assets/quality-examples/invalid-explicit.json +41 -0
- package/skills/fec-image-generation/assets/quality-examples/sequence.json +53 -0
- package/skills/fec-image-generation/assets/quality-examples/sequence.mmd +21 -0
- package/skills/fec-image-generation/assets/quality-examples/workflow.json +98 -0
- package/skills/fec-image-generation/assets/quality-examples/workflow.mmd +7 -0
- package/skills/fec-image-generation/references/diagram-workflows.md +41 -3
- package/skills/fec-image-generation/references/html-technical-diagrams.md +243 -0
- package/skills/fec-image-generation/references/png-qa-autofix.md +9 -2
- package/skills/fec-image-generation/scripts/diagram-browser.mjs +90 -0
- package/skills/fec-image-generation/scripts/diagram-layout.mjs +176 -0
- package/skills/fec-image-generation/scripts/export-diagram.mjs +332 -0
- package/skills/fec-image-generation/scripts/interactive-diagram-server.mjs +654 -0
- package/skills/fec-image-generation/scripts/mermaid-render.mjs +64 -0
- package/skills/fec-image-generation/scripts/png-qa.mjs +35 -4
- package/skills/fec-image-generation/scripts/tech-diagram-render.mjs +1537 -0
- package/skills/fec-implement-from-design/SKILL.md +81 -81
- package/skills/fec-implement-from-design/references/design-plan-template.md +16 -16
- package/skills/fec-legacy-to-modern-migration/SKILL.md +29 -29
- package/skills/fec-legacy-to-modern-migration/references/migration-execution-checklist.md +81 -81
- package/skills/fec-legacy-to-modern-migration/references/migration-report-template.md +37 -37
- package/skills/fec-legacy-to-modern-migration/references/migration-strategy-and-mapping.md +31 -31
- package/skills/fec-legacy-web-standard/SKILL.md +17 -17
- package/skills/fec-legacy-web-standard/references/legacy-patterns.md +16 -16
- package/skills/fec-list-virtualization/SKILL.md +16 -16
- package/skills/fec-list-virtualization/references/virtualization-patterns.md +31 -31
- package/skills/fec-monorepo-project-standard/SKILL.md +52 -52
- package/skills/fec-motion-interaction/SKILL.md +51 -51
- package/skills/fec-motion-interaction/references/motion-patterns.md +11 -11
- package/skills/fec-nextjs-project-standard/SKILL.md +64 -64
- package/skills/fec-nuxt-project-standard/SKILL.md +57 -57
- package/skills/fec-performance-optimization/SKILL.md +54 -54
- package/skills/fec-performance-optimization/references/framework-performance-patterns.md +23 -23
- package/skills/fec-performance-optimization/references/report-template.md +31 -31
- package/skills/fec-pwa-implementation/SKILL.md +17 -17
- package/skills/fec-pwa-implementation/references/manifest-and-icons.md +12 -12
- package/skills/fec-pwa-implementation/references/service-worker-workbox.md +13 -13
- package/skills/fec-react-project-standard/SKILL.md +72 -72
- package/skills/fec-react-project-standard/references/react-performance-patterns.md +28 -28
- package/skills/fec-react-project-standard/references/react-project-structure.md +112 -112
- package/skills/fec-react-project-standard/references/react-quality-patterns.md +72 -72
- package/skills/fec-react-project-standard/references/react-runtime-patterns.md +94 -94
- package/skills/fec-refactor-clean/SKILL.md +33 -30
- package/skills/fec-refactor-clean/references/report-template.md +23 -23
- package/skills/fec-refactoring/SKILL.md +83 -0
- package/skills/fec-refactoring/references/principles.md +60 -0
- package/skills/fec-refactoring/references/refactoring-vs-feature-change.md +27 -0
- package/skills/fec-refactoring/references/when-to-refactor.md +31 -0
- package/skills/fec-refactoring/references/workflow.md +90 -0
- package/skills/fec-refactoring-api/SKILL.md +25 -0
- package/skills/fec-refactoring-api/references/api-refactorings.md +496 -0
- package/skills/fec-refactoring-catalog/SKILL.md +28 -0
- package/skills/fec-refactoring-catalog/references/catalog-index.md +99 -0
- package/skills/fec-refactoring-catalog/references/composition-guide.md +49 -0
- package/skills/fec-refactoring-catalog/references/selection-guide.md +47 -0
- package/skills/fec-refactoring-control/SKILL.md +25 -0
- package/skills/fec-refactoring-control/references/conditional-refactorings.md +299 -0
- package/skills/fec-refactoring-data/SKILL.md +25 -0
- package/skills/fec-refactoring-data/references/data-refactorings.md +248 -0
- package/skills/fec-refactoring-encapsulation/SKILL.md +25 -0
- package/skills/fec-refactoring-encapsulation/references/encapsulation-refactorings.md +452 -0
- package/skills/fec-refactoring-functions/SKILL.md +25 -0
- package/skills/fec-refactoring-functions/references/function-refactorings.md +567 -0
- package/skills/fec-refactoring-inheritance/SKILL.md +25 -0
- package/skills/fec-refactoring-inheritance/references/inheritance-refactorings.md +550 -0
- package/skills/fec-refactoring-move-features/SKILL.md +25 -0
- package/skills/fec-refactoring-move-features/references/moving-refactorings.md +453 -0
- package/skills/fec-refactoring-validation/SKILL.md +59 -0
- package/skills/fec-refactoring-validation/references/behavior-preservation.md +53 -0
- package/skills/fec-refactoring-validation/references/refactoring-test-checklist.md +42 -0
- package/skills/fec-responsive-layout/SKILL.md +17 -17
- package/skills/fec-responsive-layout/references/responsive-layout-patterns.md +37 -37
- package/skills/fec-route-protection/SKILL.md +26 -26
- package/skills/fec-security-review/SKILL.md +36 -20
- package/skills/fec-security-review/references/report-template.md +22 -12
- package/skills/fec-security-review/references/security-checklist.md +27 -27
- package/skills/fec-source-driven-development/SKILL.md +59 -59
- package/skills/fec-state-management/SKILL.md +34 -34
- package/skills/fec-state-management/references/state-patterns.md +19 -19
- package/skills/fec-storybook-component-doc/SKILL.md +19 -19
- package/skills/fec-storybook-component-doc/references/story-patterns.md +12 -12
- package/skills/fec-svg-animation/SKILL.md +32 -32
- package/skills/fec-tailwind-design-system/SKILL.md +17 -17
- package/skills/fec-tailwind-design-system/references/tailwind-system-patterns.md +36 -36
- package/skills/fec-tdd-workflow/SKILL.md +32 -28
- package/skills/fec-testing-strategy/SKILL.md +29 -29
- package/skills/fec-typescript-project-standard/SKILL.md +38 -38
- package/skills/fec-typescript-project-standard/references/type-safety-patterns.md +20 -20
- package/skills/fec-typescript-project-standard/references/type-safety.md +18 -18
- package/skills/fec-ui-design/SKILL.md +90 -90
- package/skills/fec-ui-design/references/design-intelligence.md +61 -61
- package/skills/fec-ui-design/references/master-page-overrides.md +15 -15
- package/skills/fec-ui-design/references/pre-delivery-checklist.md +38 -38
- package/skills/fec-validation-fix/SKILL.md +26 -26
- package/skills/fec-validation-fix/references/report-template.md +25 -25
- package/skills/fec-vite-project-standard/SKILL.md +39 -39
- package/skills/fec-vue3-project-standard/SKILL.md +38 -38
- package/skills/fec-vue3-project-standard/references/vue3-composables-routing.md +36 -36
- package/skills/fec-vue3-project-standard/references/vue3-performance-patterns.md +8 -8
- package/skills/fec-vue3-project-standard/references/vue3-project-structure.md +112 -112
- package/skills/fec-vue3-project-standard/references/vue3-state-api-quality.md +74 -74
- package/skills/fec-web-video-presentation/SKILL.md +33 -33
- package/skills/fec-web-workers/SKILL.md +16 -16
- package/skills/fec-web-workers/references/advanced-workers.md +13 -13
- package/skills/fec-web-workers/references/basic-worker.md +8 -8
- package/skills/metadata.json +485 -116
- package/skills/relations.json +268 -0
- package/templates/claude/CLAUDE.md +60 -60
- package/templates/codex/AGENTS.md +76 -76
- package/templates/codex/config.toml +4 -4
- package/templates/openclaw/AGENTS.md +68 -68
- package/templates/openclaw/OPENCLAW-CONFIG.md +8 -8
- package/templates/shared/rules/fec-agent-workflow.md +41 -40
- package/templates/shared/rules/fec-api-layer.md +52 -52
- package/templates/shared/rules/fec-ci-cd.md +29 -29
- package/templates/shared/rules/fec-code-comments.md +22 -22
- package/templates/shared/rules/fec-design-system.md +53 -53
- package/templates/shared/rules/fec-error-handling.md +40 -40
- package/templates/shared/rules/fec-git-conventions.md +42 -42
- package/templates/shared/rules/fec-i18n.md +48 -48
- package/templates/shared/rules/fec-naming-conventions.md +91 -91
- package/templates/shared/rules/fec-performance.md +78 -78
- package/templates/shared/rules/fec-react.md +58 -58
- package/templates/shared/rules/fec-refactoring.md +34 -34
- package/templates/shared/rules/fec-rendering-patterns.md +36 -36
- package/templates/shared/rules/fec-responsive-design.md +37 -37
- package/templates/shared/rules/fec-source-driven-development.md +22 -22
- package/templates/shared/rules/fec-state-management.md +56 -56
- package/templates/shared/rules/fec-testing.md +64 -64
- package/templates/shared/rules/fec-typescript.md +75 -75
- package/templates/shared/rules/fec-vue.md +42 -42
- package/templates/shared/rules/fec-working-modes.md +34 -34
- package/docs/superpowers/plans/2026-05-29-fec-debug.md +0 -491
- package/docs/superpowers/specs/2026-05-29-fec-debug-design.md +0 -340
- package/skills/fec-drawio-studio/data/shape-index.json.gz +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @ts-check
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
|
|
8
|
+
// Use installed tools only. Never invoke npx or a shell that could download packages.
|
|
9
|
+
try {
|
|
10
|
+
/** @type {Record<string,string>} */
|
|
11
|
+
const args = {};
|
|
12
|
+
for (let i = 2; i < process.argv.length; i += 2) {
|
|
13
|
+
const key = process.argv[i];
|
|
14
|
+
if (!key.startsWith("--") || !process.argv[i + 1]) throw new Error("Expected --input source.mmd --output image.svg [--cli path] [--theme default|dark|neutral|forest] [--timeout 30000] [--report file.json]");
|
|
15
|
+
if (!["input", "output", "cli", "theme", "timeout", "report", "format"].includes(key.slice(2))) throw new Error(`Unknown argument: ${key}`);
|
|
16
|
+
args[key.slice(2)] = process.argv[i + 1];
|
|
17
|
+
}
|
|
18
|
+
if (!args.input || !args.output) throw new Error("--input and --output are required.");
|
|
19
|
+
const input = path.resolve(args.input), output = path.resolve(args.output);
|
|
20
|
+
if (!fs.existsSync(input)) throw new Error(`Input does not exist: ${input}`);
|
|
21
|
+
if (!/\.(svg|png|pdf)$/i.test(output)) throw new Error("Output must end in .svg, .png or .pdf.");
|
|
22
|
+
const theme = args.theme === "light" ? "default" : args.theme ?? "default";
|
|
23
|
+
if (args.format && !["json","markdown"].includes(args.format)) throw new Error("--format must be json or markdown");
|
|
24
|
+
if (!["default", "dark", "neutral", "forest"].includes(theme)) throw new Error("Unsupported Mermaid theme.");
|
|
25
|
+
const timeout = Number(args.timeout ?? 30000);
|
|
26
|
+
if (!Number.isFinite(timeout) || timeout < 100 || timeout > 300000) throw new Error("--timeout must be between 100 and 300000 milliseconds.");
|
|
27
|
+
/** @type {string[]} */
|
|
28
|
+
const candidates = args.cli ? [path.resolve(args.cli)] : (process.env.PATH ?? "").split(path.delimiter).flatMap((dir) => [path.join(dir, "mmdc"), path.join(dir, "mmdc.cmd")]);
|
|
29
|
+
let cli = candidates.find((candidate) => fs.existsSync(candidate));
|
|
30
|
+
if (cli?.endsWith(".cmd")) {
|
|
31
|
+
// npm Windows shims are shell scripts. Execute their installed JS entry directly.
|
|
32
|
+
const entry = path.join(path.dirname(cli), "node_modules", "@mermaid-js", "mermaid-cli", "src", "cli.js");
|
|
33
|
+
cli = fs.existsSync(entry) ? entry : undefined;
|
|
34
|
+
}
|
|
35
|
+
if (!cli) throw new Error("Mermaid CLI unavailable. Use the JSON/HTML renderer or provide an installed mmdc JS entry with --cli. No packages were installed.");
|
|
36
|
+
const js = /\.[cm]?js$/i.test(cli);
|
|
37
|
+
const command = js ? process.execPath : cli;
|
|
38
|
+
const prefix = js ? [cli] : [];
|
|
39
|
+
const version = spawnSync(command, [...prefix, "--version"], { encoding: "utf8", timeout, windowsHide: true });
|
|
40
|
+
if (version.error || version.status !== 0) throw new Error(`Mermaid CLI unavailable: ${version.error?.message ?? version.stderr}`);
|
|
41
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fec-mermaid-"));
|
|
42
|
+
try {
|
|
43
|
+
const artifact = path.join(dir, `diagram${path.extname(output)}`);
|
|
44
|
+
const result = spawnSync(command, [...prefix, "-i", input, "-o", artifact, "-t", theme], { encoding: "utf8", timeout, windowsHide: true });
|
|
45
|
+
if (result.error || result.status !== 0) throw new Error(`Mermaid render failed: ${result.error?.message ?? result.stderr}`);
|
|
46
|
+
if (!fs.existsSync(artifact) || fs.statSync(artifact).size === 0) throw new Error("Mermaid render failed: no fresh artifact produced.");
|
|
47
|
+
const bytes = fs.readFileSync(artifact);
|
|
48
|
+
if (output.endsWith(".svg") && !bytes.toString("utf8").includes("<svg")) throw new Error("Mermaid render failed: invalid SVG.");
|
|
49
|
+
if (output.endsWith(".png") && bytes.subarray(0, 8).toString("hex") !== "89504e470d0a1a0a") throw new Error("Mermaid render failed: invalid PNG.");
|
|
50
|
+
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
51
|
+
fs.copyFileSync(artifact, output);
|
|
52
|
+
if (args.report) {
|
|
53
|
+
fs.mkdirSync(path.dirname(path.resolve(args.report)), { recursive: true });
|
|
54
|
+
fs.writeFileSync(args.report, JSON.stringify({ ok:true,engine:"mermaid",format:path.extname(output).slice(1),verified:false,route: "mermaid", version: version.stdout.trim(), input, output, theme, status: "rendered", visualQA: "pending" }, null, 2) + "\n");
|
|
55
|
+
}
|
|
56
|
+
const report = {ok:true,engine:"mermaid",version:version.stdout.trim(),input,output,format:path.extname(output).slice(1),verified:false,reason:"Final image visual QA is pending."};
|
|
57
|
+
console.log(args.format === "json" ? JSON.stringify(report) : `Rendered Mermaid diagram: ${output}\nVisual QA: pending`);
|
|
58
|
+
} finally {
|
|
59
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
60
|
+
}
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
63
|
+
process.exitCode = 1;
|
|
64
|
+
}
|
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import zlib from "node:zlib";
|
|
6
|
+
import { segmentHits } from "./diagram-layout.mjs";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
|
|
9
|
+
if (process.argv[1] && pathToFileURL(path.resolve(process.argv[1])).href === import.meta.url) {
|
|
10
|
+
const args = parseArgs(process.argv.slice(2));
|
|
11
|
+
|
|
12
|
+
if (!args.png || args.help) {
|
|
13
|
+
printHelp();
|
|
14
|
+
process.exit(args.help ? 0 : 1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const image = readPng(args.png);
|
|
19
|
+
const manifest = args.manifest ? readManifest(args.manifest) : undefined;
|
|
20
|
+
const report = analyze(image, manifest, Boolean(args.strict));
|
|
21
|
+
if ((args.format ?? "markdown") === "json") {
|
|
22
|
+
console.log(JSON.stringify(report, null, 2));
|
|
23
|
+
} else {
|
|
24
|
+
console.log(renderMarkdown(report));
|
|
25
|
+
}
|
|
26
|
+
process.exit(report.ok ? 0 : 2);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function parseArgs(values) {
|
|
35
|
+
const parsed = { format: "markdown", strict: false, help: false };
|
|
36
|
+
for (let index = 0; index < values.length; index += 1) {
|
|
37
|
+
const value = values[index];
|
|
38
|
+
if (value === "--help" || value === "-h") parsed.help = true;
|
|
39
|
+
else if (value === "--strict") parsed.strict = true;
|
|
40
|
+
else if (value === "--png") parsed.png = values[++index];
|
|
41
|
+
else if (value === "--manifest") parsed.manifest = values[++index];
|
|
42
|
+
else if (value === "--format") parsed.format = values[++index];
|
|
43
|
+
else throw new Error(`Unknown argument: ${value}`);
|
|
44
|
+
}
|
|
45
|
+
if (parsed.format !== "json" && parsed.format !== "markdown") {
|
|
46
|
+
throw new Error("--format must be json or markdown");
|
|
47
|
+
}
|
|
48
|
+
return parsed;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function printHelp() {
|
|
52
|
+
console.log(`Usage: node skills/fec-image-generation/scripts/png-qa.mjs --png <file> [--manifest <layout.json>] [--format json|markdown] [--strict]`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function readManifest(filePath) {
|
|
56
|
+
const manifest = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
57
|
+
return {
|
|
58
|
+
...manifest,
|
|
59
|
+
canvas: manifest.canvas,
|
|
60
|
+
boxes: Array.isArray(manifest.boxes) ? manifest.boxes : [],
|
|
61
|
+
connectors: Array.isArray(manifest.connectors) ? manifest.connectors : [],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function readPng(filePath) {
|
|
66
|
+
const buffer = fs.readFileSync(filePath);
|
|
67
|
+
const signature = "89504e470d0a1a0a";
|
|
68
|
+
if (buffer.subarray(0, 8).toString("hex") !== signature) {
|
|
69
|
+
throw new Error(`Not a PNG file: ${filePath}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let offset = 8;
|
|
73
|
+
let ihdr;
|
|
74
|
+
const idat = [];
|
|
75
|
+
while (offset < buffer.length) {
|
|
76
|
+
const length = buffer.readUInt32BE(offset);
|
|
77
|
+
const type = buffer.subarray(offset + 4, offset + 8).toString("ascii");
|
|
78
|
+
const data = buffer.subarray(offset + 8, offset + 8 + length);
|
|
79
|
+
offset += 12 + length;
|
|
80
|
+
if (type === "IHDR") {
|
|
81
|
+
ihdr = {
|
|
82
|
+
width: data.readUInt32BE(0),
|
|
83
|
+
height: data.readUInt32BE(4),
|
|
84
|
+
bitDepth: data[8],
|
|
85
|
+
colorType: data[9],
|
|
86
|
+
compression: data[10],
|
|
87
|
+
filter: data[11],
|
|
88
|
+
interlace: data[12],
|
|
89
|
+
};
|
|
90
|
+
} else if (type === "IDAT") {
|
|
91
|
+
idat.push(data);
|
|
92
|
+
} else if (type === "IEND") {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!ihdr) throw new Error("PNG is missing IHDR");
|
|
98
|
+
if (ihdr.bitDepth !== 8) throw new Error(`Unsupported PNG bit depth: ${ihdr.bitDepth}`);
|
|
99
|
+
if (ihdr.compression !== 0 || ihdr.filter !== 0 || ihdr.interlace !== 0) {
|
|
100
|
+
throw new Error("Unsupported PNG compression/filter/interlace settings");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const channels = channelsForColorType(ihdr.colorType);
|
|
104
|
+
const inflated = zlib.inflateSync(Buffer.concat(idat));
|
|
105
|
+
const pixels = unfilter(inflated, ihdr.width, ihdr.height, channels);
|
|
106
|
+
return {
|
|
107
|
+
path: path.resolve(filePath),
|
|
108
|
+
width: ihdr.width,
|
|
109
|
+
height: ihdr.height,
|
|
110
|
+
colorType: ihdr.colorType,
|
|
111
|
+
channels,
|
|
112
|
+
pixels,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function channelsForColorType(colorType) {
|
|
117
|
+
if (colorType === 0) return 1;
|
|
118
|
+
if (colorType === 2) return 3;
|
|
119
|
+
if (colorType === 4) return 2;
|
|
120
|
+
if (colorType === 6) return 4;
|
|
121
|
+
throw new Error(`Unsupported PNG color type: ${colorType}`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function unfilter(data, width, height, channels) {
|
|
125
|
+
const stride = width * channels;
|
|
126
|
+
const output = Buffer.alloc(stride * height);
|
|
127
|
+
let sourceOffset = 0;
|
|
128
|
+
|
|
129
|
+
for (let y = 0; y < height; y += 1) {
|
|
130
|
+
const filterType = data[sourceOffset];
|
|
131
|
+
sourceOffset += 1;
|
|
132
|
+
const rowOffset = y * stride;
|
|
133
|
+
const previousRowOffset = (y - 1) * stride;
|
|
134
|
+
|
|
135
|
+
for (let x = 0; x < stride; x += 1) {
|
|
136
|
+
const raw = data[sourceOffset + x];
|
|
137
|
+
const left = x >= channels ? output[rowOffset + x - channels] : 0;
|
|
138
|
+
const up = y > 0 ? output[previousRowOffset + x] : 0;
|
|
139
|
+
const upLeft = y > 0 && x >= channels ? output[previousRowOffset + x - channels] : 0;
|
|
140
|
+
let value;
|
|
141
|
+
if (filterType === 0) value = raw;
|
|
142
|
+
else if (filterType === 1) value = raw + left;
|
|
143
|
+
else if (filterType === 2) value = raw + up;
|
|
144
|
+
else if (filterType === 3) value = raw + Math.floor((left + up) / 2);
|
|
145
|
+
else if (filterType === 4) value = raw + paeth(left, up, upLeft);
|
|
146
|
+
else throw new Error(`Unsupported PNG filter type: ${filterType}`);
|
|
147
|
+
output[rowOffset + x] = value & 0xff;
|
|
148
|
+
}
|
|
149
|
+
sourceOffset += stride;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return output;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function paeth(left, up, upLeft) {
|
|
156
|
+
const estimate = left + up - upLeft;
|
|
157
|
+
const leftDistance = Math.abs(estimate - left);
|
|
158
|
+
const upDistance = Math.abs(estimate - up);
|
|
159
|
+
const upLeftDistance = Math.abs(estimate - upLeft);
|
|
160
|
+
if (leftDistance <= upDistance && leftDistance <= upLeftDistance) return left;
|
|
161
|
+
if (upDistance <= upLeftDistance) return up;
|
|
162
|
+
return upLeft;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function analyze(image, manifest, strict) {
|
|
166
|
+
const issues = [];
|
|
167
|
+
const nextActions = new Set();
|
|
168
|
+
const ink = measureInk(image, strict ? 10 : 18);
|
|
169
|
+
|
|
170
|
+
if (image.width < 64 || image.height < 64) {
|
|
171
|
+
addIssue(issues, nextActions, "image-too-small", "PNG is too small for reliable visual QA.", "Export a larger PNG before review.");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (ink.coverage < (strict ? 0.001 : 0.0002)) {
|
|
175
|
+
addIssue(issues, nextActions, "blank-image", "PNG appears blank or nearly blank.", "Check the renderer/export target and regenerate the image.");
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (ink.bounds) {
|
|
179
|
+
const pad = strict ? 6 : 3;
|
|
180
|
+
if (ink.bounds.minX <= pad || ink.bounds.minY <= pad || image.width - ink.bounds.maxX <= pad || image.height - ink.bounds.maxY <= pad) {
|
|
181
|
+
addIssue(issues, nextActions, "edge-clipping", "Visible content is very close to the PNG edge.", "Increase canvas/viewBox padding or reduce subject scale.");
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (manifest) analyzeManifest(image, manifest, issues, nextActions, strict);
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
ok: issues.length === 0,
|
|
189
|
+
image: {
|
|
190
|
+
path: image.path,
|
|
191
|
+
width: image.width,
|
|
192
|
+
height: image.height,
|
|
193
|
+
colorType: image.colorType,
|
|
194
|
+
inkCoverage: Number(ink.coverage.toFixed(6)),
|
|
195
|
+
inkBounds: ink.bounds,
|
|
196
|
+
},
|
|
197
|
+
measurement: manifest?.measurement ?? "image-only",
|
|
198
|
+
verification: { image: "checked", geometry: manifest ? "checked" : "unavailable", text: manifest?.measurement === "browser" ? "browser-measured" : "estimated-or-unavailable", visual: "pending" },
|
|
199
|
+
issues,
|
|
200
|
+
nextActions: [...nextActions],
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function measureInk(image, threshold) {
|
|
205
|
+
const first = samplePixel(image, 0, 0);
|
|
206
|
+
let inkPixels = 0;
|
|
207
|
+
let minX = image.width;
|
|
208
|
+
let minY = image.height;
|
|
209
|
+
let maxX = -1;
|
|
210
|
+
let maxY = -1;
|
|
211
|
+
|
|
212
|
+
for (let y = 0; y < image.height; y += 1) {
|
|
213
|
+
for (let x = 0; x < image.width; x += 1) {
|
|
214
|
+
const pixel = samplePixel(image, x, y);
|
|
215
|
+
const differs = colorDistance(pixel, first) > threshold && pixel.a > 8;
|
|
216
|
+
if (differs) {
|
|
217
|
+
inkPixels += 1;
|
|
218
|
+
minX = Math.min(minX, x);
|
|
219
|
+
minY = Math.min(minY, y);
|
|
220
|
+
maxX = Math.max(maxX, x);
|
|
221
|
+
maxY = Math.max(maxY, y);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
coverage: inkPixels / (image.width * image.height),
|
|
228
|
+
bounds: inkPixels > 0 ? { minX, minY, maxX, maxY } : null,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function samplePixel(image, x, y) {
|
|
233
|
+
const offset = (y * image.width + x) * image.channels;
|
|
234
|
+
if (image.channels === 1) {
|
|
235
|
+
const value = image.pixels[offset];
|
|
236
|
+
return { r: value, g: value, b: value, a: 255 };
|
|
237
|
+
}
|
|
238
|
+
if (image.channels === 2) {
|
|
239
|
+
const value = image.pixels[offset];
|
|
240
|
+
return { r: value, g: value, b: value, a: image.pixels[offset + 1] };
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
r: image.pixels[offset],
|
|
244
|
+
g: image.pixels[offset + 1],
|
|
245
|
+
b: image.pixels[offset + 2],
|
|
246
|
+
a: image.channels === 4 ? image.pixels[offset + 3] : 255,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function colorDistance(left, right) {
|
|
251
|
+
return Math.abs(left.r - right.r) + Math.abs(left.g - right.g) + Math.abs(left.b - right.b) + Math.abs(left.a - right.a);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function analyzeManifest(image, manifest, issues, nextActions, strict) {
|
|
255
|
+
if (manifest.canvas && (manifest.canvas.width !== image.width || manifest.canvas.height !== image.height)) {
|
|
256
|
+
addIssue(
|
|
257
|
+
issues,
|
|
258
|
+
nextActions,
|
|
259
|
+
"manifest-canvas-mismatch",
|
|
260
|
+
`Manifest canvas ${manifest.canvas.width}x${manifest.canvas.height} does not match PNG ${image.width}x${image.height}.`,
|
|
261
|
+
"Regenerate the manifest from the final export dimensions.",
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
for (const box of manifest.boxes) if (![box.x,box.y,box.width,box.height].every(Number.isFinite) || box.width <= 0 || box.height <= 0) addIssue(issues,nextActions,"invalid-box-geometry",`Invalid geometry for "${box.id}".`,"Correct source dimensions.");
|
|
266
|
+
const allBoxes = manifest.boxes.map(normalizeBox).filter(Boolean);
|
|
267
|
+
const boxes = allBoxes.filter((box) => box.kind !== "group");
|
|
268
|
+
for (const issue of manifest.issues ?? []) addIssue(issues, nextActions, issue.code, issue.message, "Fix the source layout and render again.");
|
|
269
|
+
const labels = manifest.labels ?? [];
|
|
270
|
+
for (const label of labels) {
|
|
271
|
+
const owner = allBoxes.find((box) => box.id === label.owner);
|
|
272
|
+
if (label.kind === "node" && !owner) addIssue(issues,nextActions,"label-owner-missing",`Label "${label.id}" has an unknown node owner.`,"Correct label ownership in the manifest.");
|
|
273
|
+
if (![label.x,label.y,label.width,label.height].every(Number.isFinite) || label.width < 0 || label.height < 0) addIssue(issues,nextActions,"invalid-label-geometry",`Label "${label.id}" has invalid bounds.`,"Measure source labels again.");
|
|
274
|
+
if (label.x < 0 || label.y < 0 || label.x + label.width > image.width || label.y + label.height > image.height) addIssue(issues, nextActions, "label-out-of-bounds", `Label "${label.id}" exceeds the canvas.`, "Expand the canvas or adjust the source label position.");
|
|
275
|
+
if (label.kind === "node" && owner && (label.x < owner.x || label.y < owner.y || label.x + label.width > owner.x + owner.width || label.y + label.height > owner.y + owner.height)) addIssue(issues, nextActions, "node-text-overflow", `Label "${label.id}" exceeds node "${owner.id}".`, "Expand the source node or adjust its text layout.");
|
|
276
|
+
if (Array.isArray(label.lines) && label.lines.join("").replace(/\r?\n/g, "") !== String(label.text ?? "").replace(/\r?\n/g, "")) addIssue(issues, nextActions, "label-content-loss", `Label "${label.id}" does not preserve source text.`, "Restore the complete source label.");
|
|
277
|
+
if (label.kind === "edge") for (const box of boxes) if (overlapArea(label, box) > 0) addIssue(issues, nextActions, "edge-label-collision", `Label "${label.id}" overlaps node "${box.id}".`, "Move the edge label to a clear route segment.");
|
|
278
|
+
}
|
|
279
|
+
for (let i = 0; i < labels.length; i++) for (let j = i + 1; j < labels.length; j++) if (overlapArea(labels[i], labels[j]) > 0) addIssue(issues, nextActions, "text-overlap", `Labels "${labels[i].id}" and "${labels[j].id}" overlap.`, "Increase label spacing in the source.");
|
|
280
|
+
for (const box of boxes) {
|
|
281
|
+
if (box.x < 0 || box.y < 0 || box.x + box.width > image.width || box.y + box.height > image.height) {
|
|
282
|
+
addIssue(issues, nextActions, "box-out-of-bounds", `Box "${box.id}" is outside the canvas.`, "Move out-of-bounds nodes inside the canvas or expand the canvas.");
|
|
283
|
+
}
|
|
284
|
+
if (!labels.length && box.label && estimateLabelOverflow(box, strict)) {
|
|
285
|
+
addIssue(issues, nextActions, "label-overflow", `Box "${box.id}" label is likely to overflow.`, "Wrap or shorten labels, widen boxes, or increase export scale.");
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
for (let i = 0; i < boxes.length; i += 1) {
|
|
290
|
+
for (let j = i + 1; j < boxes.length; j += 1) {
|
|
291
|
+
const overlap = overlapArea(boxes[i], boxes[j]);
|
|
292
|
+
if (overlap > 0) {
|
|
293
|
+
addIssue(issues, nextActions, "box-overlap", `Boxes "${boxes[i].id}" and "${boxes[j].id}" overlap by ${Math.round(overlap)}px^2.`, "Increase node spacing or split dense groups.");
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const boxById = new Map(boxes.map((box) => [box.id, box]));
|
|
299
|
+
const segments = [];
|
|
300
|
+
for (const connector of manifest.connectors) {
|
|
301
|
+
const points = normalizePoints(connector.points);
|
|
302
|
+
if(points.some(point=>point.x<0||point.y<0||point.x>image.width||point.y>image.height)) addIssue(issues,nextActions,"connector-out-of-bounds",`Connector "${connector.id}" exceeds the canvas.`,"Correct explicit waypoints or expand the source canvas.");
|
|
303
|
+
if (points.length < 2 || points.every((point) => point.x === points[0].x && point.y === points[0].y)) addIssue(issues, nextActions, "degenerate-connector", `Connector "${connector.id ?? "unnamed"}" has no visible path.`, "Give self calls a loop and other connectors distinct endpoints.");
|
|
304
|
+
for (let index = 0; index < points.length - 1; index += 1) {
|
|
305
|
+
const segment = { connector, a: points[index], b: points[index + 1] };
|
|
306
|
+
segments.push(segment);
|
|
307
|
+
for (const label of labels) if (segmentHits([segment.a.x,segment.a.y],[segment.b.x,segment.b.y],label)) addIssue(issues,nextActions,"connector-through-text",`Connector "${connector.id}" crosses label "${label.id}".`,"Move the source label or route around its text.");
|
|
308
|
+
for (const box of boxes) {
|
|
309
|
+
if (box.id === connector.from || box.id === connector.to) continue;
|
|
310
|
+
if (segmentIntersectsBox(segment, box)) {
|
|
311
|
+
addIssue(issues, nextActions, "connector-through-label", `Connector "${connector.id ?? "unnamed"}" crosses box "${box.id}".`, "Add waypoints around labels or use orthogonal routing.");
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if ((connector.from && !boxById.has(connector.from)) || (connector.to && !boxById.has(connector.to))) {
|
|
316
|
+
addIssue(issues, nextActions, "connector-endpoint-missing", `Connector "${connector.id ?? "unnamed"}" references a missing endpoint.`, "Update connector endpoints to match manifest box ids.");
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
for (let i = 0; i < segments.length; i += 1) {
|
|
321
|
+
for (let j = i + 1; j < segments.length; j += 1) {
|
|
322
|
+
if (segments[i].connector === segments[j].connector) continue;
|
|
323
|
+
if (segmentsStack(segments[i], segments[j], strict ? 4 : 2)) {
|
|
324
|
+
addIssue(issues, nextActions, "connector-stacking", "Two connector segments are stacked or nearly stacked.", "Offset parallel connectors or bundle them into a labeled shared route.");
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function normalizeBox(box) {
|
|
331
|
+
if (!box || typeof box.id !== "string") return null;
|
|
332
|
+
const normalized = {
|
|
333
|
+
id: box.id,
|
|
334
|
+
kind: box.kind,
|
|
335
|
+
x: Number(box.x),
|
|
336
|
+
y: Number(box.y),
|
|
337
|
+
width: Number(box.width),
|
|
338
|
+
height: Number(box.height),
|
|
339
|
+
label: typeof box.label === "string" ? box.label : "",
|
|
340
|
+
};
|
|
341
|
+
if ([normalized.x, normalized.y, normalized.width, normalized.height].some((value) => !Number.isFinite(value))) return null;
|
|
342
|
+
return normalized;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function normalizePoints(points) {
|
|
346
|
+
if (!Array.isArray(points)) return [];
|
|
347
|
+
return points
|
|
348
|
+
.map((point) => {
|
|
349
|
+
if (Array.isArray(point)) return { x: Number(point[0]), y: Number(point[1]) };
|
|
350
|
+
return { x: Number(point?.x), y: Number(point?.y) };
|
|
351
|
+
})
|
|
352
|
+
.filter((point) => Number.isFinite(point.x) && Number.isFinite(point.y));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function estimateLabelOverflow(box, strict) {
|
|
356
|
+
const label = box.label.trim();
|
|
357
|
+
if (!label) return false;
|
|
358
|
+
const lines = label.split(/\r?\n/);
|
|
359
|
+
const maxLine = Math.max(...lines.map((line) => visualLength(line)));
|
|
360
|
+
const estimatedWidth = maxLine * (strict ? 7.5 : 7);
|
|
361
|
+
const estimatedHeight = lines.length * (strict ? 18 : 16);
|
|
362
|
+
return estimatedWidth > Math.max(0, box.width - 12) || estimatedHeight > Math.max(0, box.height - 8);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function visualLength(value) {
|
|
366
|
+
return [...value].reduce((total, char) => total + (/[\u4e00-\u9fff]/.test(char) ? 2 : 1), 0);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function overlapArea(left, right) {
|
|
370
|
+
const width = Math.max(0, Math.min(left.x + left.width, right.x + right.width) - Math.max(left.x, right.x));
|
|
371
|
+
const height = Math.max(0, Math.min(left.y + left.height, right.y + right.height) - Math.max(left.y, right.y));
|
|
372
|
+
return width * height;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function segmentIntersectsBox(segment, box) {
|
|
376
|
+
return segmentHits([segment.a.x,segment.a.y],[segment.b.x,segment.b.y],box);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function legacySegmentIntersectsBox(segment, box) {
|
|
380
|
+
if (pointInsideBox(segment.a, box) || pointInsideBox(segment.b, box)) return true;
|
|
381
|
+
const edges = [
|
|
382
|
+
[{ x: box.x, y: box.y }, { x: box.x + box.width, y: box.y }],
|
|
383
|
+
[{ x: box.x + box.width, y: box.y }, { x: box.x + box.width, y: box.y + box.height }],
|
|
384
|
+
[{ x: box.x + box.width, y: box.y + box.height }, { x: box.x, y: box.y + box.height }],
|
|
385
|
+
[{ x: box.x, y: box.y + box.height }, { x: box.x, y: box.y }],
|
|
386
|
+
];
|
|
387
|
+
return edges.some(([a, b]) => segmentsIntersect(segment.a, segment.b, a, b));
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function pointInsideBox(point, box) {
|
|
391
|
+
return point.x >= box.x && point.x <= box.x + box.width && point.y >= box.y && point.y <= box.y + box.height;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function segmentsIntersect(a, b, c, d) {
|
|
395
|
+
const o1 = orientation(a, b, c);
|
|
396
|
+
const o2 = orientation(a, b, d);
|
|
397
|
+
const o3 = orientation(c, d, a);
|
|
398
|
+
const o4 = orientation(c, d, b);
|
|
399
|
+
if (o1 !== o2 && o3 !== o4) return true;
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function orientation(a, b, c) {
|
|
404
|
+
const value = (b.y - a.y) * (c.x - b.x) - (b.x - a.x) * (c.y - b.y);
|
|
405
|
+
if (Math.abs(value) < 0.0001) return 0;
|
|
406
|
+
return value > 0 ? 1 : 2;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function segmentsStack(left, right, tolerance) {
|
|
410
|
+
const leftHorizontal = Math.abs(left.a.y - left.b.y) <= tolerance;
|
|
411
|
+
const rightHorizontal = Math.abs(right.a.y - right.b.y) <= tolerance;
|
|
412
|
+
const leftVertical = Math.abs(left.a.x - left.b.x) <= tolerance;
|
|
413
|
+
const rightVertical = Math.abs(right.a.x - right.b.x) <= tolerance;
|
|
414
|
+
|
|
415
|
+
if (leftHorizontal && rightHorizontal && Math.abs(left.a.y - right.a.y) <= tolerance) {
|
|
416
|
+
return rangesOverlap([left.a.x, left.b.x], [right.a.x, right.b.x]) > tolerance;
|
|
417
|
+
}
|
|
418
|
+
if (leftVertical && rightVertical && Math.abs(left.a.x - right.a.x) <= tolerance) {
|
|
419
|
+
return rangesOverlap([left.a.y, left.b.y], [right.a.y, right.b.y]) > tolerance;
|
|
420
|
+
}
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function rangesOverlap(left, right) {
|
|
425
|
+
const a = [Math.min(...left), Math.max(...left)];
|
|
426
|
+
const b = [Math.min(...right), Math.max(...right)];
|
|
427
|
+
return Math.max(0, Math.min(a[1], b[1]) - Math.max(a[0], b[0]));
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function addIssue(issues, nextActions, code, message, action) {
|
|
431
|
+
issues.push({ code, message, action });
|
|
432
|
+
if (typeof nextActions.add === "function") nextActions.add(action);
|
|
433
|
+
else if (!nextActions.includes(action)) nextActions.push(action);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function renderMarkdown(report) {
|
|
437
|
+
const lines = [
|
|
438
|
+
"# PNG QA Report",
|
|
439
|
+
"",
|
|
440
|
+
`- Status: ${report.ok ? "ok" : "issues-found"}`,
|
|
441
|
+
`- Image: ${report.image.width}x${report.image.height}`,
|
|
442
|
+
`- Ink coverage: ${report.image.inkCoverage}`,
|
|
443
|
+
];
|
|
444
|
+
if (report.image.inkBounds) {
|
|
445
|
+
lines.push(`- Ink bounds: ${JSON.stringify(report.image.inkBounds)}`);
|
|
446
|
+
}
|
|
447
|
+
lines.push("", "## Issues");
|
|
448
|
+
if (report.issues.length === 0) {
|
|
449
|
+
lines.push("- None");
|
|
450
|
+
} else {
|
|
451
|
+
for (const issue of report.issues) {
|
|
452
|
+
lines.push(`- ${issue.code}: ${issue.message}`);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
lines.push("", "## Next Actions");
|
|
456
|
+
if (report.nextActions.length === 0) {
|
|
457
|
+
lines.push("- None");
|
|
458
|
+
} else {
|
|
459
|
+
for (const action of report.nextActions) lines.push(`- ${action}`);
|
|
460
|
+
}
|
|
461
|
+
return `${lines.join("\n")}\n`;
|
|
462
|
+
}
|