@zenrick/zenkit 0.0.0-stage → 0.5.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 +19 -0
- package/.cursor-plugin/marketplace.json +22 -0
- package/INSTALL.md +73 -0
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +69 -3
- package/TERMS.md +48 -0
- package/THIRD-PARTY-NOTICES.md +109 -0
- package/kit/agents/backend-specialist.md +263 -0
- package/kit/agents/code-archaeologist.md +106 -0
- package/kit/agents/database-architect.md +226 -0
- package/kit/agents/debugger.md +226 -0
- package/kit/agents/devops-engineer.md +242 -0
- package/kit/agents/documentation-writer.md +104 -0
- package/kit/agents/explorer-agent.md +73 -0
- package/kit/agents/frontend-specialist.md +593 -0
- package/kit/agents/game-developer.md +162 -0
- package/kit/agents/mobile-developer.md +377 -0
- package/kit/agents/orchestrator.md +489 -0
- package/kit/agents/penetration-tester.md +188 -0
- package/kit/agents/performance-optimizer.md +187 -0
- package/kit/agents/product-manager.md +112 -0
- package/kit/agents/product-owner.md +95 -0
- package/kit/agents/project-planner.md +409 -0
- package/kit/agents/qa-automation-engineer.md +103 -0
- package/kit/agents/security-auditor.md +170 -0
- package/kit/agents/seo-specialist.md +111 -0
- package/kit/agents/test-engineer.md +158 -0
- package/kit/bundles/agent-building.yaml +26 -0
- package/kit/bundles/backend-data.yaml +14 -0
- package/kit/bundles/base.yaml +10 -0
- package/kit/bundles/core.yaml +21 -0
- package/kit/bundles/kit-engenharia.yaml +8 -0
- package/kit/bundles/kit-lite.yaml +9 -0
- package/kit/bundles/security.yaml +11 -0
- package/kit/bundles/ship-run.yaml +16 -0
- package/kit/bundles/web-ui.yaml +18 -0
- package/kit/commands/docs.md +33 -0
- package/kit/commands/explain.md +41 -0
- package/kit/commands/fix.md +65 -0
- package/kit/commands/implement.md +35 -0
- package/kit/commands/refactor.md +59 -0
- package/kit/commands/review.md +55 -0
- package/kit/commands/test.md +63 -0
- package/kit/modules/bridge/rules/cross-ide-bridge.mdc +73 -0
- package/kit/modules/bridge/zenkit-layer.yaml +1 -0
- package/kit/modules/nexuscore/sections/convivencia.md +12 -0
- package/kit/modules/nexuscore/sections/memoria.md +9 -0
- package/kit/modules/nexuscore/skills/quadro-agentes/SKILL.md +186 -0
- package/kit/modules/nexuscore/zenkit-layer.yaml +1 -0
- package/kit/rules/ZENKIT.mdc +294 -0
- package/kit/rules/git.mdc +51 -0
- package/kit/rules/karpathy-guidelines.mdc +70 -0
- package/kit/rules/model-routing.mdc +89 -0
- package/kit/rules/security-headers.mdc +41 -0
- package/kit/rules/social-automation.mdc +69 -0
- package/kit/rules/toc.mdc +40 -0
- package/kit/skills/api-patterns/SKILL.md +95 -0
- package/kit/skills/api-patterns/api-style.md +42 -0
- package/kit/skills/api-patterns/auth.md +24 -0
- package/kit/skills/api-patterns/documentation.md +26 -0
- package/kit/skills/api-patterns/graphql.md +41 -0
- package/kit/skills/api-patterns/rate-limiting.md +31 -0
- package/kit/skills/api-patterns/references/backend/backend-api-design.md +495 -0
- package/kit/skills/api-patterns/references/backend/backend-architecture.md +454 -0
- package/kit/skills/api-patterns/references/backend/backend-authentication.md +338 -0
- package/kit/skills/api-patterns/references/backend/backend-code-quality.md +659 -0
- package/kit/skills/api-patterns/references/backend/backend-debugging.md +904 -0
- package/kit/skills/api-patterns/references/backend/backend-devops.md +494 -0
- package/kit/skills/api-patterns/references/backend/backend-mindset.md +387 -0
- package/kit/skills/api-patterns/references/backend/backend-performance.md +397 -0
- package/kit/skills/api-patterns/references/backend/backend-security.md +290 -0
- package/kit/skills/api-patterns/references/backend/backend-technologies.md +256 -0
- package/kit/skills/api-patterns/references/backend/backend-testing.md +429 -0
- package/kit/skills/api-patterns/response.md +37 -0
- package/kit/skills/api-patterns/rest.md +40 -0
- package/kit/skills/api-patterns/scripts/api_validator.py +211 -0
- package/kit/skills/api-patterns/security-testing.md +122 -0
- package/kit/skills/api-patterns/trpc.md +41 -0
- package/kit/skills/api-patterns/versioning.md +22 -0
- package/kit/skills/app-builder/SKILL.md +76 -0
- package/kit/skills/app-builder/agent-coordination.md +71 -0
- package/kit/skills/app-builder/feature-building.md +53 -0
- package/kit/skills/app-builder/project-detection.md +34 -0
- package/kit/skills/app-builder/scaffolding.md +118 -0
- package/kit/skills/app-builder/tech-stack.md +41 -0
- package/kit/skills/app-builder/templates/SKILL.md +39 -0
- package/kit/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/kit/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/kit/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/kit/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/kit/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/kit/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/kit/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/kit/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/kit/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/kit/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/kit/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/kit/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/kit/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/kit/skills/architecture/SKILL.md +56 -0
- package/kit/skills/architecture/context-discovery.md +43 -0
- package/kit/skills/architecture/examples.md +94 -0
- package/kit/skills/architecture/pattern-selection.md +68 -0
- package/kit/skills/architecture/patterns-reference.md +50 -0
- package/kit/skills/architecture/trade-off-analysis.md +77 -0
- package/kit/skills/bash-linux/SKILL.md +203 -0
- package/kit/skills/batch-operations/SKILL.md +112 -0
- package/kit/skills/behavioral-modes/SKILL.md +255 -0
- package/kit/skills/brainstorming/SKILL.md +189 -0
- package/kit/skills/brainstorming/dynamic-questioning.md +350 -0
- package/kit/skills/brainstorming/references/problem-solving/attribution.md +69 -0
- package/kit/skills/brainstorming/references/problem-solving/collision-zone-thinking.md +79 -0
- package/kit/skills/brainstorming/references/problem-solving/inversion-exercise.md +91 -0
- package/kit/skills/brainstorming/references/problem-solving/meta-pattern-recognition.md +87 -0
- package/kit/skills/brainstorming/references/problem-solving/scale-game.md +95 -0
- package/kit/skills/brainstorming/references/problem-solving/simplification-cascades.md +80 -0
- package/kit/skills/brainstorming/references/problem-solving/when-stuck.md +72 -0
- package/kit/skills/claude-exec/SKILL.md +185 -0
- package/kit/skills/clean-code/SKILL.md +210 -0
- package/kit/skills/code-review-checklist/SKILL.md +115 -0
- package/kit/skills/code-review-graph/SKILL.md +50 -0
- package/kit/skills/code-review-graph/references/alternatives-comparison.md +12 -0
- package/kit/skills/code-review-graph/references/best-practices.md +9 -0
- package/kit/skills/code-review-graph/references/configuration.md +43 -0
- package/kit/skills/code-review-graph/references/core-workflows.md +61 -0
- package/kit/skills/code-review-graph/references/how-it-works-4-layers.md +20 -0
- package/kit/skills/code-review-graph/references/installation.md +67 -0
- package/kit/skills/code-review-graph/references/integration-with-zenkit.md +23 -0
- package/kit/skills/code-review-graph/references/known-limitations.md +13 -0
- package/kit/skills/code-review-graph/references/when-to-use-vs-when-to-skip.md +21 -0
- package/kit/skills/codex-exec/SKILL.md +161 -0
- package/kit/skills/context-compression/SKILL.md +145 -0
- package/kit/skills/coordinator-mode/SKILL.md +215 -0
- package/kit/skills/cursor-exec/SKILL.md +152 -0
- package/kit/skills/database-design/SKILL.md +53 -0
- package/kit/skills/database-design/database-selection.md +43 -0
- package/kit/skills/database-design/indexing.md +39 -0
- package/kit/skills/database-design/migrations.md +48 -0
- package/kit/skills/database-design/optimization.md +36 -0
- package/kit/skills/database-design/orm-selection.md +30 -0
- package/kit/skills/database-design/schema-design.md +56 -0
- package/kit/skills/database-design/scripts/schema_validator.py +172 -0
- package/kit/skills/deployment-procedures/SKILL.md +242 -0
- package/kit/skills/deprecation-and-migration/SKILL.md +149 -0
- package/kit/skills/documentation-templates/SKILL.md +195 -0
- package/kit/skills/entrega-com-agentes/SKILL.md +177 -0
- package/kit/skills/frontend-design/NOTICE.md +6 -0
- package/kit/skills/frontend-design/SKILL.md +456 -0
- package/kit/skills/frontend-design/animation-guide.md +331 -0
- package/kit/skills/frontend-design/color-system.md +311 -0
- package/kit/skills/frontend-design/decision-trees.md +418 -0
- package/kit/skills/frontend-design/motion-graphics.md +306 -0
- package/kit/skills/frontend-design/references/aesthetic/design-guideline-template.md +163 -0
- package/kit/skills/frontend-design/references/aesthetic/design-principles.md +62 -0
- package/kit/skills/frontend-design/references/aesthetic/design-resources.md +75 -0
- package/kit/skills/frontend-design/references/aesthetic/design-story-template.md +135 -0
- package/kit/skills/frontend-design/references/aesthetic/micro-interactions.md +53 -0
- package/kit/skills/frontend-design/references/aesthetic/storytelling-design.md +50 -0
- package/kit/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/kit/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/kit/skills/frontend-design/typography-system.md +345 -0
- package/kit/skills/frontend-design/ux-psychology.md +1116 -0
- package/kit/skills/frontend-design/visual-effects.md +383 -0
- package/kit/skills/game-development/2d-games/SKILL.md +119 -0
- package/kit/skills/game-development/3d-games/SKILL.md +135 -0
- package/kit/skills/game-development/SKILL.md +168 -0
- package/kit/skills/game-development/game-art/SKILL.md +185 -0
- package/kit/skills/game-development/game-audio/SKILL.md +190 -0
- package/kit/skills/game-development/game-design/SKILL.md +129 -0
- package/kit/skills/game-development/mobile-games/SKILL.md +108 -0
- package/kit/skills/game-development/multiplayer/SKILL.md +132 -0
- package/kit/skills/game-development/pc-games/SKILL.md +144 -0
- package/kit/skills/game-development/vr-ar/SKILL.md +123 -0
- package/kit/skills/game-development/web-games/SKILL.md +150 -0
- package/kit/skills/gemini-exec/SKILL.md +80 -0
- package/kit/skills/geo-fundamentals/SKILL.md +157 -0
- package/kit/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/kit/skills/git-worktrees/SKILL.md +107 -0
- package/kit/skills/i18n-localization/SKILL.md +145 -0
- package/kit/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/kit/skills/intelligent-routing/SKILL.md +128 -0
- package/kit/skills/intelligent-routing/references/4-response-format.md +16 -0
- package/kit/skills/intelligent-routing/references/complexity-assessment.md +29 -0
- package/kit/skills/intelligent-routing/references/debug-intelligent-routing.md +9 -0
- package/kit/skills/intelligent-routing/references/debugging-agent-selection.md +7 -0
- package/kit/skills/intelligent-routing/references/domain-detection-rules.md +29 -0
- package/kit/skills/intelligent-routing/references/edge-cases.md +29 -0
- package/kit/skills/intelligent-routing/references/implementation-rules.md +35 -0
- package/kit/skills/intelligent-routing/references/integration-with-existing-workflows.md +21 -0
- package/kit/skills/intelligent-routing/references/performance-considerations.md +14 -0
- package/kit/skills/intelligent-routing/references/summary.md +16 -0
- package/kit/skills/intelligent-routing/references/testing-the-system.md +36 -0
- package/kit/skills/intelligent-routing/references/tier-0-automatic-analysis-always-active.md +27 -0
- package/kit/skills/intelligent-routing/references/user-education.md +12 -0
- package/kit/skills/karpathy-guidelines/SKILL.md +67 -0
- package/kit/skills/karpathy-guidelines/references/EXAMPLES.md +522 -0
- package/kit/skills/lint-and-validate/SKILL.md +46 -0
- package/kit/skills/lint-and-validate/scripts/lint_runner.py +184 -0
- package/kit/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/kit/skills/mcp-atuacao/SKILL.md +238 -0
- package/kit/skills/mcp-builder/NOTICE.md +6 -0
- package/kit/skills/mcp-builder/SKILL.md +259 -0
- package/kit/skills/memory-system/SKILL.md +181 -0
- package/kit/skills/mobile-design/SKILL.md +395 -0
- package/kit/skills/mobile-design/decision-trees.md +516 -0
- package/kit/skills/mobile-design/mobile-backend.md +491 -0
- package/kit/skills/mobile-design/mobile-color-system.md +420 -0
- package/kit/skills/mobile-design/mobile-debugging.md +122 -0
- package/kit/skills/mobile-design/mobile-design-thinking.md +357 -0
- package/kit/skills/mobile-design/mobile-navigation.md +458 -0
- package/kit/skills/mobile-design/mobile-performance.md +767 -0
- package/kit/skills/mobile-design/mobile-testing.md +356 -0
- package/kit/skills/mobile-design/mobile-typography.md +433 -0
- package/kit/skills/mobile-design/platform-android.md +666 -0
- package/kit/skills/mobile-design/platform-ios.md +561 -0
- package/kit/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/kit/skills/mobile-design/touch-psychology.md +537 -0
- package/kit/skills/negocio-agente-conversa/SKILL.md +168 -0
- package/kit/skills/negocio-atendimento/SKILL.md +134 -0
- package/kit/skills/negocio-linguagem/SKILL.md +166 -0
- package/kit/skills/negocio-preco/SKILL.md +174 -0
- package/kit/skills/negocio-preco/scripts/preco.mjs +160 -0
- package/kit/skills/negocio-qualificacao/SKILL.md +140 -0
- package/kit/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +351 -0
- package/kit/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
- package/kit/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
- package/kit/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
- package/kit/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/kit/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
- package/kit/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
- package/kit/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
- package/kit/skills/nextjs-react-expert/9-cache-components.md +103 -0
- package/kit/skills/nextjs-react-expert/SKILL.md +308 -0
- package/kit/skills/nextjs-react-expert/resources/app-patterns/common-patterns.md +331 -0
- package/kit/skills/nextjs-react-expert/resources/app-patterns/complete-examples.md +872 -0
- package/kit/skills/nextjs-react-expert/resources/app-patterns/component-patterns.md +502 -0
- package/kit/skills/nextjs-react-expert/resources/app-patterns/data-fetching.md +767 -0
- package/kit/skills/nextjs-react-expert/resources/app-patterns/file-organization.md +502 -0
- package/kit/skills/nextjs-react-expert/resources/app-patterns/loading-and-error-states.md +501 -0
- package/kit/skills/nextjs-react-expert/resources/app-patterns/performance.md +406 -0
- package/kit/skills/nextjs-react-expert/resources/app-patterns/routing-guide.md +364 -0
- package/kit/skills/nextjs-react-expert/resources/app-patterns/styling-guide.md +428 -0
- package/kit/skills/nextjs-react-expert/resources/app-patterns/typescript-standards.md +418 -0
- package/kit/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/kit/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/kit/skills/nodejs-best-practices/SKILL.md +78 -0
- package/kit/skills/nodejs-best-practices/references/10-anti-patterns-to-avoid.md +21 -0
- package/kit/skills/nodejs-best-practices/references/11-decision-checklist.md +14 -0
- package/kit/skills/nodejs-best-practices/references/2-runtime-considerations-2025.md +36 -0
- package/kit/skills/nodejs-best-practices/references/3-architecture-principles.md +35 -0
- package/kit/skills/nodejs-best-practices/references/4-error-handling-principles.md +42 -0
- package/kit/skills/nodejs-best-practices/references/5-async-patterns-principles.md +35 -0
- package/kit/skills/nodejs-best-practices/references/6-validation-principles.md +29 -0
- package/kit/skills/nodejs-best-practices/references/7-security-principles.md +29 -0
- package/kit/skills/nodejs-best-practices/references/8-testing-principles.md +28 -0
- package/kit/skills/observability-and-instrumentation/SKILL.md +150 -0
- package/kit/skills/opencode-go-exec/SKILL.md +101 -0
- package/kit/skills/parallel-agents/SKILL.md +184 -0
- package/kit/skills/performance-profiling/SKILL.md +145 -0
- package/kit/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/kit/skills/plan-writing/SKILL.md +213 -0
- package/kit/skills/powershell-windows/SKILL.md +196 -0
- package/kit/skills/provider-orchestration/SKILL.md +269 -0
- package/kit/skills/python-patterns/SKILL.md +80 -0
- package/kit/skills/python-patterns/references/10-decision-checklist.md +14 -0
- package/kit/skills/python-patterns/references/11-anti-patterns-to-avoid.md +20 -0
- package/kit/skills/python-patterns/references/2-async-vs-sync-decision.md +44 -0
- package/kit/skills/python-patterns/references/3-type-hints-strategy.md +56 -0
- package/kit/skills/python-patterns/references/4-project-structure-principles.md +56 -0
- package/kit/skills/python-patterns/references/5-django-principles-2025.md +40 -0
- package/kit/skills/python-patterns/references/6-fastapi-principles.md +50 -0
- package/kit/skills/python-patterns/references/7-background-tasks.md +31 -0
- package/kit/skills/python-patterns/references/8-error-handling-principles.md +29 -0
- package/kit/skills/python-patterns/references/9-testing-principles.md +37 -0
- package/kit/skills/red-team-tactics/SKILL.md +201 -0
- package/kit/skills/research/SKILL.md +166 -0
- package/kit/skills/rust-pro/SKILL.md +177 -0
- package/kit/skills/seo-fundamentals/SKILL.md +130 -0
- package/kit/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/kit/skills/sequential-thinking/.env.example +8 -0
- package/kit/skills/sequential-thinking/README.md +183 -0
- package/kit/skills/sequential-thinking/SKILL.md +95 -0
- package/kit/skills/sequential-thinking/package.json +31 -0
- package/kit/skills/sequential-thinking/references/advanced-strategies.md +79 -0
- package/kit/skills/sequential-thinking/references/advanced-techniques.md +76 -0
- package/kit/skills/sequential-thinking/references/core-patterns.md +95 -0
- package/kit/skills/sequential-thinking/references/examples-api.md +88 -0
- package/kit/skills/sequential-thinking/references/examples-architecture.md +94 -0
- package/kit/skills/sequential-thinking/references/examples-debug.md +90 -0
- package/kit/skills/sequential-thinking/scripts/format-thought.js +159 -0
- package/kit/skills/sequential-thinking/scripts/process-thought.js +236 -0
- package/kit/skills/server-management/SKILL.md +162 -0
- package/kit/skills/simplify-code/SKILL.md +133 -0
- package/kit/skills/skillify/SKILL.md +116 -0
- package/kit/skills/system-design-interview/SKILL.md +268 -0
- package/kit/skills/systematic-debugging/SKILL.md +110 -0
- package/kit/skills/tailwind-patterns/SKILL.md +283 -0
- package/kit/skills/tailwind-patterns/references/shadcn-ui/canvas-design-system.md +320 -0
- package/kit/skills/tailwind-patterns/references/shadcn-ui/shadcn-accessibility.md +471 -0
- package/kit/skills/tailwind-patterns/references/shadcn-ui/shadcn-components.md +424 -0
- package/kit/skills/tailwind-patterns/references/shadcn-ui/shadcn-theming.md +373 -0
- package/kit/skills/tailwind-patterns/references/shadcn-ui/tailwind-customization.md +483 -0
- package/kit/skills/tailwind-patterns/references/shadcn-ui/tailwind-responsive.md +382 -0
- package/kit/skills/tailwind-patterns/references/shadcn-ui/tailwind-utilities.md +455 -0
- package/kit/skills/tdd-workflow/SKILL.md +150 -0
- package/kit/skills/testing-patterns/SKILL.md +196 -0
- package/kit/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/kit/skills/ui-ux-pro-max/SKILL.md +135 -0
- package/kit/skills/verify-changes/SKILL.md +125 -0
- package/kit/skills/vulnerability-scanner/SKILL.md +278 -0
- package/kit/skills/vulnerability-scanner/checklists.md +121 -0
- package/kit/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/kit/skills/web-design-guidelines/SKILL.md +58 -0
- package/kit/skills/webapp-testing/NOTICE.md +6 -0
- package/kit/skills/webapp-testing/SKILL.md +188 -0
- package/kit/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/kit/workflows/brainstorm.md +113 -0
- package/kit/workflows/coordinate.md +72 -0
- package/kit/workflows/create.md +59 -0
- package/kit/workflows/debug.md +103 -0
- package/kit/workflows/deploy.md +176 -0
- package/kit/workflows/enhance.md +63 -0
- package/kit/workflows/orchestrate.md +237 -0
- package/kit/workflows/plan.md +89 -0
- package/kit/workflows/preview.md +81 -0
- package/kit/workflows/remember.md +67 -0
- package/kit/workflows/status.md +86 -0
- package/kit/workflows/test.md +144 -0
- package/kit/workflows/ui-ux-pro-max.md +296 -0
- package/kit/workflows/verify.md +72 -0
- package/licenses/Apache-2.0.txt +202 -0
- package/package.json +60 -6
- package/scripts/avaliar-vigilancia-mandato.mjs +38 -0
- package/scripts/bundle.mjs +158 -0
- package/scripts/check-deps.mjs +178 -0
- package/scripts/check-models.mjs +150 -0
- package/scripts/cli.mjs +295 -0
- package/scripts/continuidade-mandato.mjs +47 -0
- package/scripts/discriminar-turno.mjs +191 -0
- package/scripts/doctor.mjs +615 -0
- package/scripts/generate.mjs +676 -0
- package/scripts/install.mjs +11 -0
- package/scripts/layer-remote.mjs +344 -0
- package/scripts/layers.mjs +208 -0
- package/scripts/marketplace.mjs +77 -0
- package/scripts/product.mjs +32 -0
- package/scripts/ruleset-core.mjs +68 -0
- package/scripts/social-hooks.mjs +293 -0
- package/scripts/social-pacer.mjs +219 -0
- package/scripts/validate-bundles.mjs +14 -0
- package/scripts/validate-skills.mjs +174 -0
- package/scripts/zenkit-daemon-task.cmd +3 -0
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ZenKit dual-target generator (ADR-0001 guard-rail #3).
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth = `kit/`. Emits consumable trees:
|
|
6
|
+
* - `<target>/.cursor/{rules,agents,skills,workflows,commands}` (Cursor)
|
|
7
|
+
* - `<target>/.claude/{skills,agents,commands}` + CLAUDE.md (Claude Code)
|
|
8
|
+
* - `<target>/AGENTS.md` ROOT (Codex / Agent Skills; skipped when target is $HOME)
|
|
9
|
+
* - `<target>/.codex/AGENTS.md` (Codex global)
|
|
10
|
+
* - `<target>/.agents/skills` (Agent Skills spec — Codex, Gemini CLI,
|
|
11
|
+
* Copilot, OpenCode, Windsurf lêem este path ou um alias dele)
|
|
12
|
+
*
|
|
13
|
+
* No external deps. Pure copy + light frontmatter adaptation so the same
|
|
14
|
+
* authored content serves Cursor, Claude Code, Codex and the Agent Skills spec
|
|
15
|
+
* without duplicating the source in `kit/`.
|
|
16
|
+
*
|
|
17
|
+
* Cursor cost policy (hard): every agent under `.cursor/agents/` is rewritten
|
|
18
|
+
* to `model: composer-2.5`. Fable / premium ids in kit source must never reach
|
|
19
|
+
* Cursor (they burn included tokens). Claude agents keep kit frontmatter as-is.
|
|
20
|
+
*
|
|
21
|
+
* Usage: node scripts/generate.mjs [--target <dir>] [--bundle <nome>] [--plugins]
|
|
22
|
+
* sem --bundle: emite o kit inteiro (comportamento histórico)
|
|
23
|
+
* com --bundle: emite só skills/agentes daquele recorte (kit/bundles/<nome>.yaml)
|
|
24
|
+
* --plugins: emite pacotes nativos (Cursor + Claude + Agent Plugins) em plugins/
|
|
25
|
+
*/
|
|
26
|
+
import { promises as fs } from "node:fs";
|
|
27
|
+
import { appendFileSync } from "node:fs";
|
|
28
|
+
import os from "node:os";
|
|
29
|
+
import path from "node:path";
|
|
30
|
+
import { fileURLToPath } from "node:url";
|
|
31
|
+
import { loadBundleFiles, resolveBundle } from "./bundle.mjs";
|
|
32
|
+
import { extractRulesetCore } from "./ruleset-core.mjs";
|
|
33
|
+
import { applySlots, layerDirsFromEnv, loadLayers, loadModules, mergeSources } from "./layers.mjs";
|
|
34
|
+
import { resolveLayerSpecs } from "./layer-remote.mjs";
|
|
35
|
+
import {
|
|
36
|
+
AGENT_PLUGIN_SCHEMA,
|
|
37
|
+
AUTHOR,
|
|
38
|
+
kitVersion,
|
|
39
|
+
pluginId,
|
|
40
|
+
storefrontBundles,
|
|
41
|
+
} from "./product.mjs";
|
|
42
|
+
|
|
43
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
44
|
+
const KIT = path.join(ROOT, "kit");
|
|
45
|
+
/** Only allowed Cursor agent model — see kit/rules/model-routing.mdc. */
|
|
46
|
+
const CURSOR_AGENT_MODEL = "composer-2.5";
|
|
47
|
+
|
|
48
|
+
/** Timing traces file-system cleanup, which is where Windows watchers bite. */
|
|
49
|
+
const dbg = (...parts) => {
|
|
50
|
+
if (process.env.GEN_DEBUG) {
|
|
51
|
+
try {
|
|
52
|
+
appendFileSync(path.join(ROOT, "gen-debug.log"), `[gen ${Date.now() % 100000}] ${parts.join(" ")}\n`);
|
|
53
|
+
} catch {
|
|
54
|
+
// Diagnostics only: never fail the run.
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
dbg("module body loaded");
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Windows watchers (IDE/LSP/dev servers) pin handles on freshly generated
|
|
62
|
+
* subtrees, so plain rm() fails with EPERM for minutes. fs.rm's own maxRetries
|
|
63
|
+
* wedges indefinitely on this Windows/Node 20 combo, so fail fast and escalate:
|
|
64
|
+
* 1. plain rm
|
|
65
|
+
* 2. rename-then-rm — renames detach path-based watchers, and the renamed
|
|
66
|
+
* tree deletes fine (verified empirically)
|
|
67
|
+
* 3. if even the rename of the parent is blocked (watcher holds the dir
|
|
68
|
+
* itself), clear every child the same way and reuse the now-empty parent
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* Windows checkouts of `kit/` carry the READONLY bit on directories (origin:
|
|
72
|
+
* checkout artifact), which fs.copyFile propagates into generated trees and
|
|
73
|
+
* fs.rm refuses to delete ("EPERM: operation not permitted, rmdir"). First
|
|
74
|
+
* EPERM: strip the attribute recursively, then retry immediately.
|
|
75
|
+
*/
|
|
76
|
+
async function clearReadOnly(p) {
|
|
77
|
+
const st = await fs.stat(p);
|
|
78
|
+
await fs.chmod(p, st.isDirectory() ? 0o777 : 0o666);
|
|
79
|
+
if (!st.isDirectory()) return;
|
|
80
|
+
for (const entry of await fs.readdir(p, { withFileTypes: true })) {
|
|
81
|
+
await clearReadOnly(path.join(p, entry.name));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function rmTree(p, { bestEffort = false } = {}) {
|
|
86
|
+
let roCleared = false;
|
|
87
|
+
for (let attempt = 0; ; attempt++) {
|
|
88
|
+
dbg("rm", p, "attempt", attempt);
|
|
89
|
+
try {
|
|
90
|
+
await fs.rm(p, { recursive: true, force: true });
|
|
91
|
+
dbg("rm ok", p);
|
|
92
|
+
return true;
|
|
93
|
+
} catch (err) {
|
|
94
|
+
dbg("rm fail", p, err.code, "attempt", attempt);
|
|
95
|
+
if ((err.code !== "EPERM" && err.code !== "EBUSY") || attempt > 7) {
|
|
96
|
+
if (bestEffort) return false;
|
|
97
|
+
throw err;
|
|
98
|
+
}
|
|
99
|
+
if (err.code === "EPERM" && !roCleared) {
|
|
100
|
+
roCleared = true;
|
|
101
|
+
try {
|
|
102
|
+
await clearReadOnly(p);
|
|
103
|
+
dbg("rm clearRO", p);
|
|
104
|
+
} catch {
|
|
105
|
+
// Attribute strip is best effort; the retry loop still applies.
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async function rmTreeResilient(p) {
|
|
114
|
+
dbg("rmx enter", p);
|
|
115
|
+
if (await rmTree(p, { bestEffort: true })) return true;
|
|
116
|
+
|
|
117
|
+
const stale = `${p}.stale-${Date.now()}`;
|
|
118
|
+
dbg("rmx rename", p, "->", stale);
|
|
119
|
+
try {
|
|
120
|
+
await fs.rename(p, stale);
|
|
121
|
+
} catch {
|
|
122
|
+
dbg("rmx parent-pinned, clearing children of", p);
|
|
123
|
+
// Parent itself is pinned: detach and delete every child instead.
|
|
124
|
+
let entries = [];
|
|
125
|
+
try {
|
|
126
|
+
entries = await fs.readdir(p, { withFileTypes: true });
|
|
127
|
+
dbg("rmx children-of", p, entries.length);
|
|
128
|
+
} catch {
|
|
129
|
+
return true; // unreadable/gone — leave it to the next run
|
|
130
|
+
}
|
|
131
|
+
for (const entry of entries) {
|
|
132
|
+
dbg("rmx child", path.join(p, entry.name));
|
|
133
|
+
if (!(await rmTreeResilient(path.join(p, entry.name)))) {
|
|
134
|
+
console.error(`generate: watcher lock survived cleanup of ${path.join(p, entry.name)}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
dbg("rmx final parent rm", p);
|
|
138
|
+
await rmTree(p, { bestEffort: true }); // empty parent is fine to reuse
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
dbg("rmx rm-stale", stale);
|
|
142
|
+
if (!(await rmTree(stale, { bestEffort: true }))) {
|
|
143
|
+
console.error(`generate: watcher lock held removal of stale tree: ${stale}`);
|
|
144
|
+
}
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function parseArgs(argv) {
|
|
149
|
+
let target = path.join(ROOT, ".preview");
|
|
150
|
+
let bundle = null;
|
|
151
|
+
let plugins = false;
|
|
152
|
+
const layers = [];
|
|
153
|
+
for (let i = 0; i < argv.length; i++) {
|
|
154
|
+
if (argv[i] === "--target" && argv[i + 1]) {
|
|
155
|
+
target = path.resolve(argv[++i]);
|
|
156
|
+
} else if (argv[i] === "--bundle" && argv[i + 1]) {
|
|
157
|
+
bundle = argv[++i];
|
|
158
|
+
} else if (argv[i] === "--layer" && argv[i + 1]) {
|
|
159
|
+
layers.push(path.resolve(argv[++i]));
|
|
160
|
+
} else if (argv[i] === "--plugins") {
|
|
161
|
+
plugins = true;
|
|
162
|
+
} else if (argv[i].startsWith("-")) {
|
|
163
|
+
throw new Error(`flag desconhecida: ${argv[i]}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return { target, bundle, plugins, layers };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export const OWNED_MANIFEST = ".zenkit-owned.json";
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Remove the entries this generator is about to write plus the ones its last
|
|
173
|
+
* run recorded in OWNED_MANIFEST, then record the new set. Anything else in the
|
|
174
|
+
* folder belongs to someone else and stays.
|
|
175
|
+
*/
|
|
176
|
+
async function cleanOwned(dir, names) {
|
|
177
|
+
let previous = [];
|
|
178
|
+
try {
|
|
179
|
+
previous = JSON.parse(await fs.readFile(path.join(dir, OWNED_MANIFEST), "utf8")).entries ?? [];
|
|
180
|
+
} catch {
|
|
181
|
+
// First run with ownership tracking: only the current names are ours for sure.
|
|
182
|
+
}
|
|
183
|
+
for (const name of new Set([...previous, ...names])) {
|
|
184
|
+
if (typeof name !== "string" || !name || name !== path.basename(name) || name === "..") continue;
|
|
185
|
+
await rmTreeResilient(path.join(dir, name));
|
|
186
|
+
}
|
|
187
|
+
await fs.mkdir(dir, { recursive: true });
|
|
188
|
+
await writeJson(path.join(dir, OWNED_MANIFEST), { generator: "zenkit", entries: [...names].sort() });
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function writeJson(file, obj) {
|
|
192
|
+
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
193
|
+
await fs.writeFile(file, JSON.stringify(obj, null, 2) + "\n");
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async function copyTree(src, dst) {
|
|
197
|
+
await fs.mkdir(dst, { recursive: true });
|
|
198
|
+
// Dest dirs must stay writable: SOURCE dirs can carry READONLY, which would
|
|
199
|
+
// make the next run's cleanup hit EPERM on Windows.
|
|
200
|
+
await fs.chmod(dst, 0o755);
|
|
201
|
+
for (const entry of await fs.readdir(src, { withFileTypes: true })) {
|
|
202
|
+
const s = path.join(src, entry.name);
|
|
203
|
+
const d = path.join(dst, entry.name);
|
|
204
|
+
if (entry.isDirectory()) await copyTree(s, d);
|
|
205
|
+
else {
|
|
206
|
+
await fs.copyFile(s, d);
|
|
207
|
+
await fs.chmod(d, 0o666);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Read frontmatter (--- ... ---) + body from a markdown file. */
|
|
213
|
+
function splitFrontmatter(text) {
|
|
214
|
+
text = text.replace(/\r\n/g, "\n");
|
|
215
|
+
const m = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(text);
|
|
216
|
+
if (!m) return { fm: {}, body: text, fmRaw: null };
|
|
217
|
+
const fm = {};
|
|
218
|
+
for (const line of m[1].split("\n")) {
|
|
219
|
+
const kv = /^([A-Za-z0-9_]+):\s*(.*)$/.exec(line);
|
|
220
|
+
if (kv) fm[kv[1]] = kv[2];
|
|
221
|
+
}
|
|
222
|
+
return { fm, body: m[2], fmRaw: m[1] };
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Claude skills need a `description`; Cursor authoring may use `when_to_use`. */
|
|
226
|
+
function toClaudeSkill(text, name) {
|
|
227
|
+
const { fm, body } = splitFrontmatter(text);
|
|
228
|
+
const description = fm.description || fm.when_to_use || `ZenKit skill: ${name}`;
|
|
229
|
+
const front = `---\nname: ${fm.name || name}\ndescription: ${description}\n---\n`;
|
|
230
|
+
return front + (body.startsWith("\n") ? body : "\n" + body);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Pin Cursor agent frontmatter to composer-2.5.
|
|
235
|
+
* Fable (and any other non-composer pin) in kit source is a hard error — the
|
|
236
|
+
* leak that burned Cursor included tokens (2026-07-26) came from agent YAML.
|
|
237
|
+
*/
|
|
238
|
+
function toCursorAgent(text, fileLabel) {
|
|
239
|
+
const { fm, body, fmRaw } = splitFrontmatter(text);
|
|
240
|
+
if (fmRaw == null) {
|
|
241
|
+
throw new Error(`Cursor agent ${fileLabel}: missing YAML frontmatter`);
|
|
242
|
+
}
|
|
243
|
+
const declared = (fm.model || "").trim();
|
|
244
|
+
if (/fable/i.test(declared)) {
|
|
245
|
+
throw new Error(
|
|
246
|
+
`Cursor policy violation: ${fileLabel} declares model '${declared}'. ` +
|
|
247
|
+
`Fable is forbidden on Cursor (use 'inherit' in kit/; generator pins ${CURSOR_AGENT_MODEL}).`,
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
if (declared && declared !== "inherit" && declared !== CURSOR_AGENT_MODEL) {
|
|
251
|
+
throw new Error(
|
|
252
|
+
`Cursor policy violation: ${fileLabel} declares model '${declared}'. ` +
|
|
253
|
+
`Kit agents must use 'inherit' (Claude dual-target) or ${CURSOR_AGENT_MODEL}; ` +
|
|
254
|
+
`generator always emits ${CURSOR_AGENT_MODEL} for .cursor/agents/.`,
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
const lines = fmRaw.split("\n").map((line) => {
|
|
258
|
+
if (/^model:\s*/.test(line)) return `model: ${CURSOR_AGENT_MODEL}`;
|
|
259
|
+
return line;
|
|
260
|
+
});
|
|
261
|
+
if (!/^model:\s*/m.test(fmRaw)) {
|
|
262
|
+
lines.push(`model: ${CURSOR_AGENT_MODEL}`);
|
|
263
|
+
}
|
|
264
|
+
const front = `---\n${lines.join("\n")}\n---\n`;
|
|
265
|
+
return front + (body.startsWith("\n") ? body : "\n" + body);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** Core skills (optionally filtered by a bundle) as name -> source dir. */
|
|
269
|
+
async function coreSkillSources(allowSkills) {
|
|
270
|
+
const srcSkills = path.join(KIT, "skills");
|
|
271
|
+
const sources = new Map();
|
|
272
|
+
for (const entry of await fs.readdir(srcSkills, { withFileTypes: true })) {
|
|
273
|
+
if (!entry.isDirectory()) continue;
|
|
274
|
+
if (allowSkills && !allowSkills.has(entry.name)) continue;
|
|
275
|
+
sources.set(entry.name, path.join(srcSkills, entry.name));
|
|
276
|
+
}
|
|
277
|
+
return sources;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Core agents (optionally filtered by a bundle) as stem -> source file. */
|
|
281
|
+
async function coreAgentSources(allowAgents) {
|
|
282
|
+
const srcAgents = path.join(KIT, "agents");
|
|
283
|
+
const sources = new Map();
|
|
284
|
+
for (const entry of await fs.readdir(srcAgents, { withFileTypes: true })) {
|
|
285
|
+
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
286
|
+
const stem = entry.name.replace(/\.md$/, "");
|
|
287
|
+
if (allowAgents && !allowAgents.has(stem)) continue;
|
|
288
|
+
sources.set(stem, path.join(srcAgents, entry.name));
|
|
289
|
+
}
|
|
290
|
+
return sources;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
async function emitCursorAgentsTo(dstAgents, agentSources) {
|
|
294
|
+
await fs.mkdir(dstAgents, { recursive: true });
|
|
295
|
+
for (const [stem, srcFile] of agentSources) {
|
|
296
|
+
const fileName = `${stem}.md`;
|
|
297
|
+
const raw = await fs.readFile(srcFile, "utf8");
|
|
298
|
+
const out = toCursorAgent(raw, fileName);
|
|
299
|
+
await fs.writeFile(path.join(dstAgents, fileName), out);
|
|
300
|
+
// Belt-and-suspenders: never emit fable into Cursor tree.
|
|
301
|
+
if (/fable/i.test(out)) {
|
|
302
|
+
throw new Error(`Cursor agent emit leaked 'fable' in ${fileName}`);
|
|
303
|
+
}
|
|
304
|
+
const { fm } = splitFrontmatter(out);
|
|
305
|
+
if (fm.model !== CURSOR_AGENT_MODEL) {
|
|
306
|
+
throw new Error(
|
|
307
|
+
`Cursor agent ${fileName}: expected model ${CURSOR_AGENT_MODEL}, got '${fm.model}'`,
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
async function emitCursorAgents(target, agentSources) {
|
|
314
|
+
await emitCursorAgentsTo(path.join(target, ".cursor", "agents"), agentSources);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
async function emitAdaptedSkills(dstSkills, skillSources) {
|
|
318
|
+
await fs.mkdir(dstSkills, { recursive: true });
|
|
319
|
+
for (const [name, srcDir] of skillSources) {
|
|
320
|
+
const dstDir = path.join(dstSkills, name);
|
|
321
|
+
await copyTree(srcDir, dstDir);
|
|
322
|
+
const skillMd = path.join(srcDir, "SKILL.md");
|
|
323
|
+
try {
|
|
324
|
+
const raw = await fs.readFile(skillMd, "utf8");
|
|
325
|
+
await fs.writeFile(path.join(dstDir, "SKILL.md"), toClaudeSkill(raw, name));
|
|
326
|
+
} catch {
|
|
327
|
+
/* skill without SKILL.md — leave copied content as-is */
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
async function emitClaudeSkills(target, skillSources) {
|
|
333
|
+
await emitAdaptedSkills(path.join(target, ".claude", "skills"), skillSources);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
async function emitAgentsSkills(target, skillSources) {
|
|
337
|
+
await emitAdaptedSkills(path.join(target, ".agents", "skills"), skillSources);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async function readRulesetAppend() {
|
|
341
|
+
const rulesetSource = process.env.ZENKIT_RULESET_SOURCE;
|
|
342
|
+
if (!rulesetSource) return "";
|
|
343
|
+
try {
|
|
344
|
+
await fs.access(rulesetSource);
|
|
345
|
+
} catch {
|
|
346
|
+
return "";
|
|
347
|
+
}
|
|
348
|
+
const sourceBody = await fs.readFile(rulesetSource, "utf8");
|
|
349
|
+
const lockPath = path.join(path.dirname(rulesetSource), "ruleset.lock.json");
|
|
350
|
+
let version = "unknown";
|
|
351
|
+
try {
|
|
352
|
+
const lock = JSON.parse(await fs.readFile(lockPath, "utf8"));
|
|
353
|
+
if (lock.version != null && lock.version !== "") version = String(lock.version);
|
|
354
|
+
} catch {
|
|
355
|
+
/* lock optional */
|
|
356
|
+
}
|
|
357
|
+
const basename = path.basename(rulesetSource);
|
|
358
|
+
const core = extractRulesetCore(sourceBody);
|
|
359
|
+
if (core === null) {
|
|
360
|
+
process.stderr.write(
|
|
361
|
+
`[generate] ${basename}: seção esperada do núcleo não encontrada; anexando o ruleset inteiro.\n`,
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
return (
|
|
365
|
+
`\n\n---\n\n## Ruleset global (NexusCore v${version})\n\n` +
|
|
366
|
+
(core === null
|
|
367
|
+
? `> Copiado de ${basename} pelo gerador. Fonte canônica: NexusCore \`agents/ruleset\`.\n\n`
|
|
368
|
+
: `> Núcleo de ${basename} extraído pelo gerador. Fonte canônica: NexusCore \`agents/ruleset\`.\n\n`) +
|
|
369
|
+
(core ?? sourceBody)
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const GENERATED_MARK = "Gerado de `kit/rules/ZENKIT.mdc`";
|
|
374
|
+
|
|
375
|
+
function samePath(a, b) {
|
|
376
|
+
const norm = (p) => path.resolve(p).replace(/[\\/]+$/, "");
|
|
377
|
+
return process.platform === "win32"
|
|
378
|
+
? norm(a).toLowerCase() === norm(b).toLowerCase()
|
|
379
|
+
: norm(a) === norm(b);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* A $HOME target must not get a root AGENTS.md. Codex reads its global from
|
|
384
|
+
* ~/.codex/AGENTS.md (emitted below), while Claude Code and OpenCode load
|
|
385
|
+
* ~/AGENTS.md as the "project" file of any session opened in $HOME, next to
|
|
386
|
+
* ~/.claude/CLAUDE.md: ZENKIT entered the context twice (DEM-ZEN-BUG-153).
|
|
387
|
+
* A stale copy from older runs is removed only if this generator wrote it.
|
|
388
|
+
*/
|
|
389
|
+
async function dropHomeRootAgents(target) {
|
|
390
|
+
const rootAgents = path.join(target, "AGENTS.md");
|
|
391
|
+
let content;
|
|
392
|
+
try {
|
|
393
|
+
content = await fs.readFile(rootAgents, "utf8");
|
|
394
|
+
} catch {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (content.includes(GENERATED_MARK)) await fs.rm(rootAgents, { force: true });
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** Cursor reads ZENKIT.mdc itself: write it with the slots filled, never with the markers. */
|
|
401
|
+
async function writeCursorMasterRule(rulesDir, layers = []) {
|
|
402
|
+
const master = await fs.readFile(path.join(KIT, "rules", "ZENKIT.mdc"), "utf8");
|
|
403
|
+
// Layer sections arrive with their own line endings; keep the file in the kit's one.
|
|
404
|
+
const rendered = applySlots(master.replace(/\r\n/g, "\n"), layers);
|
|
405
|
+
const eol = master.includes("\r\n") ? "\r\n" : "\n";
|
|
406
|
+
await fs.writeFile(path.join(rulesDir, "ZENKIT.mdc"), rendered.replace(/\n/g, eol));
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
async function writeClaudeMd(target, homeDir = os.homedir(), layers = []) {
|
|
410
|
+
const atHome = samePath(target, homeDir);
|
|
411
|
+
if (atHome) await dropHomeRootAgents(target);
|
|
412
|
+
const masterPath = path.join(KIT, "rules", "ZENKIT.mdc");
|
|
413
|
+
const master = await fs.readFile(masterPath, "utf8");
|
|
414
|
+
const body = applySlots(splitFrontmatter(master).body, layers);
|
|
415
|
+
await fs.mkdir(path.join(target, ".claude"), { recursive: true });
|
|
416
|
+
await fs.mkdir(path.join(target, ".codex"), { recursive: true });
|
|
417
|
+
const rulesetAppend = await readRulesetAppend();
|
|
418
|
+
// One rendered body, several consumer entry points (every platform reads the
|
|
419
|
+
// same master): Claude Code reads .claude/CLAUDE.md; Codex and the Agent
|
|
420
|
+
// Skills ecosystem read AGENTS.md at the target root; Codex global reads
|
|
421
|
+
// ~/.codex/AGENTS.md when generate --target points at the home directory.
|
|
422
|
+
const headers = [
|
|
423
|
+
{
|
|
424
|
+
file: path.join(target, ".claude", "CLAUDE.md"),
|
|
425
|
+
title: "ZenKit — Claude Code",
|
|
426
|
+
append: rulesetAppend,
|
|
427
|
+
},
|
|
428
|
+
...(atHome ? [] : [{ file: path.join(target, "AGENTS.md"), title: "ZenKit — Codex" }]),
|
|
429
|
+
{ file: path.join(target, "GEMINI.md"), title: "ZenKit \u2014 Antigravity / Gemini" },
|
|
430
|
+
{
|
|
431
|
+
file: path.join(target, ".codex", "AGENTS.md"),
|
|
432
|
+
title: "ZenKit — Codex (global)",
|
|
433
|
+
append: rulesetAppend,
|
|
434
|
+
},
|
|
435
|
+
];
|
|
436
|
+
for (const { file, title, append } of headers) {
|
|
437
|
+
const header =
|
|
438
|
+
`# ${title}\n\n` +
|
|
439
|
+
"> Gerado de `kit/rules/ZENKIT.mdc` (fonte única). Não editar à mão.\n\n";
|
|
440
|
+
const extra = append ?? "";
|
|
441
|
+
await fs.writeFile(file, header + body.trimStart() + extra);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
async function copySelectedSkillDirs(dstSkills, skillSources) {
|
|
446
|
+
await fs.mkdir(dstSkills, { recursive: true });
|
|
447
|
+
for (const [name, srcDir] of skillSources) {
|
|
448
|
+
await copyTree(srcDir, path.join(dstSkills, name));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
async function copySelectedAgents(dstAgents, agentSources) {
|
|
453
|
+
await fs.mkdir(dstAgents, { recursive: true });
|
|
454
|
+
for (const [stem, srcFile] of agentSources) {
|
|
455
|
+
await fs.copyFile(srcFile, path.join(dstAgents, `${stem}.md`));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Pacote nativo por recorte. Cursor e Claude não compartilham agents/:
|
|
461
|
+
* Cursor pinna composer-2.5; Claude mantém o frontmatter do kit.
|
|
462
|
+
*/
|
|
463
|
+
export async function emitPluginPackage({ dest, bundle }) {
|
|
464
|
+
if (!bundle) throw new Error("emitPluginPackage exige bundle");
|
|
465
|
+
const byName = await loadBundleFiles();
|
|
466
|
+
const meta = resolveBundle(bundle, byName);
|
|
467
|
+
const id = pluginId(bundle);
|
|
468
|
+
const version = await kitVersion();
|
|
469
|
+
const description = meta.description || meta.title;
|
|
470
|
+
const cursorDest = path.join(dest, "cursor");
|
|
471
|
+
const claudeDest = path.join(dest, "claude");
|
|
472
|
+
|
|
473
|
+
await rmTreeResilient(dest);
|
|
474
|
+
|
|
475
|
+
await writeJson(path.join(cursorDest, ".cursor-plugin", "plugin.json"), {
|
|
476
|
+
name: id,
|
|
477
|
+
description,
|
|
478
|
+
version,
|
|
479
|
+
author: AUTHOR,
|
|
480
|
+
});
|
|
481
|
+
for (const layer of ["rules", "workflows", "commands"]) {
|
|
482
|
+
await copyTree(path.join(KIT, layer), path.join(cursorDest, layer));
|
|
483
|
+
}
|
|
484
|
+
await writeCursorMasterRule(path.join(cursorDest, "rules"));
|
|
485
|
+
// Plugin packages ship the public core only: user layers stay private.
|
|
486
|
+
const skillSources = await coreSkillSources(meta.skills);
|
|
487
|
+
const agentSources = await coreAgentSources(meta.agents);
|
|
488
|
+
await copySelectedSkillDirs(path.join(cursorDest, "skills"), skillSources);
|
|
489
|
+
await emitCursorAgentsTo(path.join(cursorDest, "agents"), agentSources);
|
|
490
|
+
|
|
491
|
+
await writeJson(path.join(claudeDest, ".claude-plugin", "plugin.json"), {
|
|
492
|
+
name: id,
|
|
493
|
+
description,
|
|
494
|
+
version,
|
|
495
|
+
author: AUTHOR,
|
|
496
|
+
});
|
|
497
|
+
await writeJson(path.join(claudeDest, "plugin.json"), {
|
|
498
|
+
$schema: AGENT_PLUGIN_SCHEMA,
|
|
499
|
+
name: id,
|
|
500
|
+
description,
|
|
501
|
+
version,
|
|
502
|
+
author: AUTHOR,
|
|
503
|
+
});
|
|
504
|
+
await emitAdaptedSkills(path.join(claudeDest, "skills"), skillSources);
|
|
505
|
+
await copySelectedAgents(path.join(claudeDest, "agents"), agentSources);
|
|
506
|
+
await copyTree(path.join(KIT, "commands"), path.join(claudeDest, "commands"));
|
|
507
|
+
|
|
508
|
+
// Third-party licenses require their notices to travel with every copy.
|
|
509
|
+
for (const pkg of [cursorDest, claudeDest]) {
|
|
510
|
+
for (const file of ["LICENSE", "NOTICE", "THIRD-PARTY-NOTICES.md"]) {
|
|
511
|
+
await fs.copyFile(path.join(ROOT, file), path.join(pkg, file));
|
|
512
|
+
}
|
|
513
|
+
await copyTree(path.join(ROOT, "licenses"), path.join(pkg, "licenses"));
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
return { id, title: meta.title, description, cursorDest, claudeDest, meta };
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export async function emitStorefrontPlugins(destRoot = path.join(ROOT, "plugins")) {
|
|
520
|
+
const byName = await loadBundleFiles();
|
|
521
|
+
const list = storefrontBundles(byName);
|
|
522
|
+
if (list.length === 0) {
|
|
523
|
+
throw new Error("nenhum bundle kind: storefront — nada a emitir como plugin");
|
|
524
|
+
}
|
|
525
|
+
await rmTreeResilient(destRoot);
|
|
526
|
+
const emitted = [];
|
|
527
|
+
for (const b of list) {
|
|
528
|
+
const one = await emitPluginPackage({
|
|
529
|
+
dest: path.join(destRoot, b.name),
|
|
530
|
+
bundle: b.name,
|
|
531
|
+
});
|
|
532
|
+
emitted.push(one);
|
|
533
|
+
process.stdout.write(
|
|
534
|
+
` plugin ${one.id} (${b.name}) → ${path.join(destRoot, b.name)}\n`,
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
return emitted;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
export async function generateKit({ target, bundle, homeDir, layers }) {
|
|
541
|
+
let allowSkills = null;
|
|
542
|
+
let allowAgents = null;
|
|
543
|
+
let bundleMeta = null;
|
|
544
|
+
if (bundle) {
|
|
545
|
+
const byName = await loadBundleFiles();
|
|
546
|
+
bundleMeta = resolveBundle(bundle, byName);
|
|
547
|
+
allowSkills = bundleMeta.skills;
|
|
548
|
+
allowAgents = bundleMeta.agents;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// Resolve layers before touching the target: a conflict must fail while the
|
|
552
|
+
// existing install is still intact.
|
|
553
|
+
const layerSpecs = layers && layers.length ? layers : layerDirsFromEnv();
|
|
554
|
+
const userLayers = await loadLayers(await resolveLayerSpecs(layerSpecs));
|
|
555
|
+
const { modules, unknown: unknownModules } = await loadModules(path.join(KIT, "modules"), userLayers);
|
|
556
|
+
const loadedLayers = [...modules, ...userLayers];
|
|
557
|
+
const skillSources = mergeSources(await coreSkillSources(allowSkills), loadedLayers, "skills");
|
|
558
|
+
const agentSources = mergeSources(await coreAgentSources(allowAgents), loadedLayers, "agents");
|
|
559
|
+
const coreRules = new Map(
|
|
560
|
+
(await fs.readdir(path.join(KIT, "rules")))
|
|
561
|
+
.filter((f) => f.endsWith(".mdc"))
|
|
562
|
+
.map((f) => [f.slice(0, -".mdc".length), path.join(KIT, "rules", f)]),
|
|
563
|
+
);
|
|
564
|
+
const ruleSources = mergeSources(coreRules, loadedLayers, "rules");
|
|
565
|
+
|
|
566
|
+
// Sweep rename-fallback detritus from previous runs (best effort).
|
|
567
|
+
try {
|
|
568
|
+
for (const entry of await fs.readdir(target, { withFileTypes: true })) {
|
|
569
|
+
if (entry.isDirectory() && entry.name.includes(".stale-")) {
|
|
570
|
+
await rmTreeResilient(path.join(target, entry.name));
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
} catch {
|
|
574
|
+
// Clean checkout: nothing to sweep yet.
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// Clean only what this generator wrote. Never wipe the whole .claude/.cursor/
|
|
578
|
+
// .agents dir (at $HOME it holds transcripts, settings, credentials, MCP config),
|
|
579
|
+
// and not even a whole subtree: other tools share them (Cursor drops its own
|
|
580
|
+
// skills in ~/.agents/skills).
|
|
581
|
+
const kitEntries = async (dir) => fs.readdir(path.join(KIT, dir));
|
|
582
|
+
const skillNames = [...skillSources.keys()];
|
|
583
|
+
const agentFiles = [...agentSources.keys()].map((stem) => `${stem}.md`);
|
|
584
|
+
const ruleFiles = [...new Set([...(await kitEntries("rules")), ...[...ruleSources.keys()].map((n) => `${n}.mdc`)])];
|
|
585
|
+
const owned = [
|
|
586
|
+
[[".cursor", "rules"], ruleFiles],
|
|
587
|
+
...(await Promise.all(
|
|
588
|
+
["workflows", "commands"].map(async (d) => [[".cursor", d], await kitEntries(d)]),
|
|
589
|
+
)),
|
|
590
|
+
[[".cursor", "skills"], skillNames],
|
|
591
|
+
[[".cursor", "agents"], agentFiles],
|
|
592
|
+
[[".claude", "skills"], skillNames],
|
|
593
|
+
[[".claude", "agents"], agentFiles],
|
|
594
|
+
[[".claude", "commands"], await kitEntries("commands")],
|
|
595
|
+
[[".agents", "skills"], skillNames],
|
|
596
|
+
];
|
|
597
|
+
for (const [parts, names] of owned) {
|
|
598
|
+
await cleanOwned(path.join(target, ...parts), names);
|
|
599
|
+
}
|
|
600
|
+
await fs.mkdir(path.join(target, ".claude"), { recursive: true });
|
|
601
|
+
await fs.mkdir(path.join(target, ".agents"), { recursive: true });
|
|
602
|
+
|
|
603
|
+
// Cursor: rules/workflows/commands sempre; skills/agentes filtrados pelo bundle.
|
|
604
|
+
for (const layer of ["rules", "workflows", "commands"]) {
|
|
605
|
+
await copyTree(path.join(KIT, layer), path.join(target, ".cursor", layer));
|
|
606
|
+
}
|
|
607
|
+
for (const [name, src] of ruleSources) {
|
|
608
|
+
if (src !== coreRules.get(name)) {
|
|
609
|
+
await fs.copyFile(src, path.join(target, ".cursor", "rules", `${name}.mdc`));
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
await writeCursorMasterRule(path.join(target, ".cursor", "rules"), loadedLayers);
|
|
613
|
+
await copySelectedSkillDirs(path.join(target, ".cursor", "skills"), skillSources);
|
|
614
|
+
await emitCursorAgents(target, agentSources);
|
|
615
|
+
|
|
616
|
+
await emitClaudeSkills(target, skillSources);
|
|
617
|
+
await emitAgentsSkills(target, skillSources);
|
|
618
|
+
await copySelectedAgents(path.join(target, ".claude", "agents"), agentSources);
|
|
619
|
+
await copyTree(path.join(KIT, "commands"), path.join(target, ".claude", "commands"));
|
|
620
|
+
await writeClaudeMd(target, homeDir, loadedLayers);
|
|
621
|
+
|
|
622
|
+
const count = async (p) =>
|
|
623
|
+
(await fs.readdir(p).catch(() => [])).filter((n) => n !== OWNED_MANIFEST).length;
|
|
624
|
+
const bundleLine = bundleMeta
|
|
625
|
+
? ` bundle: ${bundleMeta.name} (${bundleMeta.title}) — ${allowSkills.size} skills, ${allowAgents.size} agents\n`
|
|
626
|
+
: " bundle: (kit inteiro)\n";
|
|
627
|
+
const layerLine =
|
|
628
|
+
(userLayers.length ? ` camadas: ${userLayers.map((l) => l.name).join(", ")}\n` : "") +
|
|
629
|
+
(modules.length ? ` módulos: ${modules.map((m) => m.name).join(", ")}\n` : "") +
|
|
630
|
+
(unknownModules.length
|
|
631
|
+
? ` módulos pedidos que o kit não traz (ignorados): ${unknownModules.join(", ")}\n`
|
|
632
|
+
: "");
|
|
633
|
+
process.stdout.write(
|
|
634
|
+
`ZenKit generated -> ${target}\n` +
|
|
635
|
+
bundleLine +
|
|
636
|
+
layerLine +
|
|
637
|
+
` .cursor/skills: ${await count(path.join(target, ".cursor/skills"))}` +
|
|
638
|
+
` agents: ${await count(path.join(target, ".cursor/agents"))}` +
|
|
639
|
+
` rules: ${await count(path.join(target, ".cursor/rules"))}\n` +
|
|
640
|
+
` .claude/skills: ${await count(path.join(target, ".claude/skills"))}` +
|
|
641
|
+
` agents: ${await count(path.join(target, ".claude/agents"))}` +
|
|
642
|
+
` + CLAUDE.md\n` +
|
|
643
|
+
` .agents/skills: ${await count(path.join(target, ".agents/skills"))}` +
|
|
644
|
+
` (Codex / Gemini / Copilot / OpenCode / Windsurf)\n` +
|
|
645
|
+
` cursor agent model: ${CURSOR_AGENT_MODEL} (forced)\n`,
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
async function main() {
|
|
650
|
+
dbg("main: parsed target/bundle start");
|
|
651
|
+
const args = parseArgs(process.argv.slice(2));
|
|
652
|
+
dbg("main: args parsed", JSON.stringify(args));
|
|
653
|
+
if (args.plugins) {
|
|
654
|
+
if (args.bundle) {
|
|
655
|
+
const dest = path.join(ROOT, "plugins", args.bundle);
|
|
656
|
+
process.stdout.write(`ZenKit plugin ${args.bundle} → ${dest}\n`);
|
|
657
|
+
await emitPluginPackage({ dest, bundle: args.bundle });
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
process.stdout.write("ZenKit plugins → plugins/\n");
|
|
661
|
+
await emitStorefrontPlugins();
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
await generateKit(args);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
const invokedDirectly =
|
|
668
|
+
Boolean(process.argv[1]) &&
|
|
669
|
+
path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
670
|
+
|
|
671
|
+
if (invokedDirectly) {
|
|
672
|
+
main().catch((e) => {
|
|
673
|
+
process.stderr.write(String(e?.stack || e) + "\n");
|
|
674
|
+
process.exit(1);
|
|
675
|
+
});
|
|
676
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Alias estável: node scripts/install.mjs --into <projeto>
|
|
4
|
+
* O comando novo é `zenkit init` (scripts/cli.mjs).
|
|
5
|
+
*/
|
|
6
|
+
import { runCli } from "./cli.mjs";
|
|
7
|
+
|
|
8
|
+
runCli(["init", ...process.argv.slice(2)]).catch((e) => {
|
|
9
|
+
process.stderr.write(String(e?.message || e) + "\n");
|
|
10
|
+
process.exit(e.exitCode || 1);
|
|
11
|
+
});
|