forjajs 2.0.3 → 2.0.4
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/agents/context-engineer.md +25 -25
- package/.claude/agents/governance.md +55 -55
- package/.claude/agents/marketing.md +24 -24
- package/.claude/agents/orchestrator.md +31 -31
- package/.claude/agents/product.md +26 -26
- package/.claude/agents/release-auditor.md +68 -59
- package/.claude/agents/sdd-architect.md +34 -34
- package/.claude/settings.json +76 -76
- package/.claude/skills/new-adr/SKILL.md +61 -61
- package/.claude/skills/new-command/SKILL.md +67 -67
- package/.gemini-instructions.md +87 -87
- package/.github/copilot-instructions.md +87 -87
- package/.memoryrc.json +104 -104
- package/.openai-instructions.md +87 -87
- package/AGENTS.md +134 -134
- package/CHANGELOG.md +566 -550
- package/CONTRIBUTING.md +32 -32
- package/DOC-MAP.md +65 -60
- package/LICENSE +21 -21
- package/README.md +358 -339
- package/README.pt-BR.md +345 -345
- package/boilerplates/01-api-rest/README.md +336 -336
- package/boilerplates/01-api-rest/boilerplate.manifest.json +41 -41
- package/boilerplates/02-saas-starter/.env.example +25 -25
- package/boilerplates/02-saas-starter/CHECKLIST-CRIACAO.md +190 -190
- package/boilerplates/02-saas-starter/INFO.md +252 -252
- package/boilerplates/02-saas-starter/QUICK_START.md +194 -194
- package/boilerplates/02-saas-starter/README.md +305 -305
- package/boilerplates/02-saas-starter/START-HERE.md +259 -259
- package/boilerplates/02-saas-starter/backend/package.json +87 -87
- package/boilerplates/02-saas-starter/backend/src/app.module.ts +27 -27
- package/boilerplates/02-saas-starter/backend/src/common/decorators/roles.decorator.ts +3 -3
- package/boilerplates/02-saas-starter/backend/src/common/decorators/tenant.decorator.ts +6 -6
- package/boilerplates/02-saas-starter/backend/src/common/middleware/roles.guard.ts +23 -23
- package/boilerplates/02-saas-starter/backend/src/config/database.ts +26 -26
- package/boilerplates/02-saas-starter/backend/src/main.ts +26 -26
- package/boilerplates/02-saas-starter/backend/src/modules/auth/auth.controller.ts +46 -46
- package/boilerplates/02-saas-starter/backend/src/modules/auth/auth.module.ts +25 -25
- package/boilerplates/02-saas-starter/backend/src/modules/auth/auth.service.ts +145 -145
- package/boilerplates/02-saas-starter/backend/src/modules/auth/dto/auth.dto.ts +30 -30
- package/boilerplates/02-saas-starter/backend/src/modules/auth/strategies/jwt.strategy.ts +24 -24
- package/boilerplates/02-saas-starter/backend/src/modules/auth/strategies/local.strategy.ts +19 -19
- package/boilerplates/02-saas-starter/backend/src/modules/billing/billing.controller.ts +42 -42
- package/boilerplates/02-saas-starter/backend/src/modules/billing/billing.module.ts +13 -13
- package/boilerplates/02-saas-starter/backend/src/modules/billing/billing.service.ts +67 -67
- package/boilerplates/02-saas-starter/backend/src/modules/billing/entities/invoice.entity.ts +52 -52
- package/boilerplates/02-saas-starter/backend/src/modules/organizations/entities/organization.entity.ts +36 -36
- package/boilerplates/02-saas-starter/backend/src/modules/organizations/organizations.controller.ts +16 -16
- package/boilerplates/02-saas-starter/backend/src/modules/organizations/organizations.module.ts +13 -13
- package/boilerplates/02-saas-starter/backend/src/modules/organizations/organizations.service.ts +34 -34
- package/boilerplates/02-saas-starter/backend/src/modules/subscriptions/entities/subscription.entity.ts +40 -40
- package/boilerplates/02-saas-starter/backend/src/modules/subscriptions/subscriptions.controller.ts +36 -36
- package/boilerplates/02-saas-starter/backend/src/modules/subscriptions/subscriptions.module.ts +13 -13
- package/boilerplates/02-saas-starter/backend/src/modules/subscriptions/subscriptions.service.ts +91 -91
- package/boilerplates/02-saas-starter/backend/src/modules/users/entities/user.entity.ts +42 -42
- package/boilerplates/02-saas-starter/backend/src/modules/users/users.controller.ts +14 -14
- package/boilerplates/02-saas-starter/backend/src/modules/users/users.module.ts +13 -13
- package/boilerplates/02-saas-starter/backend/src/modules/users/users.service.ts +48 -48
- package/boilerplates/02-saas-starter/backend/tsconfig.json +28 -28
- package/boilerplates/02-saas-starter/boilerplate.manifest.json +42 -42
- package/boilerplates/02-saas-starter/docker-compose.yml +34 -34
- package/boilerplates/02-saas-starter/memory/00-global/agent-contract.md +227 -227
- package/boilerplates/02-saas-starter/memory/00-global/context-policy.md +141 -141
- package/boilerplates/02-saas-starter/memory/00-global/index.md +133 -133
- package/boilerplates/02-saas-starter/memory/00-global/mission.md +45 -45
- package/boilerplates/02-saas-starter/memory/00-global/patterns.md +223 -223
- package/boilerplates/02-saas-starter/memory/10-product/business-rules.md +240 -240
- package/boilerplates/02-saas-starter/memory/10-product/nfrs.md +239 -239
- package/boilerplates/02-saas-starter/memory/10-product/personas.md +195 -195
- package/boilerplates/02-saas-starter/memory/10-product/vision.md +63 -63
- package/boilerplates/02-saas-starter/memory/20-architecture/overview.md +232 -232
- package/boilerplates/02-saas-starter/memory/30-domains/auth/api.md +186 -186
- package/boilerplates/02-saas-starter/memory/30-domains/auth/context.md +85 -85
- package/boilerplates/02-saas-starter/memory/30-domains/billing/api.md +262 -262
- package/boilerplates/02-saas-starter/memory/30-domains/billing/context.md +137 -137
- package/boilerplates/02-saas-starter/memory/30-domains/subscriptions/api.md +176 -176
- package/boilerplates/02-saas-starter/memory/30-domains/subscriptions/context.md +100 -100
- package/boilerplates/02-saas-starter/memory/40-delivery/backlog.md +81 -81
- package/boilerplates/02-saas-starter/memory/40-delivery/roadmap.md +97 -97
- package/boilerplates/02-saas-starter/memory/40-delivery/sprint-atual.md +57 -57
- package/boilerplates/02-saas-starter/memory/50-orchestration/topology.md +90 -90
- package/boilerplates/02-saas-starter/memory/60-runs/index.md +54 -54
- package/boilerplates/02-saas-starter/memory/70-summaries/global.md +50 -50
- package/boilerplates/02-saas-starter/memory/80-data/schema.md +185 -185
- package/boilerplates/02-saas-starter/memory/90-decisions/adr-template.md +75 -75
- package/boilerplates/03-ecommerce-starter/FLOW_EXEMPLOS.md +599 -599
- package/boilerplates/03-ecommerce-starter/GUIA_RAPIDO.md +322 -322
- package/boilerplates/03-ecommerce-starter/MANIFEST.md +463 -463
- package/boilerplates/03-ecommerce-starter/README.md +465 -465
- package/boilerplates/03-ecommerce-starter/backend/.env.example +121 -121
- package/boilerplates/03-ecommerce-starter/backend/Dockerfile +15 -15
- package/boilerplates/03-ecommerce-starter/backend/docker-compose.yml +56 -56
- package/boilerplates/03-ecommerce-starter/backend/jest.config.js +16 -16
- package/boilerplates/03-ecommerce-starter/backend/package.json +71 -71
- package/boilerplates/03-ecommerce-starter/backend/src/app.controller.ts +12 -12
- package/boilerplates/03-ecommerce-starter/backend/src/app.module.ts +48 -48
- package/boilerplates/03-ecommerce-starter/backend/src/app.service.ts +12 -12
- package/boilerplates/03-ecommerce-starter/backend/src/main.ts +51 -51
- package/boilerplates/03-ecommerce-starter/backend/src/modules/auth/auth.module.ts +8 -8
- package/boilerplates/03-ecommerce-starter/backend/src/modules/cart/cart.module.ts +8 -8
- package/boilerplates/03-ecommerce-starter/backend/src/modules/coupons/coupons.module.ts +8 -8
- package/boilerplates/03-ecommerce-starter/backend/src/modules/inventory/inventory.module.ts +8 -8
- package/boilerplates/03-ecommerce-starter/backend/src/modules/orders/orders.module.ts +10 -10
- package/boilerplates/03-ecommerce-starter/backend/src/modules/payments/payments.module.ts +8 -8
- package/boilerplates/03-ecommerce-starter/backend/src/modules/products/dto/create-product.dto.ts +34 -34
- package/boilerplates/03-ecommerce-starter/backend/src/modules/products/entities/category.entity.ts +47 -47
- package/boilerplates/03-ecommerce-starter/backend/src/modules/products/entities/product.entity.ts +66 -66
- package/boilerplates/03-ecommerce-starter/backend/src/modules/products/products.controller.ts +78 -78
- package/boilerplates/03-ecommerce-starter/backend/src/modules/products/products.module.ts +14 -14
- package/boilerplates/03-ecommerce-starter/backend/src/modules/products/products.service.ts +112 -112
- package/boilerplates/03-ecommerce-starter/backend/src/modules/reviews/entities/review.entity.ts +32 -32
- package/boilerplates/03-ecommerce-starter/backend/src/modules/reviews/reviews.module.ts +11 -11
- package/boilerplates/03-ecommerce-starter/backend/test/health.e2e-spec.ts +31 -31
- package/boilerplates/03-ecommerce-starter/backend/test/jest-e2e.json +12 -12
- package/boilerplates/03-ecommerce-starter/backend/tsconfig.json +23 -23
- package/boilerplates/03-ecommerce-starter/boilerplate.manifest.json +42 -42
- package/boilerplates/03-ecommerce-starter/boilerplate.md +128 -128
- package/boilerplates/03-ecommerce-starter/memory/00-global/agent-contract.md +53 -53
- package/boilerplates/03-ecommerce-starter/memory/00-global/context-index.md +55 -55
- package/boilerplates/03-ecommerce-starter/memory/00-global/context-policy.md +31 -31
- package/boilerplates/03-ecommerce-starter/memory/00-global/mission.md +25 -25
- package/boilerplates/03-ecommerce-starter/memory/00-global/standards.md +45 -45
- package/boilerplates/03-ecommerce-starter/memory/10-product/business-rules.md +62 -62
- package/boilerplates/03-ecommerce-starter/memory/10-product/nfrs.md +62 -62
- package/boilerplates/03-ecommerce-starter/memory/10-product/vision.md +124 -124
- package/boilerplates/03-ecommerce-starter/memory/20-architecture/backend.md +253 -253
- package/boilerplates/03-ecommerce-starter/memory/20-architecture/observability.md +319 -319
- package/boilerplates/03-ecommerce-starter/memory/20-architecture/overview.md +133 -133
- package/boilerplates/03-ecommerce-starter/memory/20-architecture/security.md +227 -227
- package/boilerplates/03-ecommerce-starter/memory/30-domains/catalog/context.md +210 -210
- package/boilerplates/03-ecommerce-starter/memory/30-domains/inventory/context.md +233 -233
- package/boilerplates/03-ecommerce-starter/memory/30-domains/orders/context.md +210 -210
- package/boilerplates/03-ecommerce-starter/memory/30-domains/payments/context.md +168 -168
- package/boilerplates/03-ecommerce-starter/memory/80-data/sqlite.md +260 -260
- package/boilerplates/03-ecommerce-starter/memory/90-decisions/ADR-TEMPLATE.md +223 -223
- package/boilerplates/04-microservices-starter/.env.example +43 -43
- package/boilerplates/04-microservices-starter/API-EXAMPLES.md +609 -609
- package/boilerplates/04-microservices-starter/ARCHITECTURE.md +512 -512
- package/boilerplates/04-microservices-starter/GETTING-STARTED.md +246 -246
- package/boilerplates/04-microservices-starter/INDEX.md +377 -377
- package/boilerplates/04-microservices-starter/MANIFEST.md +456 -456
- package/boilerplates/04-microservices-starter/README.md +466 -466
- package/boilerplates/04-microservices-starter/SUMMARY.md +386 -386
- package/boilerplates/04-microservices-starter/backend/api-gateway/Dockerfile +14 -14
- package/boilerplates/04-microservices-starter/backend/api-gateway/package.json +29 -29
- package/boilerplates/04-microservices-starter/backend/api-gateway/src/app.module.ts +9 -9
- package/boilerplates/04-microservices-starter/backend/api-gateway/src/gateway.controller.ts +45 -45
- package/boilerplates/04-microservices-starter/backend/api-gateway/src/gateway.service.ts +114 -114
- package/boilerplates/04-microservices-starter/backend/api-gateway/src/main.ts +9 -9
- package/boilerplates/04-microservices-starter/backend/api-gateway/tsconfig.json +20 -20
- package/boilerplates/04-microservices-starter/backend/services/auth-service/Dockerfile +14 -14
- package/boilerplates/04-microservices-starter/backend/services/auth-service/package.json +42 -42
- package/boilerplates/04-microservices-starter/backend/services/auth-service/src/app.module.ts +7 -7
- package/boilerplates/04-microservices-starter/backend/services/auth-service/src/main.ts +9 -9
- package/boilerplates/04-microservices-starter/backend/services/auth-service/src/modules/auth/auth.controller.ts +130 -130
- package/boilerplates/04-microservices-starter/backend/services/auth-service/src/modules/auth/auth.module.ts +21 -21
- package/boilerplates/04-microservices-starter/backend/services/auth-service/src/modules/auth/auth.service.ts +159 -159
- package/boilerplates/04-microservices-starter/backend/services/auth-service/src/modules/auth/jwt.strategy.ts +19 -19
- package/boilerplates/04-microservices-starter/backend/services/auth-service/src/modules/auth/local.strategy.ts +18 -18
- package/boilerplates/04-microservices-starter/backend/services/auth-service/tsconfig.json +21 -21
- package/boilerplates/04-microservices-starter/backend/services/notification-service/Dockerfile +14 -14
- package/boilerplates/04-microservices-starter/backend/services/notification-service/package.json +25 -25
- package/boilerplates/04-microservices-starter/backend/services/notification-service/src/app.module.ts +7 -7
- package/boilerplates/04-microservices-starter/backend/services/notification-service/src/main.ts +9 -9
- package/boilerplates/04-microservices-starter/backend/services/notification-service/src/modules/notification/notification.controller.ts +160 -160
- package/boilerplates/04-microservices-starter/backend/services/notification-service/src/modules/notification/notification.module.ts +10 -10
- package/boilerplates/04-microservices-starter/backend/services/notification-service/src/modules/notification/notification.service.ts +92 -92
- package/boilerplates/04-microservices-starter/backend/services/notification-service/tsconfig.json +20 -20
- package/boilerplates/04-microservices-starter/backend/services/user-service/Dockerfile +14 -14
- package/boilerplates/04-microservices-starter/backend/services/user-service/package.json +25 -25
- package/boilerplates/04-microservices-starter/backend/services/user-service/src/app.module.ts +7 -7
- package/boilerplates/04-microservices-starter/backend/services/user-service/src/main.ts +9 -9
- package/boilerplates/04-microservices-starter/backend/services/user-service/src/modules/user/user.controller.ts +122 -122
- package/boilerplates/04-microservices-starter/backend/services/user-service/src/modules/user/user.module.ts +10 -10
- package/boilerplates/04-microservices-starter/backend/services/user-service/src/modules/user/user.service.ts +161 -161
- package/boilerplates/04-microservices-starter/backend/services/user-service/tsconfig.json +20 -20
- package/boilerplates/04-microservices-starter/backend/shared/package.json +15 -15
- package/boilerplates/04-microservices-starter/backend/shared/src/constants/index.ts +84 -84
- package/boilerplates/04-microservices-starter/backend/shared/src/decorators/index.ts +12 -12
- package/boilerplates/04-microservices-starter/backend/shared/src/index.ts +4 -4
- package/boilerplates/04-microservices-starter/backend/shared/src/interfaces/index.ts +152 -152
- package/boilerplates/04-microservices-starter/backend/shared/src/utils/index.ts +54 -54
- package/boilerplates/04-microservices-starter/backend/shared/tsconfig.json +20 -20
- package/boilerplates/04-microservices-starter/boilerplate.manifest.json +41 -41
- package/boilerplates/04-microservices-starter/docker-compose.yml +164 -164
- package/boilerplates/04-microservices-starter/memory/00-global/agent-contract.md +171 -171
- package/boilerplates/04-microservices-starter/memory/00-global/context-policy.md +89 -89
- package/boilerplates/04-microservices-starter/memory/00-global/index.md +102 -102
- package/boilerplates/04-microservices-starter/memory/00-global/mission.md +44 -44
- package/boilerplates/04-microservices-starter/memory/00-global/patterns.md +106 -106
- package/boilerplates/04-microservices-starter/memory/10-product/vision.md +76 -76
- package/boilerplates/04-microservices-starter/memory/20-architecture/overview.md +247 -247
- package/boilerplates/04-microservices-starter/memory/30-domains/auth-service/api.md +293 -293
- package/boilerplates/04-microservices-starter/memory/30-domains/auth-service/context.md +108 -108
- package/boilerplates/04-microservices-starter/memory/30-domains/notification-service/api.md +333 -333
- package/boilerplates/04-microservices-starter/memory/30-domains/notification-service/context.md +121 -121
- package/boilerplates/04-microservices-starter/memory/30-domains/user-service/api.md +308 -308
- package/boilerplates/04-microservices-starter/memory/30-domains/user-service/context.md +120 -120
- package/boilerplates/04-microservices-starter/memory/50-orchestration/topology.md +216 -216
- package/boilerplates/04-microservices-starter/package.json +21 -21
- package/boilerplates/05-monorepo-starter/.env.example +1 -1
- package/boilerplates/05-monorepo-starter/BOILERPLATE_SUMMARY.md +193 -193
- package/boilerplates/05-monorepo-starter/DEVELOPMENT.md +481 -481
- package/boilerplates/05-monorepo-starter/Dockerfile +35 -35
- package/boilerplates/05-monorepo-starter/README.md +318 -318
- package/boilerplates/05-monorepo-starter/boilerplate.manifest.json +43 -43
- package/boilerplates/05-monorepo-starter/docker-compose.yml +36 -36
- package/boilerplates/05-monorepo-starter/memory/00-global/agent-contract.md +28 -28
- package/boilerplates/05-monorepo-starter/memory/00-global/context-policy.md +21 -21
- package/boilerplates/05-monorepo-starter/memory/00-global/index.md +44 -44
- package/boilerplates/05-monorepo-starter/memory/00-global/mission.md +17 -17
- package/boilerplates/05-monorepo-starter/memory/00-global/patterns.md +48 -48
- package/boilerplates/05-monorepo-starter/memory/10-product/business-rules.md +24 -24
- package/boilerplates/05-monorepo-starter/memory/10-product/nfrs.md +39 -39
- package/boilerplates/05-monorepo-starter/memory/10-product/personas.md +25 -25
- package/boilerplates/05-monorepo-starter/memory/10-product/vision.md +22 -22
- package/boilerplates/05-monorepo-starter/memory/20-architecture/backend.md +85 -85
- package/boilerplates/05-monorepo-starter/memory/20-architecture/data.md +66 -66
- package/boilerplates/05-monorepo-starter/memory/20-architecture/frontend.md +58 -58
- package/boilerplates/05-monorepo-starter/memory/20-architecture/overview.md +86 -86
- package/boilerplates/05-monorepo-starter/memory/20-architecture/security.md +58 -58
- package/boilerplates/05-monorepo-starter/memory/30-domains/order/api.md +81 -81
- package/boilerplates/05-monorepo-starter/memory/30-domains/order/context.md +63 -63
- package/boilerplates/05-monorepo-starter/memory/30-domains/product/api.md +81 -81
- package/boilerplates/05-monorepo-starter/memory/30-domains/product/context.md +56 -56
- package/boilerplates/05-monorepo-starter/memory/30-domains/user/api.md +99 -99
- package/boilerplates/05-monorepo-starter/memory/30-domains/user/context.md +58 -58
- package/boilerplates/05-monorepo-starter/package.json +30 -30
- package/boilerplates/05-monorepo-starter/packages/apps/backend/.env.example +15 -15
- package/boilerplates/05-monorepo-starter/packages/apps/backend/README.md +28 -28
- package/boilerplates/05-monorepo-starter/packages/apps/backend/package.json +53 -53
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/app.module.ts +40 -40
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/common/exceptions/global.exception.ts +32 -32
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/common/guards/jwt.guard.ts +5 -5
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/common/guards/jwt.strategy.ts +11 -11
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/common/guards/roles.guard.ts +17 -17
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/common/health.controller.ts +13 -13
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/main.ts +28 -28
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/orders/dto/index.ts +23 -23
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/orders/entities/order.entity.ts +48 -48
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/orders/orders.controller.ts +51 -51
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/orders/orders.module.ts +13 -13
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/orders/orders.service.ts +123 -123
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/products/dto/index.ts +35 -35
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/products/entities/product.entity.ts +28 -28
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/products/products.controller.ts +49 -49
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/products/products.module.ts +12 -12
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/products/products.service.ts +79 -79
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/users/dto/index.ts +24 -24
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/users/entities/user.entity.ts +28 -28
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/users/users.controller.ts +29 -29
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/users/users.module.ts +15 -15
- package/boilerplates/05-monorepo-starter/packages/apps/backend/src/modules/users/users.service.ts +78 -78
- package/boilerplates/05-monorepo-starter/packages/apps/backend/tsconfig.json +25 -25
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/.env.example +1 -1
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/README.md +30 -30
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/app/dashboard/page.tsx +39 -39
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/app/layout.tsx +15 -15
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/app/page.tsx +47 -47
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/app/products/page.tsx +51 -51
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/components/features/product-card.tsx +19 -19
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/components/layout/footer.tsx +10 -10
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/components/layout/header.tsx +24 -24
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/components/layout/layout.tsx +13 -13
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/lib/api-client.ts +34 -34
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/lib/auth.ts +35 -35
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/lib/orders.ts +28 -28
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/lib/products.ts +28 -28
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/next.config.js +15 -15
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/package.json +31 -31
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/postcss.config.js +3 -3
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/styles/globals.css +7 -7
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/tailwind.config.js +7 -7
- package/boilerplates/05-monorepo-starter/packages/apps/frontend/tsconfig.json +14 -14
- package/boilerplates/05-monorepo-starter/packages/packages/shared-types/README.md +35 -35
- package/boilerplates/05-monorepo-starter/packages/packages/shared-types/package.json +17 -17
- package/boilerplates/05-monorepo-starter/packages/packages/shared-types/src/api/common.ts +18 -18
- package/boilerplates/05-monorepo-starter/packages/packages/shared-types/src/api/order.ts +38 -38
- package/boilerplates/05-monorepo-starter/packages/packages/shared-types/src/api/product.ts +33 -33
- package/boilerplates/05-monorepo-starter/packages/packages/shared-types/src/api/user.ts +32 -32
- package/boilerplates/05-monorepo-starter/packages/packages/shared-types/src/domain/index.ts +41 -41
- package/boilerplates/05-monorepo-starter/packages/packages/shared-types/src/errors/index.ts +46 -46
- package/boilerplates/05-monorepo-starter/packages/packages/shared-types/src/index.ts +7 -7
- package/boilerplates/05-monorepo-starter/packages/packages/shared-types/tsconfig.json +8 -8
- package/boilerplates/05-monorepo-starter/packages/packages/shared-utils/README.md +30 -30
- package/boilerplates/05-monorepo-starter/packages/packages/shared-utils/package.json +17 -17
- package/boilerplates/05-monorepo-starter/packages/packages/shared-utils/src/constants/index.ts +45 -45
- package/boilerplates/05-monorepo-starter/packages/packages/shared-utils/src/index.ts +4 -4
- package/boilerplates/05-monorepo-starter/packages/packages/shared-utils/src/utils/index.ts +3 -3
- package/boilerplates/05-monorepo-starter/packages/packages/shared-utils/src/utils/math.ts +30 -30
- package/boilerplates/05-monorepo-starter/packages/packages/shared-utils/src/utils/string.ts +48 -48
- package/boilerplates/05-monorepo-starter/packages/packages/shared-utils/src/validators/index.ts +44 -44
- package/boilerplates/05-monorepo-starter/packages/packages/shared-utils/tsconfig.json +8 -8
- package/boilerplates/05-monorepo-starter/tsconfig.json +23 -23
- package/boilerplates/05-monorepo-starter/turbo.json +35 -35
- package/boilerplates/06-clean-arch/README.md +48 -48
- package/boilerplates/06-clean-arch/WHEN-CLEAN-WHEN-LEAN.md +71 -71
- package/boilerplates/06-clean-arch/backend/package.json +43 -43
- package/boilerplates/06-clean-arch/backend/src/app.module.ts +20 -20
- package/boilerplates/06-clean-arch/backend/src/main.ts +10 -10
- package/boilerplates/06-clean-arch/backend/src/modules/orders/application/place-order.usecase.ts +47 -47
- package/boilerplates/06-clean-arch/backend/src/modules/orders/application/ship-order.usecase.ts +28 -28
- package/boilerplates/06-clean-arch/backend/src/modules/orders/domain/money.vo.ts +30 -30
- package/boilerplates/06-clean-arch/backend/src/modules/orders/domain/order-status.vo.ts +36 -36
- package/boilerplates/06-clean-arch/backend/src/modules/orders/domain/order.entity.ts +85 -85
- package/boilerplates/06-clean-arch/backend/src/modules/orders/domain/order.repository.ts +17 -17
- package/boilerplates/06-clean-arch/backend/src/modules/orders/infrastructure/order.orm-entity.ts +24 -24
- package/boilerplates/06-clean-arch/backend/src/modules/orders/infrastructure/typeorm-order.repository.ts +57 -57
- package/boilerplates/06-clean-arch/backend/src/modules/orders/orders.module.ts +28 -28
- package/boilerplates/06-clean-arch/backend/src/modules/orders/presentation/orders.controller.ts +31 -31
- package/boilerplates/06-clean-arch/backend/src/modules/orders/presentation/orders.http.dto.ts +30 -30
- package/boilerplates/06-clean-arch/backend/src/modules/products/product.entity.ts +20 -20
- package/boilerplates/06-clean-arch/backend/src/modules/products/products.controller.ts +43 -43
- package/boilerplates/06-clean-arch/backend/src/modules/products/products.module.ts +11 -11
- package/boilerplates/06-clean-arch/backend/src/shared/result.ts +32 -32
- package/boilerplates/06-clean-arch/backend/test/orders/place-order.spec.ts +46 -46
- package/boilerplates/06-clean-arch/backend/tsconfig.json +16 -16
- package/boilerplates/06-clean-arch/boilerplate.manifest.json +43 -43
- package/boilerplates/06-clean-arch/memory/30-domains/orders/context.md +39 -39
- package/boilerplates/06-clean-arch/memory/30-domains/products/context.md +23 -23
- package/boilerplates/README.md +427 -427
- package/design-md/BRIEF-TEMPLATE.md +47 -47
- package/design-md/INDEX.md +35 -35
- package/design-md/MATRIX.md +24 -24
- package/design-md/PLAYBOOK.md +35 -35
- package/design-md/examples/agent-console-brief.md +48 -48
- package/dist/apps/dashboard/app/dashboard-client.jsx +10 -10
- package/dist/bin/create-memory-nest-kit.js +17 -17
- package/dist/bin/forja.js +14 -2
- package/dist/bin/init-project.js +38 -38
- package/dist/lib/audit.js +7 -7
- package/dist/lib/context-builder.js +32 -32
- package/dist/lib/core/doc-graph.js +6 -4
- package/dist/lib/core/registry.d.ts +54 -0
- package/dist/lib/core/registry.js +55 -0
- package/dist/lib/core/release.d.ts +53 -0
- package/dist/lib/core/release.js +5 -1
- package/dist/lib/generators/memory-generator.js +700 -698
- package/dist/lib/generators/nest-generator.js +398 -398
- package/dist/lib/generators/readme-generator.js +180 -180
- package/dist/lib/governance-report.js +39 -39
- package/dist/lib/project-upgrade.js +1 -1
- package/dist/lib/workspace.d.ts +7 -0
- package/dist/lib/workspace.js +63 -34
- package/dist/packages/adapter-sqlite/src/index.js +12 -12
- package/dist/packages/llm/src/index.d.ts +43 -0
- package/dist/packages/llm/src/index.js +108 -0
- package/dist/scripts/agent-harness.js +66 -64
- package/dist/scripts/agent-router.js +20 -20
- package/dist/scripts/build-smart-context.js +22 -22
- package/dist/scripts/compress-memory.js +8 -8
- package/dist/scripts/context-ops.js +29 -29
- package/dist/scripts/demo-autonomy.js +2 -2
- package/dist/scripts/demo-workspace.d.ts +6 -0
- package/dist/scripts/demo-workspace.js +101 -0
- package/dist/scripts/dev.js +13 -13
- package/dist/scripts/extract-global-knowledge.js +5 -5
- package/dist/scripts/generate-dashboard.js +11 -11
- package/dist/scripts/llm-fit.js +131 -0
- package/dist/scripts/memory-schema.js +48 -48
- package/dist/scripts/query-universal-memory.js +13 -13
- package/dist/scripts/sprint-manager.js +39 -39
- package/dist/scripts/sync-universal-memory.js +63 -50
- package/docs/2x/CLI-CAPABILITIES.md +35 -35
- package/docs/2x/IMPLEMENTATION-AUDIT.md +40 -40
- package/docs/2x/SPRINT-1-CLI-CAPABILITY-PLAN.md +53 -53
- package/docs/2x/SPRINT-10-GRAPH-SYNC-PLAN.md +54 -54
- package/docs/2x/SPRINT-11-GRAPH-SYNC-CLI-MCP-PLAN.md +38 -38
- package/docs/2x/SPRINT-12-REAL-AUTONOMY-PLAN.md +40 -40
- package/docs/2x/SPRINT-13-MCP-STDIO-PLAN.md +26 -26
- package/docs/2x/SPRINT-14-SERVER-RESTART-PLAN.md +28 -28
- package/docs/2x/SPRINT-15-CHAOS-SECURITY-PLAN.md +22 -22
- package/docs/2x/SPRINT-16-LAST-MILE-PLAN.md +25 -25
- package/docs/2x/SPRINT-2-CLI-CAPABILITY-PLAN.md +39 -39
- package/docs/2x/SPRINT-3-RUNTIME-PERSISTENCE-PLAN.md +42 -42
- package/docs/2x/SPRINT-4-MCP-REGISTRY-PLAN.md +35 -35
- package/docs/2x/SPRINT-5-SERVER-APPROVALS-AUDIT-PLAN.md +31 -31
- package/docs/2x/SPRINT-6-EVENTS-E2E-PLAN.md +55 -55
- package/docs/2x/SPRINT-7-GRAPHLOOP-PERSISTENCE-PLAN.md +60 -60
- package/docs/2x/SPRINT-8-CONTEXT-GRAPH-PLAN.md +64 -64
- package/docs/2x/SPRINT-9-DETERMINISTIC-EXTRACTORS-PLAN.md +51 -51
- package/docs/GUIA-ONBOARDING-EXECUTIVO.md +63 -63
- package/docs/GUIA-ONBOARDING-OPERACIONAL-PAPEIS.md +136 -136
- package/docs/GUIA-ONBOARDING-PROJETO.md +279 -279
- package/docs/agent-harnesses.md +149 -149
- package/docs/architecture/FORJA-2.0-ARCHITECTURE.md +109 -109
- package/docs/architecture/FORJA-2.0-IMPACT-FOUNDATION.md +273 -273
- package/docs/archive/CHECKLIST-FINAL.md +295 -295
- package/docs/archive/FASE2-SUMMARY.md +263 -263
- package/docs/archive/FASE3-PROGRESS.md +355 -355
- package/docs/archive/IMPLEMENTACAO-FASE1.md +476 -476
- package/docs/archive/INDICE-MASTER.md +282 -282
- package/docs/archive/PROJETO-COMPLETO.md +363 -363
- package/docs/archive/README-REFINAMENTO.md +293 -293
- package/docs/archive/REFERENCIA-RAPIDA.md +324 -324
- package/docs/archive/REFINAMENTO-v1.0.md +565 -565
- package/docs/archive/RELATORIO-TESTES-INTEGRACAO.md +223 -223
- package/docs/archive/START-HERE.md +319 -319
- package/docs/archive/SUMARIO-EXECUTIVO.md +268 -268
- package/docs/archive/examples/v1/AGENTS.md +10 -10
- package/docs/archive/examples/v1/README.md +36 -36
- package/docs/archive/examples/v1/backend/jest-e2e.json +9 -9
- package/docs/archive/examples/v1/backend/nest-cli.json +4 -4
- package/docs/archive/examples/v1/backend/package.json +42 -42
- package/docs/archive/examples/v1/backend/src/app.controller.ts +12 -12
- package/docs/archive/examples/v1/backend/src/app.module.ts +10 -10
- package/docs/archive/examples/v1/backend/src/app.service.ts +8 -8
- package/docs/archive/examples/v1/backend/src/main.ts +10 -10
- package/docs/archive/examples/v1/backend/test/app.e2e-spec.ts +24 -24
- package/docs/archive/examples/v1/backend/tsconfig.build.json +4 -4
- package/docs/archive/examples/v1/backend/tsconfig.json +17 -17
- package/docs/archive/examples/v1/memory/00-global/glossary.md +5 -5
- package/docs/archive/examples/v1/memory/00-global/mission.md +9 -9
- package/docs/archive/examples/v1/memory/00-global/standards.md +12 -12
- package/docs/archive/examples/v1/memory/00-global/tooling.md +10 -10
- package/docs/archive/examples/v1/memory/10-product/business-rules.md +3 -3
- package/docs/archive/examples/v1/memory/10-product/nfrs.md +6 -6
- package/docs/archive/examples/v1/memory/10-product/personas.md +3 -3
- package/docs/archive/examples/v1/memory/10-product/vision.md +3 -3
- package/docs/archive/examples/v1/memory/20-architecture/backend.md +10 -10
- package/docs/archive/examples/v1/memory/20-architecture/data.md +3 -3
- package/docs/archive/examples/v1/memory/20-architecture/frontend.md +3 -3
- package/docs/archive/examples/v1/memory/20-architecture/observability.md +5 -5
- package/docs/archive/examples/v1/memory/20-architecture/security.md +6 -6
- package/docs/archive/examples/v1/memory/20-architecture/system-overview.md +3 -3
- package/docs/archive/examples/v1/memory/30-domains/auth/api.md +3 -3
- package/docs/archive/examples/v1/memory/30-domains/auth/context.md +3 -3
- package/docs/archive/examples/v1/memory/30-domains/auth/rules.md +3 -3
- package/docs/archive/examples/v1/memory/30-domains/billing/api.md +3 -3
- package/docs/archive/examples/v1/memory/30-domains/billing/context.md +3 -3
- package/docs/archive/examples/v1/memory/30-domains/billing/rules.md +3 -3
- package/docs/archive/examples/v1/memory/40-delivery/backlog.md +3 -3
- package/docs/archive/examples/v1/memory/40-delivery/current-sprint.md +10 -10
- package/docs/archive/examples/v1/memory/40-delivery/roadmap.md +3 -3
- package/docs/archive/examples/v1/memory/90-decisions/ADR-0001-template.md +9 -9
- package/docs/archive/examples/v1/prompts/project-prompt-base.md +19 -19
- package/docs/archive/examples/v2/.memoryrc.json +8 -8
- package/docs/archive/examples/v2/AGENTS.md +16 -16
- package/docs/archive/examples/v2/README.md +35 -35
- package/docs/archive/examples/v2/agents/README.md +3 -3
- package/docs/archive/examples/v2/agents/backend-nest.md +9 -9
- package/docs/archive/examples/v2/agents/dba.md +4 -4
- package/docs/archive/examples/v2/agents/frontend.md +4 -4
- package/docs/archive/examples/v2/agents/orchestrator.md +9 -9
- package/docs/archive/examples/v2/agents/reviewer.md +6 -6
- package/docs/archive/examples/v2/agents/security.md +4 -4
- package/docs/archive/examples/v2/backend/jest-e2e.json +9 -9
- package/docs/archive/examples/v2/backend/nest-cli.json +4 -4
- package/docs/archive/examples/v2/backend/package.json +42 -42
- package/docs/archive/examples/v2/backend/src/app.controller.ts +12 -12
- package/docs/archive/examples/v2/backend/src/app.module.ts +10 -10
- package/docs/archive/examples/v2/backend/src/app.service.ts +8 -8
- package/docs/archive/examples/v2/backend/src/main.ts +10 -10
- package/docs/archive/examples/v2/backend/test/app.e2e-spec.ts +24 -24
- package/docs/archive/examples/v2/backend/tsconfig.build.json +4 -4
- package/docs/archive/examples/v2/backend/tsconfig.json +17 -17
- package/docs/archive/examples/v2/memory/00-global/agent-contract.md +15 -15
- package/docs/archive/examples/v2/memory/00-global/context-index.md +12 -12
- package/docs/archive/examples/v2/memory/00-global/context-policy.md +14 -14
- package/docs/archive/examples/v2/memory/00-global/mission.md +9 -9
- package/docs/archive/examples/v2/memory/00-global/standards.md +12 -12
- package/docs/archive/examples/v2/memory/10-product/business-rules.md +3 -3
- package/docs/archive/examples/v2/memory/10-product/nfrs.md +6 -6
- package/docs/archive/examples/v2/memory/10-product/personas.md +3 -3
- package/docs/archive/examples/v2/memory/10-product/vision.md +3 -3
- package/docs/archive/examples/v2/memory/20-architecture/backend.md +10 -10
- package/docs/archive/examples/v2/memory/20-architecture/data.md +3 -3
- package/docs/archive/examples/v2/memory/20-architecture/frontend.md +3 -3
- package/docs/archive/examples/v2/memory/20-architecture/observability.md +5 -5
- package/docs/archive/examples/v2/memory/20-architecture/security.md +6 -6
- package/docs/archive/examples/v2/memory/20-architecture/system-overview.md +3 -3
- package/docs/archive/examples/v2/memory/30-domains/auth/api.md +3 -3
- package/docs/archive/examples/v2/memory/30-domains/auth/context.md +3 -3
- package/docs/archive/examples/v2/memory/30-domains/auth/rules.md +3 -3
- package/docs/archive/examples/v2/memory/30-domains/billing/api.md +3 -3
- package/docs/archive/examples/v2/memory/30-domains/billing/context.md +3 -3
- package/docs/archive/examples/v2/memory/30-domains/billing/rules.md +3 -3
- package/docs/archive/examples/v2/memory/40-delivery/backlog.md +3 -3
- package/docs/archive/examples/v2/memory/40-delivery/current-sprint.md +10 -10
- package/docs/archive/examples/v2/memory/40-delivery/roadmap.md +3 -3
- package/docs/archive/examples/v2/memory/50-orchestration/handoff-protocol.md +8 -8
- package/docs/archive/examples/v2/memory/50-orchestration/handoffs/2026-04-18T18-40-10.517Z_orchestrator_para_backend-nest.md +19 -19
- package/docs/archive/examples/v2/memory/50-orchestration/handoffs/README.md +4 -4
- package/docs/archive/examples/v2/memory/50-orchestration/parallel-playbook.md +9 -9
- package/docs/archive/examples/v2/memory/50-orchestration/routing.md +10 -10
- package/docs/archive/examples/v2/memory/50-orchestration/topology.md +15 -15
- package/docs/archive/examples/v2/memory/60-runs/README.md +3 -3
- package/docs/archive/examples/v2/memory/70-summaries/domain-summary.md +3 -3
- package/docs/archive/examples/v2/memory/70-summaries/global-summary.md +6 -6
- package/docs/archive/examples/v2/memory/90-decisions/ADR-0001-template.md +9 -9
- package/docs/archive/examples/v2/memory/README.md +8 -8
- package/docs/archive/examples/v2/prompts/multi-agent-orchestrator.md +12 -12
- package/docs/archive/examples/v2/prompts/project-prompt-base.md +21 -21
- package/docs/archive/examples/v2/prompts/worker-task-template.md +10 -10
- package/docs/archive/examples/v2/scripts/append-handoff.mjs +25 -25
- package/docs/archive/examples/v2/scripts/build-context-pack.mjs +31 -31
- package/docs/archive/examples/v2/skills/context-compaction/SKILL.md +9 -9
- package/docs/archive/examples/v2/skills/handoff/SKILL.md +8 -8
- package/docs/archive/examples/v2/skills/nest-api/SKILL.md +7 -7
- package/docs/archive/examples/v2/skills/triage-task/SKILL.md +10 -10
- package/docs/archive/legacy-bin/create-memory-nest-kit-monolith.js +1486 -1486
- package/docs/capacidades-externas.md +86 -86
- package/docs/cli-first-operacao.md +74 -74
- package/docs/dev-workflow.md +421 -421
- package/docs/examples.md +546 -546
- package/docs/fluxo.md +103 -103
- package/docs/glossary.md +453 -453
- package/docs/init-project.md +457 -457
- package/docs/llm-fit-loop.md +41 -0
- package/docs/manual-operacional-cli-sdd-gsd.md +1014 -1014
- package/docs/modos-de-operacao.md +52 -0
- package/docs/personas/architect/README.md +333 -333
- package/docs/personas/developer/README.md +371 -371
- package/docs/personas/executive/README.md +172 -172
- package/docs/personas/qa/README.md +350 -350
- package/docs/processo-projeto.md +138 -138
- package/docs/produto/factsheet-marketing.md +151 -0
- package/docs/produto/roteiro-demo.md +47 -0
- package/docs/publishing.md +377 -377
- package/docs/quick-reference.md +409 -409
- package/docs/security/FORJA-2.0-RELEASE-AUDIT-2026-08-01.md +95 -95
- package/docs/structure.md +360 -360
- package/docs/token-optimization.md +502 -502
- package/docs/vision/FORJA-2.0-VISION.md +72 -72
- package/memory/00-global/mission.md +15 -15
- package/memory/00-global/shared-knowledge.md +8 -8
- package/memory/00-global/standards.md +47 -47
- package/memory/10-product/personas.md +21 -21
- package/memory/10-product/vision.md +27 -27
- package/memory/30-projects/README.md +15 -15
- package/memory/40-delivery/backlog.md +15 -15
- package/memory/40-delivery/current-sprint.md +23 -26
- package/memory/50-orchestration/gsd-harness.md +55 -55
- package/memory/50-orchestration/handoffs/2026-07-31_architect_foundation-contracts.md +15 -15
- package/memory/50-orchestration/handoffs/2026-07-31_backend-nest.md +22 -22
- package/memory/50-orchestration/handoffs/2026-07-31_context-engine.md +16 -16
- package/memory/50-orchestration/handoffs/2026-07-31_control-plane.md +28 -28
- package/memory/50-orchestration/handoffs/2026-07-31_core-capability-registry.md +15 -15
- package/memory/50-orchestration/handoffs/2026-07-31_evals-plugin-sdk.md +22 -22
- package/memory/50-orchestration/handoffs/2026-07-31_events-scheduler.md +16 -16
- package/memory/50-orchestration/handoffs/2026-07-31_graphloop.md +16 -16
- package/memory/50-orchestration/handoffs/2026-07-31_mcp.md +21 -21
- package/memory/50-orchestration/handoffs/2026-07-31_nest-bootstrap.md +28 -28
- package/memory/50-orchestration/handoffs/2026-07-31_next-dashboard.md +22 -22
- package/memory/50-orchestration/handoffs/2026-07-31_observability.md +27 -27
- package/memory/50-orchestration/handoffs/2026-07-31_orchestration.md +21 -21
- package/memory/50-orchestration/handoffs/2026-07-31_planner-validator.md +16 -16
- package/memory/50-orchestration/handoffs/2026-07-31_policy-engine.md +14 -14
- package/memory/50-orchestration/handoffs/2026-07-31_runtime-control-plane.md +23 -23
- package/memory/50-orchestration/handoffs/2026-07-31_runtime-controlado.md +15 -15
- package/memory/50-orchestration/handoffs/2026-07-31_sandbox.md +21 -21
- package/memory/50-orchestration/handoffs/2026-07-31_sdk.md +27 -27
- package/memory/50-orchestration/handoffs/2026-07-31_sqlite-adapter.md +21 -21
- package/memory/50-orchestration/handoffs/2026-07-31_worker-dashboard-boundary.md +23 -23
- package/memory/50-orchestration/handoffs/2026-08-01_approval-server-identity.md +23 -23
- package/memory/50-orchestration/handoffs/2026-08-01_dashboard-auth-query.md +24 -24
- package/memory/50-orchestration/handoffs/2026-08-01_graphloop-approvals.md +23 -23
- package/memory/50-orchestration/handoffs/2026-08-01_sprint-1-cli-capabilities.md +41 -41
- package/memory/50-orchestration/handoffs/2026-08-01_sprint-10-graph-sync.md +23 -23
- package/memory/50-orchestration/handoffs/2026-08-01_sprint-11-graph-sync-cli-mcp.md +22 -22
- package/memory/50-orchestration/handoffs/2026-08-01_sprint-12-real-autonomy.md +16 -16
- package/memory/50-orchestration/handoffs/2026-08-01_sprint-2-cli-capabilities.md +30 -30
- package/memory/50-orchestration/handoffs/2026-08-01_sprint-3-runtime-persistence.md +29 -29
- package/memory/50-orchestration/handoffs/2026-08-01_sprint-4-mcp.md +29 -29
- package/memory/50-orchestration/handoffs/2026-08-01_sprint-5-server-approvals-audit.md +22 -22
- package/memory/50-orchestration/handoffs/2026-08-01_sprint-6-events-e2e.md +25 -25
- package/memory/50-orchestration/handoffs/2026-08-01_sprint-7-graphloop.md +23 -23
- package/memory/50-orchestration/handoffs/2026-08-01_sprint-8-context-graph.md +23 -23
- package/memory/50-orchestration/handoffs/2026-08-01_sprint-9-extractors.md +21 -21
- package/memory/50-orchestration/handoffs/2026-08-02_sprint-13-mcp-stdio.md +14 -14
- package/memory/50-orchestration/handoffs/2026-08-02_sprint-14-server-restart.md +15 -15
- package/memory/50-orchestration/handoffs/2026-08-02_sprint-15-chaos-security.md +13 -13
- package/memory/50-orchestration/handoffs/2026-08-02_sprint-16-last-mile.md +11 -11
- package/memory/90-decisions/0001-memoria-hierarquica.md +38 -38
- package/memory/90-decisions/0002-sqlite-fts5-busca.md +25 -25
- package/memory/90-decisions/0003-smart-context-3-modos.md +31 -31
- package/memory/90-decisions/0004-validacao-obrigatoria-nest.md +27 -27
- package/memory/90-decisions/0005-handoff-7-campos.md +32 -32
- package/memory/90-decisions/0006-docs-por-persona.md +23 -23
- package/memory/90-decisions/0007-sdd-pipeline.md +33 -33
- package/memory/90-decisions/0008-sub-agents-claude-handoff-sqlite.md +36 -36
- package/memory/90-decisions/0009-claude-hooks-token-economy.md +43 -43
- package/memory/90-decisions/0010-banco-postgres.md +30 -30
- package/memory/90-decisions/0011-adrs-de-produto-realocadas.md +19 -19
- package/memory/90-decisions/0016-integracao-capacidades-externas.md +64 -64
- package/memory/90-decisions/0017-codegraph-no-harness-gsd.md +40 -40
- package/memory/90-decisions/0018-ferramentas-de-processo.md +46 -46
- package/memory/90-decisions/0019-workspace-separado.md +45 -45
- package/memory/90-decisions/0020-forja-core-cli-unica.md +45 -45
- package/memory/90-decisions/0021-guardrails-de-harness.md +111 -111
- package/memory/90-decisions/0022-congelar-dashboard-web.md +101 -101
- package/memory/90-decisions/0023-doctor-como-gate-do-nucleo.md +114 -114
- package/memory/90-decisions/0024-gate-do-tarball.md +103 -103
- package/memory/90-decisions/0025-coerencia-da-documentacao.md +105 -105
- package/memory/90-decisions/0026-migracao-typescript-runtime-duplo.md +66 -66
- package/memory/90-decisions/0027-clean-arch-calibrada.md +127 -127
- package/memory/90-decisions/0028-governanca-visivel.md +84 -84
- package/memory/90-decisions/0029-gate-do-projeto-gerado.md +59 -59
- package/memory/90-decisions/0030-projeto-gerado-herda-os-gates.md +53 -53
- package/memory/90-decisions/0031-motor-de-orquestracao.md +55 -55
- package/memory/90-decisions/0032-superficies-do-projeto-usam-cwd.md +63 -63
- package/memory/90-decisions/0033-doctor-distingue-permissao-de-corrupcao.md +64 -64
- package/memory/90-decisions/0034-forja-2-core-e-contratos.md +29 -29
- package/memory/90-decisions/0035-forja-2-local-first-e-autonomia.md +23 -23
- package/memory/90-decisions/0036-forja-2-capability-registry.md +30 -30
- package/memory/90-decisions/0037-forja-2-policy-engine-obrigatorio.md +28 -28
- package/memory/90-decisions/0038-forja-2-runtime-controlado.md +28 -28
- package/memory/90-decisions/0039-forja-2-event-bus-scheduler-local-first.md +31 -31
- package/memory/90-decisions/0040-forja-2-context-engine-budget-cache.md +32 -32
- package/memory/90-decisions/0041-forja-2-graphloop-separado-codegraph.md +32 -32
- package/memory/90-decisions/0042-forja-2-planner-validator-independentes.md +29 -29
- package/memory/90-decisions/0043-forja-2-orchestration-entities.md +16 -16
- package/memory/90-decisions/0044-forja-2-sandbox-worktree.md +19 -19
- package/memory/90-decisions/0045-forja-2-sqlite-adapter.md +19 -19
- package/memory/90-decisions/0046-forja-2-mcp-adapter.md +18 -18
- package/memory/90-decisions/0047-forja-2-backend-nest-adapter.md +19 -19
- package/memory/90-decisions/0048-forja-2-sdk-transport.md +18 -18
- package/memory/90-decisions/0049-forja-2-observability-control-plane.md +18 -18
- package/memory/90-decisions/0050-forja-2-control-plane-application-ports.md +18 -18
- package/memory/90-decisions/0051-forja-2-runtime-control-plane-composition.md +18 -18
- package/memory/90-decisions/0052-forja-2-deterministic-evaluation.md +15 -15
- package/memory/90-decisions/0053-forja-2-plugin-sdk-permissionado.md +16 -16
- package/memory/90-decisions/0054-forja-2-worker-dashboard-boundary.md +15 -15
- package/memory/90-decisions/0055-forja-2-next-dashboard-distribution.md +16 -16
- package/memory/90-decisions/0056-forja-2-dashboard-proxy-auth-query.md +16 -16
- package/memory/90-decisions/0057-forja-2-graphloop-approvals-dashboard.md +15 -15
- package/memory/90-decisions/0058-forja-2-approval-server-identity.md +15 -15
- package/memory/90-decisions/0059-cli-adapter-capability-registry.md +17 -17
- package/memory/90-decisions/0060-runtime-persistence-port.md +17 -17
- package/memory/90-decisions/0061-mcp-dynamic-registry-stdio.md +16 -16
- package/memory/90-decisions/0062-server-catalog-approval-audit.md +17 -17
- package/memory/90-decisions/0063-events-persistent-e2e.md +19 -19
- package/memory/90-decisions/0064-graphloop-sqlite-store.md +20 -20
- package/memory/90-decisions/0065-context-graph-source-cache.md +20 -20
- package/memory/90-decisions/0066-graph-deterministic-extractors.md +16 -16
- package/memory/90-decisions/0067-graph-sync-capability.md +17 -17
- package/memory/90-decisions/0068-graph-sync-cli-mcp.md +17 -17
- package/memory/90-decisions/0069-real-autonomy-demo.md +16 -16
- package/memory/90-decisions/0070-mcp-stdio-real.md +11 -11
- package/memory/90-decisions/0071-server-persistence-composition.md +12 -12
- package/memory/90-decisions/0072-sandbox-security-boundaries.md +9 -9
- package/memory/90-decisions/0073-last-mile-rollback-benchmark-plugins.md +17 -17
- package/memory/90-decisions/0074-llm-fit-loop-cli-adapters.md +51 -0
- package/memory/90-decisions/0075-workspace-demo-isolado.md +43 -0
- package/memory/90-decisions/0076-modos-embedded-e-studio.md +43 -0
- package/memory/90-decisions/_template.md +28 -28
- package/package.json +157 -150
- package/prompts/context-engineer-agent.md +19 -19
- package/prompts/governance-agent.md +16 -16
- package/prompts/marketing-agent.md +13 -13
- package/prompts/orchestrator-agent.md +18 -18
- package/prompts/product-agent.md +13 -13
- package/prompts/sdd-architect-agent.md +20 -20
- package/specs/README.md +70 -70
- package/specs/_templates/plan.md +43 -43
- package/specs/_templates/spec.md +43 -43
- package/specs/_templates/tasks.md +32 -32
- package/specs/clean-arch-boilerplate/plan.md +137 -137
- package/specs/clean-arch-boilerplate/spec.md +121 -121
- package/specs/clean-arch-boilerplate/tasks.md +70 -70
- package/specs/cli-first-operacao/plan.md +53 -53
- package/specs/cli-first-operacao/spec.md +53 -53
- package/specs/cli-first-operacao/tasks.md +53 -53
- package/specs/code-context/spec.md +56 -56
- package/specs/coerencia-do-sistema/plan.md +155 -155
- package/specs/coerencia-do-sistema/spec.md +123 -123
- package/specs/coerencia-do-sistema/tasks.md +115 -115
- package/specs/dev-token-assets-db/plan.md +71 -71
- package/specs/dev-token-assets-db/spec.md +58 -58
- package/specs/dev-token-assets-db/tasks.md +58 -58
- package/specs/doctor-do-nucleo/plan.md +165 -165
- package/specs/doctor-do-nucleo/spec.md +139 -139
- package/specs/doctor-do-nucleo/tasks.md +172 -172
- package/specs/forja-core/spec.md +71 -71
- package/specs/gates/spec.md +63 -63
- package/specs/governanca-visivel/plan.md +122 -122
- package/specs/governanca-visivel/spec.md +112 -112
- package/specs/governanca-visivel/tasks.md +60 -60
- package/specs/harness-codegraph/spec.md +71 -71
- package/specs/memory-audit/spec.md +54 -54
- package/specs/orchestrate/spec.md +108 -108
- package/specs/orchestration-coherent/spec.md +95 -95
- package/specs/pipeline-sdd-e-orquestracao/spec.md +61 -61
- package/specs/project-smoke/spec.md +96 -96
- package/specs/project-upgrade/spec.md +58 -58
- package/specs/reestruturacao-forja-v2/plan.md +95 -95
- package/specs/reestruturacao-forja-v2/spec.md +74 -74
- package/specs/reestruturacao-forja-v2/tasks.md +113 -113
- package/specs/release-auditor-health/plan.md +88 -0
- package/specs/release-auditor-health/spec.md +82 -0
- package/specs/release-auditor-health/tasks.md +72 -0
- package/specs/release-gate/plan.md +174 -174
- package/specs/release-gate/spec.md +122 -122
- package/specs/release-gate/tasks.md +183 -183
- package/specs/ts-migration/plan.md +200 -200
- package/specs/ts-migration/spec.md +119 -119
- package/specs/ts-migration/tasks.md +110 -110
- package/dist/scripts/server-persistence-probe.d.ts +0 -1
- package/dist/scripts/server-persistence-probe.js +0 -52
- package/dist/scripts/server-persistence-probe.mjs +0 -52
- /package/dist/scripts/{server-persistence-probe.d.mts → llm-fit.d.ts} +0 -0
|
@@ -1,1486 +1,1486 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import process from 'node:process';
|
|
5
|
-
|
|
6
|
-
const args = process.argv.slice(2);
|
|
7
|
-
const showHelp = args.includes('--help') || args.includes('-h');
|
|
8
|
-
|
|
9
|
-
if (showHelp) {
|
|
10
|
-
console.log(`
|
|
11
|
-
create-memory-nest-kit v0.5.0
|
|
12
|
-
|
|
13
|
-
Uso:
|
|
14
|
-
create-memory-nest-kit [diretorio] [opcoes]
|
|
15
|
-
|
|
16
|
-
Opcoes:
|
|
17
|
-
--force Sobrescreve arquivos existentes
|
|
18
|
-
--only-memory Gera apenas estrutura de memoria/agents/skills
|
|
19
|
-
--no-gitkeep Nao cria .gitkeep em diretorios vazios
|
|
20
|
-
-h, --help Mostra esta ajuda
|
|
21
|
-
`);
|
|
22
|
-
process.exit(0);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const options = {
|
|
26
|
-
force: args.includes('--force'),
|
|
27
|
-
noGitkeep: args.includes('--no-gitkeep'),
|
|
28
|
-
onlyMemory: args.includes('--only-memory')
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const rawTarget = args.find((a) => !a.startsWith('-')) || '.';
|
|
32
|
-
const targetDir = path.resolve(process.cwd(), rawTarget);
|
|
33
|
-
const projectName = path.basename(targetDir);
|
|
34
|
-
|
|
35
|
-
function log(message) {
|
|
36
|
-
console.log(message);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function ensureDir(dirPath) {
|
|
40
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function writeFileSafe(filePath, content) {
|
|
44
|
-
if (fs.existsSync(filePath) && !options.force) {
|
|
45
|
-
throw new Error(`Arquivo ja existe: ${filePath}. Use --force para sobrescrever.`);
|
|
46
|
-
}
|
|
47
|
-
ensureDir(path.dirname(filePath));
|
|
48
|
-
fs.writeFileSync(filePath, content, 'utf8');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function maybeGitkeep(dirPath) {
|
|
52
|
-
if (options.noGitkeep) return;
|
|
53
|
-
const keepFile = path.join(dirPath, '.gitkeep');
|
|
54
|
-
if (!fs.existsSync(keepFile)) {
|
|
55
|
-
fs.writeFileSync(keepFile, '', 'utf8');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function writeMemoryAndOps(base) {
|
|
60
|
-
const files = {
|
|
61
|
-
'memory/README.md': `# Memoria do Projeto
|
|
62
|
-
|
|
63
|
-
Esta estrutura foi desenhada para reduzir perda de contexto em projetos grandes.
|
|
64
|
-
|
|
65
|
-
## Principio
|
|
66
|
-
- Nao depender de um unico contexto gigante.
|
|
67
|
-
- Trabalhar com memoria em camadas + handoff incremental.
|
|
68
|
-
- Registrar decisoes, resumos e execucoes para continuidade.
|
|
69
|
-
`,
|
|
70
|
-
|
|
71
|
-
'memory/00-global/mission.md': `# Missao do Projeto
|
|
72
|
-
|
|
73
|
-
Construir software com clareza arquitetural, seguranca by-default e entrega continua.
|
|
74
|
-
|
|
75
|
-
## Principios
|
|
76
|
-
- Simplicidade primeiro
|
|
77
|
-
- Decisoes explicitas em ADR
|
|
78
|
-
- Qualidade e seguranca desde o inicio
|
|
79
|
-
- Documentacao viva
|
|
80
|
-
`,
|
|
81
|
-
|
|
82
|
-
'memory/00-global/standards.md': `# Padroes Globais
|
|
83
|
-
|
|
84
|
-
## Idioma
|
|
85
|
-
- Toda comunicacao e documentacao em **pt-BR**.
|
|
86
|
-
|
|
87
|
-
## Backend
|
|
88
|
-
- API criada em **NestJS** por padrao.
|
|
89
|
-
- Arquitetura modular por dominio.
|
|
90
|
-
|
|
91
|
-
## Qualidade
|
|
92
|
-
- Cada mudanca deve registrar impacto, risco e rollback.
|
|
93
|
-
- Priorizar padroes reutilizaveis.
|
|
94
|
-
`,
|
|
95
|
-
|
|
96
|
-
'memory/00-global/context-policy.md': `# Politica de Contexto Longo
|
|
97
|
-
|
|
98
|
-
## Objetivo
|
|
99
|
-
Permitir trabalho em larga escala sem depender de janela unica gigantesca.
|
|
100
|
-
|
|
101
|
-
## Regras
|
|
102
|
-
- Usar contexto em camadas: global -> dominio -> tarefa -> diff.
|
|
103
|
-
- Antes de cada tarefa: carregar apenas arquivos necessarios.
|
|
104
|
-
- A cada entrega: gerar resumo curto em memory/70-summaries.
|
|
105
|
-
- Em mudancas grandes: registrar handoff em memory/50-orchestration/handoffs.
|
|
106
|
-
|
|
107
|
-
## 🔄 Protocolo de Recuperacao (Engine Switch)
|
|
108
|
-
Se houver esgotamento de cota ou necessidade de mudar de IA:
|
|
109
|
-
1. Localize o arquivo \`.ia-instructions/models.json\`.
|
|
110
|
-
2. Identifique o proximo motor na \`fallback_chain\`.
|
|
111
|
-
3. Carregue as instrucoes do novo motor.
|
|
112
|
-
4. Forneca o conteúdo de \`.context/context-pack.md\` + o ultimo arquivo em \`memory/50-orchestration/handoffs/\`.
|
|
113
|
-
5. O novo motor assumira o trabalho a partir do ponto exato da ultima entrega.
|
|
114
|
-
|
|
115
|
-
## Nota importante
|
|
116
|
-
Esta estrutura **nao aumenta** limite nativo do modelo.
|
|
117
|
-
Ela reduz perda de memoria por segmentacao, resumo e continuidade operacional.
|
|
118
|
-
`,
|
|
119
|
-
|
|
120
|
-
'memory/00-global/agent-contract.md': `# Contrato de Agentes
|
|
121
|
-
|
|
122
|
-
## Orquestrador
|
|
123
|
-
- Decompõe trabalho em subtarefas independentes.
|
|
124
|
-
- Define dono por escopo de arquivo.
|
|
125
|
-
- Consolida handoffs e conflitos.
|
|
126
|
-
|
|
127
|
-
## Workers
|
|
128
|
-
- Implementam subtarefas com escopo claro.
|
|
129
|
-
- Nao alteram areas de outros agentes sem alinhamento.
|
|
130
|
-
- Entregam: alteracoes, riscos, testes e pendencias.
|
|
131
|
-
|
|
132
|
-
## Reviewer
|
|
133
|
-
- Verifica regressao, seguranca e cobertura de testes.
|
|
134
|
-
- Bloqueia merge se encontrar risco critico.
|
|
135
|
-
`,
|
|
136
|
-
|
|
137
|
-
'memory/00-global/context-index.md': `# Indice de Contexto
|
|
138
|
-
|
|
139
|
-
## Ordem de Leitura
|
|
140
|
-
1. memory/00-global/mission.md
|
|
141
|
-
2. memory/00-global/standards.md
|
|
142
|
-
3. memory/00-global/context-policy.md
|
|
143
|
-
4. memory/10-product/*
|
|
144
|
-
5. memory/20-architecture/*
|
|
145
|
-
6. memory/30-domains/<dominio>/*
|
|
146
|
-
7. memory/40-delivery/current-sprint.md
|
|
147
|
-
8. memory/90-decisions/ADR-*.md
|
|
148
|
-
9. memory/70-summaries/*
|
|
149
|
-
`,
|
|
150
|
-
|
|
151
|
-
'memory/10-product/vision.md': `# Visao de Produto
|
|
152
|
-
|
|
153
|
-
Descreva objetivo, publico-alvo, problema e proposta de valor.
|
|
154
|
-
`,
|
|
155
|
-
|
|
156
|
-
'memory/10-product/personas.md': `# Personas
|
|
157
|
-
|
|
158
|
-
Liste personas e dores principais.
|
|
159
|
-
`,
|
|
160
|
-
|
|
161
|
-
'memory/10-product/business-rules.md': `# Regras de Negocio
|
|
162
|
-
|
|
163
|
-
Documente regras imutaveis e validacoes criticas.
|
|
164
|
-
`,
|
|
165
|
-
|
|
166
|
-
'memory/10-product/nfrs.md': `# Requisitos Nao Funcionais
|
|
167
|
-
|
|
168
|
-
- Performance
|
|
169
|
-
- Seguranca
|
|
170
|
-
- Observabilidade
|
|
171
|
-
- Escalabilidade
|
|
172
|
-
`,
|
|
173
|
-
|
|
174
|
-
'memory/20-architecture/system-overview.md': `# Visao Geral da Arquitetura
|
|
175
|
-
|
|
176
|
-
Descreva contexto, fronteiras e integracoes principais.
|
|
177
|
-
`,
|
|
178
|
-
|
|
179
|
-
'memory/20-architecture/frontend.md': `# Frontend
|
|
180
|
-
|
|
181
|
-
Defina padroes de componentizacao, acessibilidade e performance.
|
|
182
|
-
`,
|
|
183
|
-
|
|
184
|
-
'memory/20-architecture/backend.md': `# Backend
|
|
185
|
-
|
|
186
|
-
## Diretriz principal
|
|
187
|
-
- Backend em **NestJS** por padrao.
|
|
188
|
-
|
|
189
|
-
## Estrutura sugerida
|
|
190
|
-
- Modulos por dominio
|
|
191
|
-
- DTO + validacao
|
|
192
|
-
- Servicos com regras de negocio
|
|
193
|
-
- Repositorios/integradores isolados
|
|
194
|
-
`,
|
|
195
|
-
|
|
196
|
-
'memory/20-architecture/data.md': `# Dados
|
|
197
|
-
|
|
198
|
-
Descreva entidades, relacionamentos e politicas de retencao.
|
|
199
|
-
`,
|
|
200
|
-
|
|
201
|
-
'memory/20-architecture/security.md': `# Seguranca
|
|
202
|
-
|
|
203
|
-
- Principio do menor privilegio
|
|
204
|
-
- Segredos fora do codigo
|
|
205
|
-
- Validacao de entrada em todas as rotas
|
|
206
|
-
- Logs sem dados sensiveis
|
|
207
|
-
`,
|
|
208
|
-
|
|
209
|
-
'memory/20-architecture/observability.md': `# Observabilidade
|
|
210
|
-
|
|
211
|
-
- Logs estruturados
|
|
212
|
-
- Metricas e tracing
|
|
213
|
-
- Alertas por SLO
|
|
214
|
-
`,
|
|
215
|
-
|
|
216
|
-
'memory/30-domains/auth/context.md': `# Contexto de Auth
|
|
217
|
-
|
|
218
|
-
Defina escopo funcional de autenticacao/autorizacao.
|
|
219
|
-
`,
|
|
220
|
-
|
|
221
|
-
'memory/30-domains/auth/rules.md': `# Regras de Auth
|
|
222
|
-
|
|
223
|
-
Liste regras e restricoes de seguranca.
|
|
224
|
-
`,
|
|
225
|
-
|
|
226
|
-
'memory/30-domains/auth/api.md': `# API de Auth
|
|
227
|
-
|
|
228
|
-
Documente endpoints, payloads e erros.
|
|
229
|
-
`,
|
|
230
|
-
|
|
231
|
-
'memory/30-domains/billing/context.md': `# Contexto de Billing
|
|
232
|
-
|
|
233
|
-
Defina cobranca, ciclo e integracoes.
|
|
234
|
-
`,
|
|
235
|
-
|
|
236
|
-
'memory/30-domains/billing/rules.md': `# Regras de Billing
|
|
237
|
-
|
|
238
|
-
Descreva calculos, status e excecoes.
|
|
239
|
-
`,
|
|
240
|
-
|
|
241
|
-
'memory/30-domains/billing/api.md': `# API de Billing
|
|
242
|
-
|
|
243
|
-
Documente endpoints e regras de idempotencia.
|
|
244
|
-
`,
|
|
245
|
-
|
|
246
|
-
'memory/40-delivery/roadmap.md': `# Roadmap
|
|
247
|
-
|
|
248
|
-
Mapeie entregas por trimestre/sprint.
|
|
249
|
-
`,
|
|
250
|
-
|
|
251
|
-
'memory/40-delivery/current-sprint.md': `# Sprint Atual
|
|
252
|
-
|
|
253
|
-
## Objetivos
|
|
254
|
-
-
|
|
255
|
-
|
|
256
|
-
## Itens
|
|
257
|
-
-
|
|
258
|
-
|
|
259
|
-
## Riscos
|
|
260
|
-
-
|
|
261
|
-
`,
|
|
262
|
-
|
|
263
|
-
'memory/40-delivery/backlog.md': `# Backlog
|
|
264
|
-
|
|
265
|
-
Liste itens priorizados com contexto minimo.
|
|
266
|
-
`,
|
|
267
|
-
|
|
268
|
-
'memory/50-orchestration/topology.md': `# Topologia Multiagente
|
|
269
|
-
|
|
270
|
-
## Papeis
|
|
271
|
-
- Orquestrador
|
|
272
|
-
- Worker Backend (NestJS)
|
|
273
|
-
- Worker Frontend
|
|
274
|
-
- Worker DBA
|
|
275
|
-
- Worker Security
|
|
276
|
-
- Reviewer
|
|
277
|
-
|
|
278
|
-
## Fluxo
|
|
279
|
-
1. Orquestrador cria plano e fatia trabalho.
|
|
280
|
-
2. Workers executam em paralelo com escopo isolado.
|
|
281
|
-
3. Handoffs sao registrados.
|
|
282
|
-
4. Reviewer valida e aprova.
|
|
283
|
-
`,
|
|
284
|
-
|
|
285
|
-
'memory/50-orchestration/routing.md': `# Roteamento de Tarefas
|
|
286
|
-
|
|
287
|
-
## Regras de roteamento
|
|
288
|
-
- API e dominio server-side -> backend-nest
|
|
289
|
-
- Schema/migracao/query -> dba
|
|
290
|
-
- Auth, hardening, segredos -> security
|
|
291
|
-
- UX/componentes -> frontend
|
|
292
|
-
|
|
293
|
-
## Critico
|
|
294
|
-
Subtarefas devem ter dono unico por arquivo para evitar conflito.
|
|
295
|
-
`,
|
|
296
|
-
|
|
297
|
-
'memory/50-orchestration/handoff-protocol.md': `# Protocolo de Handoff
|
|
298
|
-
|
|
299
|
-
Cada handoff deve conter:
|
|
300
|
-
- contexto minimo
|
|
301
|
-
- alteracoes realizadas
|
|
302
|
-
- arquivos tocados
|
|
303
|
-
- riscos e pontos abertos
|
|
304
|
-
- proximos passos objetivos
|
|
305
|
-
`,
|
|
306
|
-
|
|
307
|
-
'memory/50-orchestration/parallel-playbook.md': `# Playbook de Paralelizacao
|
|
308
|
-
|
|
309
|
-
## Quando paralelizar
|
|
310
|
-
- Subtarefas independentes por dominio.
|
|
311
|
-
- Escopo de escrita sem sobreposicao.
|
|
312
|
-
|
|
313
|
-
## Quando nao paralelizar
|
|
314
|
-
- Mudanca bloqueante para a proxima etapa.
|
|
315
|
-
- Refactor altamente acoplado no mesmo modulo.
|
|
316
|
-
`,
|
|
317
|
-
|
|
318
|
-
'memory/50-orchestration/handoffs/README.md': `# Handoffs
|
|
319
|
-
|
|
320
|
-
Registre cada transicao em arquivos markdown com timestamp.
|
|
321
|
-
Exemplo: 2026-04-18T12-30_worker-backend_para_reviewer.md
|
|
322
|
-
`,
|
|
323
|
-
|
|
324
|
-
'memory/60-runs/README.md': `# Runs
|
|
325
|
-
|
|
326
|
-
Log de execucao por ciclo/sprint.
|
|
327
|
-
`,
|
|
328
|
-
|
|
329
|
-
'memory/70-summaries/global-summary.md': `# Resumo Global
|
|
330
|
-
|
|
331
|
-
Atualize a cada marco importante com:
|
|
332
|
-
- estado atual
|
|
333
|
-
- decisoes novas
|
|
334
|
-
- riscos ativos
|
|
335
|
-
`,
|
|
336
|
-
|
|
337
|
-
'memory/70-summaries/domain-summary.md': `# Resumo por Dominio
|
|
338
|
-
|
|
339
|
-
Mantenha resumos curtos por dominio para carregamento rapido de contexto.
|
|
340
|
-
`,
|
|
341
|
-
|
|
342
|
-
'memory/80-data/memory-db.md': `# Memory DB (SQLite)
|
|
343
|
-
|
|
344
|
-
## Objetivo
|
|
345
|
-
Armazenar indice operacional da documentacao para busca e continuidade de contexto.
|
|
346
|
-
|
|
347
|
-
## Fonte da verdade
|
|
348
|
-
- Arquivos Markdown em memory/, docs/, agents/, skills/, prompts/
|
|
349
|
-
|
|
350
|
-
## Banco
|
|
351
|
-
- SQLite em .memory/sqlite/context.db
|
|
352
|
-
|
|
353
|
-
## Fluxo
|
|
354
|
-
1. Atualizar markdown
|
|
355
|
-
2. Rodar sincronizacao
|
|
356
|
-
3. Consultar contexto por texto ou tipo
|
|
357
|
-
`,
|
|
358
|
-
|
|
359
|
-
'memory/90-decisions/ADR-0001-template.md': `# ADR-0001: Titulo da Decisao
|
|
360
|
-
|
|
361
|
-
## Contexto
|
|
362
|
-
|
|
363
|
-
## Decisao
|
|
364
|
-
|
|
365
|
-
## Consequencias
|
|
366
|
-
|
|
367
|
-
## Alternativas consideradas
|
|
368
|
-
`,
|
|
369
|
-
|
|
370
|
-
'agents/README.md': `# Agents
|
|
371
|
-
|
|
372
|
-
Agentes especializados para dividir trabalho em paralelo.
|
|
373
|
-
`,
|
|
374
|
-
|
|
375
|
-
'agents/orchestrator.md': `# Agent: Orchestrator
|
|
376
|
-
|
|
377
|
-
## Responsabilidade
|
|
378
|
-
Planejamento, decomposicao de tarefas, atribuicao de ownership e consolidacao.
|
|
379
|
-
|
|
380
|
-
## Entrega minima
|
|
381
|
-
- plano objetivo
|
|
382
|
-
- distribuicao por agentes
|
|
383
|
-
- consolidacao de handoffs
|
|
384
|
-
`,
|
|
385
|
-
|
|
386
|
-
'agents/backend-nest.md': `# Agent: Backend NestJS
|
|
387
|
-
|
|
388
|
-
## Escopo
|
|
389
|
-
- modulos, controllers, services, dto, guard, pipe
|
|
390
|
-
- testes unitarios e e2e da API
|
|
391
|
-
|
|
392
|
-
## Padrao
|
|
393
|
-
- NestJS por padrao
|
|
394
|
-
- validacao de entrada obrigatoria
|
|
395
|
-
`,
|
|
396
|
-
|
|
397
|
-
'agents/frontend.md': `# Agent: Frontend
|
|
398
|
-
|
|
399
|
-
## Escopo
|
|
400
|
-
- componentes, acessibilidade, performance, UX
|
|
401
|
-
`,
|
|
402
|
-
|
|
403
|
-
'agents/dba.md': `# Agent: DBA
|
|
404
|
-
|
|
405
|
-
## Escopo
|
|
406
|
-
- modelagem, indices, migracoes, tuning de query
|
|
407
|
-
`,
|
|
408
|
-
|
|
409
|
-
'agents/security.md': `# Agent: Security
|
|
410
|
-
|
|
411
|
-
## Escopo
|
|
412
|
-
- threat modeling, hardening, authz/authn, secrets, auditoria
|
|
413
|
-
`,
|
|
414
|
-
|
|
415
|
-
'agents/reviewer.md': `# Agent: Reviewer
|
|
416
|
-
|
|
417
|
-
## Escopo
|
|
418
|
-
- regressao funcional
|
|
419
|
-
- riscos de seguranca
|
|
420
|
-
- cobertura de testes
|
|
421
|
-
`,
|
|
422
|
-
|
|
423
|
-
'skills/triage-task/SKILL.md': `# Skill: Triage de Tarefa
|
|
424
|
-
|
|
425
|
-
## Objetivo
|
|
426
|
-
Classificar demanda em: rapido, medio, complexo.
|
|
427
|
-
|
|
428
|
-
## Saida
|
|
429
|
-
- resumo
|
|
430
|
-
- risco
|
|
431
|
-
- owner sugerido
|
|
432
|
-
- fatias de execucao
|
|
433
|
-
`,
|
|
434
|
-
|
|
435
|
-
'skills/context-compaction/SKILL.md': `# Skill: Compactacao de Contexto
|
|
436
|
-
|
|
437
|
-
## Objetivo
|
|
438
|
-
Gerar resumo operacional sem perder decisoes chave.
|
|
439
|
-
|
|
440
|
-
## Regras
|
|
441
|
-
- manter fatos verificaveis
|
|
442
|
-
- remover redundancia
|
|
443
|
-
- preservar links para fontes internas
|
|
444
|
-
`,
|
|
445
|
-
|
|
446
|
-
'skills/handoff/SKILL.md': `# Skill: Handoff
|
|
447
|
-
|
|
448
|
-
## Template
|
|
449
|
-
- contexto
|
|
450
|
-
- alteracoes
|
|
451
|
-
- riscos
|
|
452
|
-
- pendencias
|
|
453
|
-
- proximo agente
|
|
454
|
-
`,
|
|
455
|
-
|
|
456
|
-
'skills/nest-api/SKILL.md': `# Skill: Nest API
|
|
457
|
-
|
|
458
|
-
## Checklist
|
|
459
|
-
- modulo criado
|
|
460
|
-
- dto com validacao
|
|
461
|
-
- controller + service
|
|
462
|
-
- testes
|
|
463
|
-
`,
|
|
464
|
-
|
|
465
|
-
'skills/self-healing/SKILL.md': `# Skill: Auto-Diagnóstico (Self-Healing)
|
|
466
|
-
|
|
467
|
-
## Objetivo
|
|
468
|
-
Resolver falhas de build, testes ou tipos sem intervenção humana.
|
|
469
|
-
|
|
470
|
-
## Fluxo
|
|
471
|
-
1. Analisar a stack trace completa do erro.
|
|
472
|
-
2. Identificar se é: erro de sintaxe, falta de dependência, erro de tipo ou lógica.
|
|
473
|
-
3. Consultar documentação interna ou padrões do projeto.
|
|
474
|
-
4. Propor correção mínima e rodar validação novamente.
|
|
475
|
-
`,
|
|
476
|
-
|
|
477
|
-
'skills/validate-handoff/SKILL.md': `# Skill: Validação e Review de Segurança (Gatekeeper)
|
|
478
|
-
|
|
479
|
-
## Objetivo
|
|
480
|
-
Atuar como Gatekeeper final para garantir que nenhum código inseguro ou incompleto entre no pipeline.
|
|
481
|
-
|
|
482
|
-
## Protocolo de Review (Obrigatório)
|
|
483
|
-
Antes de aceitar um handoff, o Reviewer deve validar:
|
|
484
|
-
|
|
485
|
-
1. **Compliance de Raciocínio**: O Worker preencheu o bloco \`## Raciocínio Estruturado\`? (Se não, rejeite imediatamente).
|
|
486
|
-
2. **Scan de Segurança**:
|
|
487
|
-
- Há logs sensíveis (PII, tokens) sendo impressos?
|
|
488
|
-
- As validações de input estão no DTO?
|
|
489
|
-
3. **Verificação de Handoff**:
|
|
490
|
-
- Os arquivos listados no handoff condizem com o diff real?
|
|
491
|
-
- Existem pendências (riscos) não documentadas?
|
|
492
|
-
|
|
493
|
-
## Saída do Reviewer
|
|
494
|
-
- [ ] Aprovado (Status: \`done\` no DB)
|
|
495
|
-
- [ ] Rejeitado (Status: \`blocked\` + pendências listadas)
|
|
496
|
-
`,
|
|
497
|
-
|
|
498
|
-
'skills/ui-fidelity/SKILL.md': `# Skill: Fidelidade Visual
|
|
499
|
-
|
|
500
|
-
## Objetivo
|
|
501
|
-
Garantir que a UI segue padrões de elite.
|
|
502
|
-
|
|
503
|
-
## Instrução
|
|
504
|
-
1. Consultar a biblioteca \`design-md/\` para inspiração de marca/padrão.
|
|
505
|
-
2. Comparar o código gerado com os padrões de espaçamento, tipografia e cores da referência.
|
|
506
|
-
3. Ajustar CSS/Componentes para atingir qualidade visual de nível mundial.
|
|
507
|
-
`,
|
|
508
|
-
|
|
509
|
-
'skills/reasoning-protocol/SKILL.md': `# Skill: Raciocínio Estruturado (Chain-of-Thought)
|
|
510
|
-
|
|
511
|
-
## Objetivo
|
|
512
|
-
Reduzir erros de implementação através de análise lógica explícita.
|
|
513
|
-
|
|
514
|
-
## Protocolo Obrigatório
|
|
515
|
-
Antes de qualquer código ou plano de ação, preencha o bloco \`## Raciocínio Estruturado\`:
|
|
516
|
-
|
|
517
|
-
1. **Entendimento**: O que foi pedido e qual o impacto no sistema?
|
|
518
|
-
2. **Restrições**: Quais arquivos NÃO posso tocar? Quais padrões devo seguir?
|
|
519
|
-
3. **Alternativas**: Existe mais de uma forma de fazer? Por que escolhi esta?
|
|
520
|
-
4. **Plano de Ataque**: Passo-a-passo lógico da implementação.
|
|
521
|
-
`,
|
|
522
|
-
|
|
523
|
-
'skills/MANIFEST.json': `{
|
|
524
|
-
"version": "0.5.0",
|
|
525
|
-
"skills": [
|
|
526
|
-
{ "id": "triage", "path": "skills/triage-task/SKILL.md", "description": "Classificação de tarefas" },
|
|
527
|
-
{ "id": "compaction", "path": "skills/context-compaction/SKILL.md", "description": "Compactação de memória" },
|
|
528
|
-
{ "id": "handoff", "path": "skills/handoff/SKILL.md", "description": "Protocolo de transição" },
|
|
529
|
-
{ "id": "nest-api", "path": "skills/nest-api/SKILL.md", "description": "Geração de endpoints NestJS" },
|
|
530
|
-
{ "id": "self-healing", "path": "skills/self-healing/SKILL.md", "description": "Resolução autônoma de erros" },
|
|
531
|
-
{ "id": "validate-handoff", "path": "skills/validate-handoff/SKILL.md", "description": "Checklist de qualidade de handoff" },
|
|
532
|
-
{ "id": "ui-fidelity", "path": "skills/ui-fidelity/SKILL.md", "description": "Auditoria estética de UI" },
|
|
533
|
-
{ "id": "reasoning", "path": "skills/reasoning-protocol/SKILL.md", "description": "Protocolo de raciocínio lógico" }
|
|
534
|
-
]
|
|
535
|
-
}
|
|
536
|
-
`,
|
|
537
|
-
|
|
538
|
-
'prompts/project-prompt-base.md': `# Prompt Base do Projeto
|
|
539
|
-
|
|
540
|
-
Voce e um agente de engenharia sênior neste repositorio.
|
|
541
|
-
|
|
542
|
-
Prioridade de contexto:
|
|
543
|
-
1. memory/00-global/mission.md
|
|
544
|
-
2. memory/00-global/standards.md
|
|
545
|
-
3. memory/00-global/context-policy.md
|
|
546
|
-
4. memory/10-product/*
|
|
547
|
-
5. memory/20-architecture/*
|
|
548
|
-
6. memory/30-domains/<dominio>/*
|
|
549
|
-
7. memory/40-delivery/current-sprint.md
|
|
550
|
-
8. memory/90-decisions/ADR-*.md
|
|
551
|
-
9. memory/70-summaries/*
|
|
552
|
-
|
|
553
|
-
Regras:
|
|
554
|
-
- comunicacao em pt-BR
|
|
555
|
-
- API em NestJS por padrao
|
|
556
|
-
- nao contradizer ADR sem sinalizar
|
|
557
|
-
- explicitar suposicoes
|
|
558
|
-
- **OBRIGATÓRIO**: Usar a skill \`reasoning\` e preencher o bloco \`## Raciocínio Estruturado\` antes de cada resposta técnica.
|
|
559
|
-
- entregar: raciocínio, entendimento, plano, implementacao, validacao e proximos passos
|
|
560
|
-
`,
|
|
561
|
-
|
|
562
|
-
'prompts/multi-agent-orchestrator.md': `# Prompt Orquestrador Multiagente
|
|
563
|
-
|
|
564
|
-
Atue como orquestrador. Divida o trabalho em subtarefas independentes, com ownership por arquivo.
|
|
565
|
-
|
|
566
|
-
Para cada subtarefa, entregue:
|
|
567
|
-
- objetivo
|
|
568
|
-
- escopo de escrita
|
|
569
|
-
- criterio de pronto
|
|
570
|
-
- risco principal
|
|
571
|
-
- agente dono
|
|
572
|
-
|
|
573
|
-
No final, consolide os handoffs em ordem cronologica.
|
|
574
|
-
`,
|
|
575
|
-
|
|
576
|
-
'prompts/worker-task-template.md': `# Prompt Worker
|
|
577
|
-
|
|
578
|
-
Voce recebeu uma subtarefa.
|
|
579
|
-
|
|
580
|
-
Responda com:
|
|
581
|
-
1. **Raciocínio Estruturado** (Uso obrigatório da skill \`reasoning\`)
|
|
582
|
-
2. Entendimento
|
|
583
|
-
3. Implementacao realizada
|
|
584
|
-
4. Arquivos alterados
|
|
585
|
-
5. Validacao/testes
|
|
586
|
-
6. Riscos e pendencias
|
|
587
|
-
`,
|
|
588
|
-
|
|
589
|
-
'AGENTS.md': `# AGENTS
|
|
590
|
-
|
|
591
|
-
## Linguagem
|
|
592
|
-
- Sempre responder e documentar em **pt-BR**.
|
|
593
|
-
|
|
594
|
-
## Stack
|
|
595
|
-
- API padrao do projeto: **NestJS**.
|
|
596
|
-
|
|
597
|
-
## Modo multiagente
|
|
598
|
-
- Orquestrador decompõe tarefas
|
|
599
|
-
- Workers executam em paralelo por ownership
|
|
600
|
-
- Reviewer valida riscos
|
|
601
|
-
|
|
602
|
-
## Memoria
|
|
603
|
-
- Seguir hierarchy em /memory
|
|
604
|
-
- Registrar handoff e resumo ao fim de cada entrega relevante
|
|
605
|
-
`,
|
|
606
|
-
|
|
607
|
-
'.memoryrc.json': `{
|
|
608
|
-
"strategy": "hierarchical",
|
|
609
|
-
"maxContextHint": "1M+ por segmentacao e resumo incremental",
|
|
610
|
-
"handoffDir": "memory/50-orchestration/handoffs",
|
|
611
|
-
"summaryDir": "memory/70-summaries",
|
|
612
|
-
"sqlitePath": ".memory/sqlite/context.db",
|
|
613
|
-
"language": "pt-BR",
|
|
614
|
-
"backendDefault": "nestjs"
|
|
615
|
-
}
|
|
616
|
-
`,
|
|
617
|
-
|
|
618
|
-
'scripts/build-context-pack.mjs': `import fs from 'node:fs';
|
|
619
|
-
import path from 'node:path';
|
|
620
|
-
import { fileURLToPath } from 'node:url';
|
|
621
|
-
|
|
622
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
623
|
-
const __dirname = path.dirname(__filename);
|
|
624
|
-
const root = path.resolve(__dirname, '..');
|
|
625
|
-
const outputDir = path.join(root, '.context');
|
|
626
|
-
const outFile = path.join(outputDir, 'context-pack.md');
|
|
627
|
-
|
|
628
|
-
const priorityFiles = [
|
|
629
|
-
'memory/00-global/mission.md',
|
|
630
|
-
'memory/00-global/standards.md',
|
|
631
|
-
'memory/00-global/context-policy.md',
|
|
632
|
-
'memory/20-architecture/backend.md',
|
|
633
|
-
'memory/40-delivery/current-sprint.md',
|
|
634
|
-
'memory/70-summaries/global-summary.md'
|
|
635
|
-
];
|
|
636
|
-
|
|
637
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
638
|
-
let content = '# Context Pack\\n\\n';
|
|
639
|
-
|
|
640
|
-
for (const rel of priorityFiles) {
|
|
641
|
-
const abs = path.join(root, rel);
|
|
642
|
-
if (!fs.existsSync(abs)) continue;
|
|
643
|
-
const raw = fs.readFileSync(abs, 'utf8').slice(0, 6000);
|
|
644
|
-
content += '## ' + rel + '\\n\\n' + raw + '\\n\\n';
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
fs.writeFileSync(outFile, content, 'utf8');
|
|
648
|
-
console.log('Context pack gerado em: ' + outFile);
|
|
649
|
-
`,
|
|
650
|
-
|
|
651
|
-
'scripts/append-handoff.mjs': `import fs from 'node:fs';
|
|
652
|
-
import path from 'node:path';
|
|
653
|
-
import { fileURLToPath } from 'node:url';
|
|
654
|
-
|
|
655
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
656
|
-
const __dirname = path.dirname(__filename);
|
|
657
|
-
const root = path.resolve(__dirname, '..');
|
|
658
|
-
|
|
659
|
-
const [from = 'agente-a', to = 'agente-b', title = 'handoff'] = process.argv.slice(2);
|
|
660
|
-
const dir = path.join(root, 'memory/50-orchestration/handoffs');
|
|
661
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
662
|
-
|
|
663
|
-
const stamp = new Date().toISOString().replace(/[:]/g, '-');
|
|
664
|
-
const file = path.join(dir, stamp + '_' + from + '_para_' + to + '.md');
|
|
665
|
-
|
|
666
|
-
const template = '# Handoff: ' + from + ' -> ' + to + '\\n\\n'
|
|
667
|
-
+ '## Titulo\\n' + title + '\\n\\n'
|
|
668
|
-
+ '## Contexto\\n-\\n\\n'
|
|
669
|
-
+ '## Alteracoes\\n-\\n\\n'
|
|
670
|
-
+ '## Riscos\\n-\\n\\n'
|
|
671
|
-
+ '## Pendencias\\n-\\n\\n'
|
|
672
|
-
+ '## Proximo passo\\n-\\n';
|
|
673
|
-
|
|
674
|
-
fs.writeFileSync(file, template, 'utf8');
|
|
675
|
-
console.log('Handoff criado: ' + file);
|
|
676
|
-
`,
|
|
677
|
-
|
|
678
|
-
'scripts/lib/skill-loader.mjs': `import fs from 'node:fs';
|
|
679
|
-
import path from 'node:path';
|
|
680
|
-
import { fileURLToPath } from 'node:url';
|
|
681
|
-
|
|
682
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
683
|
-
const __dirname = path.dirname(__filename);
|
|
684
|
-
const root = path.resolve(__dirname, '..', '..');
|
|
685
|
-
|
|
686
|
-
export function loadSkills() {
|
|
687
|
-
const manifestPath = path.join(root, 'skills', 'MANIFEST.json');
|
|
688
|
-
if (!fs.existsSync(manifestPath)) return [];
|
|
689
|
-
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
690
|
-
return manifest.skills;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
export function getSkill(id) {
|
|
694
|
-
const skills = loadSkills();
|
|
695
|
-
return skills.find(s => s.id === id);
|
|
696
|
-
}
|
|
697
|
-
`,
|
|
698
|
-
|
|
699
|
-
'scripts/memory-vacuum.mjs': `import fs from 'node:fs';
|
|
700
|
-
import path from 'node:path';
|
|
701
|
-
import { fileURLToPath } from 'node:url';
|
|
702
|
-
|
|
703
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
704
|
-
const __dirname = path.dirname(__filename);
|
|
705
|
-
const root = path.resolve(__dirname, '..');
|
|
706
|
-
const runsDir = path.join(root, 'memory/60-runs');
|
|
707
|
-
const archiveDir = path.join(runsDir, 'archive');
|
|
708
|
-
|
|
709
|
-
const TTL_DAYS = 30;
|
|
710
|
-
const now = Date.now();
|
|
711
|
-
|
|
712
|
-
if (!fs.existsSync(runsDir)) process.exit(0);
|
|
713
|
-
if (!fs.existsSync(archiveDir)) fs.mkdirSync(archiveDir, { recursive: true });
|
|
714
|
-
|
|
715
|
-
const entries = fs.readdirSync(runsDir, { withFileTypes: true });
|
|
716
|
-
|
|
717
|
-
let archived = 0;
|
|
718
|
-
for (const entry of entries) {
|
|
719
|
-
if (entry.name === 'README.md' || entry.name === 'archive' || entry.name === '.gitkeep') continue;
|
|
720
|
-
|
|
721
|
-
const abs = path.join(runsDir, entry.name);
|
|
722
|
-
const stats = fs.statSync(abs);
|
|
723
|
-
const ageDays = (now - stats.mtimeMs) / (1000 * 60 * 60 * 24);
|
|
724
|
-
|
|
725
|
-
if (ageDays > TTL_DAYS) {
|
|
726
|
-
const dest = path.join(archiveDir, entry.name);
|
|
727
|
-
fs.renameSync(abs, dest);
|
|
728
|
-
archived++;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
if (archived > 0) {
|
|
733
|
-
console.log('Vacuum: ' + archived + ' runs movidas para archive/');
|
|
734
|
-
}
|
|
735
|
-
`,
|
|
736
|
-
|
|
737
|
-
'scripts/memory-watcher.mjs': `import { watch } from 'node:fs';
|
|
738
|
-
import { exec } from 'node:child_process';
|
|
739
|
-
import path from 'node:path';
|
|
740
|
-
import { fileURLToPath } from 'node:url';
|
|
741
|
-
|
|
742
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
743
|
-
const __dirname = path.dirname(__filename);
|
|
744
|
-
const root = path.resolve(__dirname, '..');
|
|
745
|
-
|
|
746
|
-
const watchDirs = ['memory', 'agents', 'skills', 'prompts', 'docs'];
|
|
747
|
-
let timeout = null;
|
|
748
|
-
|
|
749
|
-
console.log('👀 Memory Watcher iniciado...');
|
|
750
|
-
|
|
751
|
-
watchDirs.forEach(dir => {
|
|
752
|
-
const absDir = path.join(root, dir);
|
|
753
|
-
watch(absDir, { recursive: true }, (eventType, filename) => {
|
|
754
|
-
if (filename && filename.endsWith('.md')) {
|
|
755
|
-
if (timeout) clearTimeout(timeout);
|
|
756
|
-
timeout = setTimeout(() => {
|
|
757
|
-
console.log('🔄 Mudança detectada em: ' + filename + '. Sincronizando SQLite...');
|
|
758
|
-
exec('npm run memory:db:sync', { cwd: path.join(root, 'backend') }, (err, stdout) => {
|
|
759
|
-
if (err) console.error('❌ Erro no sync: ' + err.message);
|
|
760
|
-
else console.log('✅ SQLite sincronizado.');
|
|
761
|
-
});
|
|
762
|
-
}, 1000);
|
|
763
|
-
}
|
|
764
|
-
});
|
|
765
|
-
});
|
|
766
|
-
`,
|
|
767
|
-
|
|
768
|
-
'.gitignore': `node_modules
|
|
769
|
-
dist
|
|
770
|
-
.env
|
|
771
|
-
.DS_Store
|
|
772
|
-
coverage
|
|
773
|
-
.context
|
|
774
|
-
`
|
|
775
|
-
};
|
|
776
|
-
|
|
777
|
-
for (const [relativePath, content] of Object.entries(files)) {
|
|
778
|
-
writeFileSafe(path.join(base, relativePath), content);
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
const emptyDirs = [
|
|
782
|
-
'memory/30-domains/shared',
|
|
783
|
-
'memory/90-decisions/archive',
|
|
784
|
-
'docs',
|
|
785
|
-
'scripts/lib',
|
|
786
|
-
'.memory/sqlite',
|
|
787
|
-
'.context'
|
|
788
|
-
];
|
|
789
|
-
|
|
790
|
-
for (const relDir of emptyDirs) {
|
|
791
|
-
const abs = path.join(base, relDir);
|
|
792
|
-
ensureDir(abs);
|
|
793
|
-
maybeGitkeep(abs);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
function writeNestApi(base) {
|
|
798
|
-
const files = {
|
|
799
|
-
'backend/package.json': `{
|
|
800
|
-
"name": "${projectName}-api",
|
|
801
|
-
"version": "0.1.0",
|
|
802
|
-
"private": true,
|
|
803
|
-
"scripts": {
|
|
804
|
-
"build": "nest build",
|
|
805
|
-
"start": "nest start",
|
|
806
|
-
"start:dev": "nest start --watch",
|
|
807
|
-
"start:prod": "node dist/main",
|
|
808
|
-
"lint": "eslint \\\"src/**/*.ts\\\" --max-warnings=0",
|
|
809
|
-
"format": "prettier --write \\\"src/**/*.ts\\\" \\\"test/**/*.ts\\\"",
|
|
810
|
-
"test": "jest",
|
|
811
|
-
"test:watch": "jest --watch",
|
|
812
|
-
"test:cov": "jest --coverage",
|
|
813
|
-
"memory:db:init": "node scripts/memory-db-init.mjs",
|
|
814
|
-
"memory:db:sync": "node scripts/memory-db-sync.mjs",
|
|
815
|
-
"memory:db:query": "node scripts/memory-db-query.mjs",
|
|
816
|
-
"memory:watch": "node ../scripts/memory-watcher.mjs"
|
|
817
|
-
},
|
|
818
|
-
"jest": {
|
|
819
|
-
"moduleFileExtensions": ["js", "json", "ts"],
|
|
820
|
-
"rootDir": "src",
|
|
821
|
-
"testRegex": ".*\\\\.spec\\\\.ts$",
|
|
822
|
-
"transform": {
|
|
823
|
-
"^.+\\\\.(t|j)s$": "ts-jest"
|
|
824
|
-
},
|
|
825
|
-
"collectCoverageFrom": ["**/*.(t|j)s"],
|
|
826
|
-
"coverageDirectory": "../coverage",
|
|
827
|
-
"testEnvironment": "node"
|
|
828
|
-
},
|
|
829
|
-
"dependencies": {
|
|
830
|
-
"@nestjs/common": "^11.0.0",
|
|
831
|
-
"@nestjs/core": "^11.0.0",
|
|
832
|
-
"@nestjs/platform-express": "^11.0.0",
|
|
833
|
-
"better-sqlite3": "^11.8.1",
|
|
834
|
-
"reflect-metadata": "^0.2.2",
|
|
835
|
-
"rxjs": "^7.8.1"
|
|
836
|
-
},
|
|
837
|
-
"devDependencies": {
|
|
838
|
-
"@nestjs/cli": "^11.0.0",
|
|
839
|
-
"@nestjs/schematics": "^11.0.0",
|
|
840
|
-
"@nestjs/testing": "^11.0.0",
|
|
841
|
-
"@types/express": "^5.0.1",
|
|
842
|
-
"@types/better-sqlite3": "^11.2.1",
|
|
843
|
-
"@types/jest": "^29.5.14",
|
|
844
|
-
"@types/node": "^22.10.2",
|
|
845
|
-
"@types/supertest": "^6.0.2",
|
|
846
|
-
"eslint": "^9.16.0",
|
|
847
|
-
"eslint-config-prettier": "^9.1.0",
|
|
848
|
-
"jest": "^29.7.0",
|
|
849
|
-
"prettier": "^3.4.2",
|
|
850
|
-
"supertest": "^7.0.0",
|
|
851
|
-
"ts-jest": "^29.2.5",
|
|
852
|
-
"ts-loader": "^9.5.1",
|
|
853
|
-
"ts-node": "^10.9.2",
|
|
854
|
-
"tsconfig-paths": "^4.2.0",
|
|
855
|
-
"typescript": "^5.7.2"
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
`,
|
|
859
|
-
|
|
860
|
-
'backend/nest-cli.json': `{
|
|
861
|
-
"collection": "@nestjs/schematics",
|
|
862
|
-
"sourceRoot": "src"
|
|
863
|
-
}
|
|
864
|
-
`,
|
|
865
|
-
|
|
866
|
-
'backend/tsconfig.json': `{
|
|
867
|
-
"compilerOptions": {
|
|
868
|
-
"module": "commonjs",
|
|
869
|
-
"declaration": true,
|
|
870
|
-
"removeComments": true,
|
|
871
|
-
"emitDecoratorMetadata": true,
|
|
872
|
-
"experimentalDecorators": true,
|
|
873
|
-
"allowSyntheticDefaultImports": true,
|
|
874
|
-
"target": "es2021",
|
|
875
|
-
"sourceMap": true,
|
|
876
|
-
"outDir": "./dist",
|
|
877
|
-
"baseUrl": "./",
|
|
878
|
-
"incremental": true,
|
|
879
|
-
"strict": true,
|
|
880
|
-
"skipLibCheck": true
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
`,
|
|
884
|
-
|
|
885
|
-
'backend/tsconfig.build.json': `{
|
|
886
|
-
"extends": "./tsconfig.json",
|
|
887
|
-
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
|
888
|
-
}
|
|
889
|
-
`,
|
|
890
|
-
|
|
891
|
-
'backend/src/main.ts': `import { NestFactory } from '@nestjs/core';
|
|
892
|
-
import { AppModule } from './app.module';
|
|
893
|
-
|
|
894
|
-
async function bootstrap(): Promise<void> {
|
|
895
|
-
const app = await NestFactory.create(AppModule);
|
|
896
|
-
app.setGlobalPrefix('api');
|
|
897
|
-
await app.listen(process.env.PORT ? Number(process.env.PORT) : 3000);
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
void bootstrap();
|
|
901
|
-
`,
|
|
902
|
-
|
|
903
|
-
'backend/src/app.module.ts': 'import { Module } from "@nestjs/common";\nimport { AppController } from "./app.controller";\nimport { AppService } from "./app.service";\nimport { OpsModule } from "./modules/ops/ops.module";\n\n@Module({\n imports: [OpsModule],\n controllers: [AppController],\n providers: [AppService]\n})\nexport class AppModule {}',
|
|
904
|
-
|
|
905
|
-
'backend/src/app.controller.ts': `import { Controller, Get } from '@nestjs/common';
|
|
906
|
-
import { AppService } from './app.service';
|
|
907
|
-
|
|
908
|
-
@Controller()
|
|
909
|
-
export class AppController {
|
|
910
|
-
constructor(private readonly appService: AppService) {}
|
|
911
|
-
|
|
912
|
-
@Get('health')
|
|
913
|
-
health(): { status: string } {
|
|
914
|
-
return this.appService.health();
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
`,
|
|
918
|
-
|
|
919
|
-
'backend/src/app.service.ts': `import { Injectable } from '@nestjs/common';
|
|
920
|
-
|
|
921
|
-
@Injectable()
|
|
922
|
-
export class AppService {
|
|
923
|
-
health(): { status: string } {
|
|
924
|
-
return { status: 'ok' };
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
`,
|
|
928
|
-
|
|
929
|
-
'backend/src/modules/ops/ops.service.ts': `import { Injectable } from '@nestjs/common';
|
|
930
|
-
import * as Database from 'better-sqlite3';
|
|
931
|
-
import * as path from 'node:path';
|
|
932
|
-
|
|
933
|
-
@Injectable()
|
|
934
|
-
export class OpsService {
|
|
935
|
-
private db: any;
|
|
936
|
-
|
|
937
|
-
constructor() {
|
|
938
|
-
const dbPath = path.resolve(process.cwd(), '..', '.memory', 'sqlite', 'context.db');
|
|
939
|
-
this.db = new (Database as any)(dbPath, { readonly: true });
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
getStats() {
|
|
943
|
-
const agents = this.db.prepare('SELECT agent_name, status, current_task FROM agent_sessions').all();
|
|
944
|
-
const tasks = this.db.prepare('SELECT status, COUNT(*) as count FROM tasks GROUP BY status').all();
|
|
945
|
-
const handoffs = this.db.prepare('SELECT from_agent, to_agent, title, created_at FROM handoffs ORDER BY created_at DESC LIMIT 5').all();
|
|
946
|
-
|
|
947
|
-
return { agents, tasks, handoffs };
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
`,
|
|
951
|
-
|
|
952
|
-
'backend/src/modules/ops/ops.controller.ts': `import { Controller, Get } from '@nestjs/common';
|
|
953
|
-
import { OpsService } from './ops.service';
|
|
954
|
-
|
|
955
|
-
@Controller('ops')
|
|
956
|
-
export class OpsController {
|
|
957
|
-
constructor(private readonly opsService: OpsService) {}
|
|
958
|
-
|
|
959
|
-
@Get('stats')
|
|
960
|
-
getStats() {
|
|
961
|
-
return this.opsService.getStats();
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
@Get()
|
|
965
|
-
renderDashboard() {
|
|
966
|
-
const stats = this.opsService.getStats();
|
|
967
|
-
|
|
968
|
-
return \`
|
|
969
|
-
<!DOCTYPE html>
|
|
970
|
-
<html lang="pt-BR">
|
|
971
|
-
<head>
|
|
972
|
-
<meta charset="UTF-8">
|
|
973
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
974
|
-
<title>Agentes Ops Dashboard</title>
|
|
975
|
-
<script src="https://cdn.tailwindcss.com"></script>
|
|
976
|
-
<meta http-equiv="refresh" content="30">
|
|
977
|
-
</head>
|
|
978
|
-
<body class="bg-gray-900 text-gray-100 font-sans p-8">
|
|
979
|
-
<div class="max-w-6xl mx-auto">
|
|
980
|
-
<header class="flex justify-between items-center mb-12">
|
|
981
|
-
<h1 class="text-3xl font-bold text-blue-400">🚀 Agentes Operacionais</h1>
|
|
982
|
-
<div class="text-sm text-gray-400">Sincronizado via SQLite</div>
|
|
983
|
-
</header>
|
|
984
|
-
|
|
985
|
-
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
|
|
986
|
-
<!-- Agentes -->
|
|
987
|
-
<section class="bg-gray-800 p-6 rounded-xl border border-gray-700">
|
|
988
|
-
<h2 class="text-xl font-semibold mb-4 flex items-center">
|
|
989
|
-
<span class="mr-2">🤖</span> Status dos Agentes
|
|
990
|
-
</h2>
|
|
991
|
-
<div class="space-y-4">
|
|
992
|
-
\${stats.agents.map((a: any) => \`
|
|
993
|
-
<div class="p-3 bg-gray-900 rounded-lg border-l-4 \${a.status === 'IDLE' ? 'border-green-500' : 'border-yellow-500'}">
|
|
994
|
-
<div class="font-bold">\${a.agent_name}</div>
|
|
995
|
-
<div class="text-xs text-gray-400">\${a.status} \${a.current_task ? ' - ' + a.current_task : ''}</div>
|
|
996
|
-
</div>
|
|
997
|
-
\`).join('')}
|
|
998
|
-
</div>
|
|
999
|
-
</section>
|
|
1000
|
-
|
|
1001
|
-
<!-- Tarefas -->
|
|
1002
|
-
<section class="bg-gray-800 p-6 rounded-xl border border-gray-700">
|
|
1003
|
-
<h2 class="text-xl font-semibold mb-4 flex items-center">
|
|
1004
|
-
<span class="mr-2">📊</span> Backlog & Progresso
|
|
1005
|
-
</h2>
|
|
1006
|
-
<div class="space-y-4">
|
|
1007
|
-
\${stats.tasks.map((t: any) => \`
|
|
1008
|
-
<div class="flex justify-between items-center">
|
|
1009
|
-
<span class="capitalize">\${t.status}</span>
|
|
1010
|
-
<span class="bg-blue-600 px-2 py-1 rounded text-xs">\${t.count}</span>
|
|
1011
|
-
</div>
|
|
1012
|
-
\`).join('')}
|
|
1013
|
-
</div>
|
|
1014
|
-
</section>
|
|
1015
|
-
|
|
1016
|
-
<!-- Handoffs -->
|
|
1017
|
-
<section class="bg-gray-800 p-6 rounded-xl border border-gray-700">
|
|
1018
|
-
<h2 class="text-xl font-semibold mb-4 flex items-center">
|
|
1019
|
-
<span class="mr-2">🤝</span> Últimos Handoffs
|
|
1020
|
-
</h2>
|
|
1021
|
-
<div class="space-y-3">
|
|
1022
|
-
\${stats.handoffs.map((h: any) => \`
|
|
1023
|
-
<div class="text-xs border-b border-gray-700 pb-2">
|
|
1024
|
-
<div class="text-blue-300 font-medium">\${h.from_agent} → \${h.to_agent}</div>
|
|
1025
|
-
<div class="text-gray-400 truncate">\${h.title}</div>
|
|
1026
|
-
</div>
|
|
1027
|
-
\`).join('')}
|
|
1028
|
-
</div>
|
|
1029
|
-
</section>
|
|
1030
|
-
</div>
|
|
1031
|
-
|
|
1032
|
-
<footer class="mt-12 text-center text-gray-500 text-xs">
|
|
1033
|
-
Atualizado em: \${new Date().toLocaleString('pt-BR')} | create-memory-nest-kit v0.5.0
|
|
1034
|
-
</footer>
|
|
1035
|
-
</div>
|
|
1036
|
-
</body>
|
|
1037
|
-
</html>
|
|
1038
|
-
\`;
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
`,
|
|
1042
|
-
|
|
1043
|
-
'backend/src/modules/ops/ops.module.ts': `import { Module } from '@nestjs/common';
|
|
1044
|
-
import { OpsController } from './ops.controller';
|
|
1045
|
-
import { OpsService } from './ops.service';
|
|
1046
|
-
|
|
1047
|
-
@Module({
|
|
1048
|
-
controllers: [OpsController],
|
|
1049
|
-
providers: [OpsService]
|
|
1050
|
-
})
|
|
1051
|
-
export class OpsModule {}
|
|
1052
|
-
`,
|
|
1053
|
-
|
|
1054
|
-
'backend/src/app.controller.spec.ts': `import { Test, TestingModule } from '@nestjs/testing';
|
|
1055
|
-
import { AppController } from './app.controller';
|
|
1056
|
-
import { AppService } from './app.service';
|
|
1057
|
-
|
|
1058
|
-
describe('AppController', () => {
|
|
1059
|
-
let controller: AppController;
|
|
1060
|
-
|
|
1061
|
-
beforeEach(async () => {
|
|
1062
|
-
const module: TestingModule = await Test.createTestingModule({
|
|
1063
|
-
controllers: [AppController],
|
|
1064
|
-
providers: [AppService]
|
|
1065
|
-
}).compile();
|
|
1066
|
-
|
|
1067
|
-
controller = module.get<AppController>(AppController);
|
|
1068
|
-
});
|
|
1069
|
-
|
|
1070
|
-
it('health() deve retornar status ok', () => {
|
|
1071
|
-
expect(controller.health()).toEqual({ status: 'ok' });
|
|
1072
|
-
});
|
|
1073
|
-
});
|
|
1074
|
-
`,
|
|
1075
|
-
|
|
1076
|
-
'backend/test/app.e2e-spec.ts': `import { Test, TestingModule } from '@nestjs/testing';
|
|
1077
|
-
import { INestApplication } from '@nestjs/common';
|
|
1078
|
-
import request from 'supertest';
|
|
1079
|
-
import { AppModule } from '../src/app.module';
|
|
1080
|
-
|
|
1081
|
-
describe('AppController (e2e)', () => {
|
|
1082
|
-
let app: INestApplication;
|
|
1083
|
-
|
|
1084
|
-
beforeEach(async () => {
|
|
1085
|
-
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
1086
|
-
imports: [AppModule]
|
|
1087
|
-
}).compile();
|
|
1088
|
-
|
|
1089
|
-
app = moduleFixture.createNestApplication();
|
|
1090
|
-
await app.init();
|
|
1091
|
-
});
|
|
1092
|
-
|
|
1093
|
-
it('/api/health (GET)', async () => {
|
|
1094
|
-
await request(app.getHttpServer())
|
|
1095
|
-
.get('/api/health')
|
|
1096
|
-
.expect(200)
|
|
1097
|
-
.expect({ status: 'ok' });
|
|
1098
|
-
});
|
|
1099
|
-
});
|
|
1100
|
-
`,
|
|
1101
|
-
|
|
1102
|
-
'backend/jest-e2e.json': `{
|
|
1103
|
-
"moduleFileExtensions": ["js", "json", "ts"],
|
|
1104
|
-
"rootDir": ".",
|
|
1105
|
-
"testEnvironment": "node",
|
|
1106
|
-
"testRegex": ".e2e-spec.ts$",
|
|
1107
|
-
"transform": {
|
|
1108
|
-
"^.+\\\\.(t|j)s$": "ts-jest"
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
`,
|
|
1112
|
-
|
|
1113
|
-
'backend/scripts/memory-db-schema.sql': `PRAGMA journal_mode = WAL;
|
|
1114
|
-
PRAGMA foreign_keys = ON;
|
|
1115
|
-
|
|
1116
|
-
CREATE TABLE IF NOT EXISTS documents (
|
|
1117
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1118
|
-
path TEXT NOT NULL UNIQUE,
|
|
1119
|
-
kind TEXT NOT NULL,
|
|
1120
|
-
title TEXT,
|
|
1121
|
-
content_hash TEXT NOT NULL,
|
|
1122
|
-
content TEXT NOT NULL,
|
|
1123
|
-
updated_at TEXT NOT NULL
|
|
1124
|
-
);
|
|
1125
|
-
|
|
1126
|
-
CREATE TABLE IF NOT EXISTS document_chunks (
|
|
1127
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1128
|
-
document_id INTEGER NOT NULL,
|
|
1129
|
-
chunk_index INTEGER NOT NULL,
|
|
1130
|
-
content TEXT NOT NULL,
|
|
1131
|
-
token_estimate INTEGER NOT NULL DEFAULT 0,
|
|
1132
|
-
FOREIGN KEY(document_id) REFERENCES documents(id) ON DELETE CASCADE
|
|
1133
|
-
);
|
|
1134
|
-
|
|
1135
|
-
CREATE UNIQUE INDEX IF NOT EXISTS idx_document_chunks_unique
|
|
1136
|
-
ON document_chunks (document_id, chunk_index);
|
|
1137
|
-
|
|
1138
|
-
CREATE TABLE IF NOT EXISTS handoffs (
|
|
1139
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1140
|
-
file_path TEXT NOT NULL UNIQUE,
|
|
1141
|
-
from_agent TEXT,
|
|
1142
|
-
to_agent TEXT,
|
|
1143
|
-
title TEXT,
|
|
1144
|
-
created_at TEXT NOT NULL,
|
|
1145
|
-
status TEXT NOT NULL DEFAULT 'open'
|
|
1146
|
-
);
|
|
1147
|
-
|
|
1148
|
-
CREATE TABLE IF NOT EXISTS adrs (
|
|
1149
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1150
|
-
adr_code TEXT NOT NULL UNIQUE,
|
|
1151
|
-
title TEXT NOT NULL,
|
|
1152
|
-
file_path TEXT NOT NULL UNIQUE,
|
|
1153
|
-
status TEXT NOT NULL DEFAULT 'accepted',
|
|
1154
|
-
updated_at TEXT NOT NULL
|
|
1155
|
-
);
|
|
1156
|
-
|
|
1157
|
-
CREATE TABLE IF NOT EXISTS summaries (
|
|
1158
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1159
|
-
scope TEXT NOT NULL,
|
|
1160
|
-
scope_key TEXT NOT NULL,
|
|
1161
|
-
file_path TEXT NOT NULL UNIQUE,
|
|
1162
|
-
summary TEXT NOT NULL,
|
|
1163
|
-
updated_at TEXT NOT NULL
|
|
1164
|
-
);
|
|
1165
|
-
|
|
1166
|
-
CREATE UNIQUE INDEX IF NOT EXISTS idx_summaries_scope
|
|
1167
|
-
ON summaries (scope, scope_key);
|
|
1168
|
-
|
|
1169
|
-
CREATE TABLE IF NOT EXISTS tasks (
|
|
1170
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1171
|
-
task_key TEXT NOT NULL UNIQUE,
|
|
1172
|
-
title TEXT NOT NULL,
|
|
1173
|
-
status TEXT NOT NULL DEFAULT 'open',
|
|
1174
|
-
owner_agent TEXT,
|
|
1175
|
-
source_file TEXT NOT NULL,
|
|
1176
|
-
updated_at TEXT NOT NULL
|
|
1177
|
-
);
|
|
1178
|
-
|
|
1179
|
-
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
1180
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1181
|
-
agent_name TEXT NOT NULL UNIQUE,
|
|
1182
|
-
status TEXT NOT NULL DEFAULT 'IDLE', -- IDLE, BUSY, FAILING
|
|
1183
|
-
current_task TEXT,
|
|
1184
|
-
updated_at TEXT NOT NULL
|
|
1185
|
-
);
|
|
1186
|
-
`,
|
|
1187
|
-
|
|
1188
|
-
'backend/scripts/memory-db-init.mjs': `import fs from 'node:fs';
|
|
1189
|
-
import path from 'node:path';
|
|
1190
|
-
import Database from 'better-sqlite3';
|
|
1191
|
-
import { fileURLToPath } from 'node:url';
|
|
1192
|
-
|
|
1193
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
1194
|
-
const __dirname = path.dirname(__filename);
|
|
1195
|
-
const backendRoot = path.resolve(__dirname, '..');
|
|
1196
|
-
const projectRoot = path.resolve(backendRoot, '..');
|
|
1197
|
-
const dbDir = path.join(projectRoot, '.memory', 'sqlite');
|
|
1198
|
-
const dbPath = path.join(dbDir, 'context.db');
|
|
1199
|
-
const schemaPath = path.join(__dirname, 'memory-db-schema.sql');
|
|
1200
|
-
|
|
1201
|
-
fs.mkdirSync(dbDir, { recursive: true });
|
|
1202
|
-
const schema = fs.readFileSync(schemaPath, 'utf8');
|
|
1203
|
-
const db = new Database(dbPath);
|
|
1204
|
-
db.exec(schema);
|
|
1205
|
-
db.close();
|
|
1206
|
-
|
|
1207
|
-
console.log('SQLite inicializado em: ' + dbPath);
|
|
1208
|
-
`,
|
|
1209
|
-
|
|
1210
|
-
'backend/scripts/memory-db-sync.mjs': `import fs from 'node:fs';
|
|
1211
|
-
import path from 'node:path';
|
|
1212
|
-
import crypto from 'node:crypto';
|
|
1213
|
-
import Database from 'better-sqlite3';
|
|
1214
|
-
import { fileURLToPath } from 'node:url';
|
|
1215
|
-
|
|
1216
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
1217
|
-
const __dirname = path.dirname(__filename);
|
|
1218
|
-
const backendRoot = path.resolve(__dirname, '..');
|
|
1219
|
-
const projectRoot = path.resolve(backendRoot, '..');
|
|
1220
|
-
const dbPath = path.join(projectRoot, '.memory', 'sqlite', 'context.db');
|
|
1221
|
-
|
|
1222
|
-
function walk(dir, out = []) {
|
|
1223
|
-
if (!fs.existsSync(dir)) return out;
|
|
1224
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
1225
|
-
if (entry.name === 'node_modules' || entry.name === '.git') continue;
|
|
1226
|
-
const abs = path.join(dir, entry.name);
|
|
1227
|
-
if (entry.isDirectory()) walk(abs, out);
|
|
1228
|
-
else if (entry.isFile() && entry.name.endsWith('.md')) out.push(abs);
|
|
1229
|
-
}
|
|
1230
|
-
return out;
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
function toPosix(p) {
|
|
1234
|
-
return p.split(path.sep).join('/');
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
function getKind(relPath) {
|
|
1238
|
-
if (relPath.startsWith('memory/50-orchestration/handoffs/')) return 'handoff';
|
|
1239
|
-
if (relPath.startsWith('memory/90-decisions/ADR-')) return 'adr';
|
|
1240
|
-
if (relPath.startsWith('memory/70-summaries/')) return 'summary';
|
|
1241
|
-
if (relPath.startsWith('memory/')) return 'memory';
|
|
1242
|
-
if (relPath.startsWith('agents/')) return 'agent';
|
|
1243
|
-
if (relPath.startsWith('skills/')) return 'skill';
|
|
1244
|
-
if (relPath.startsWith('prompts/')) return 'prompt';
|
|
1245
|
-
if (relPath.startsWith('docs/')) return 'doc';
|
|
1246
|
-
return 'other';
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
function getTitle(md) {
|
|
1250
|
-
const m = md.match(/^#\\s+(.+)$/m);
|
|
1251
|
-
return m ? m[1].trim() : null;
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
function splitChunks(content, size = 1600) {
|
|
1255
|
-
const chunks = [];
|
|
1256
|
-
for (let i = 0; i < content.length; i += size) {
|
|
1257
|
-
chunks.push(content.slice(i, i + size));
|
|
1258
|
-
}
|
|
1259
|
-
return chunks;
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
const roots = ['memory', 'docs', 'agents', 'skills', 'prompts'].map((r) => path.join(projectRoot, r));
|
|
1263
|
-
const mdFiles = roots.flatMap((r) => walk(r)).sort();
|
|
1264
|
-
|
|
1265
|
-
if (!fs.existsSync(dbPath)) {
|
|
1266
|
-
console.error('Banco nao encontrado: ' + dbPath);
|
|
1267
|
-
console.error('Rode primeiro: npm run memory:db:init');
|
|
1268
|
-
process.exit(1);
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
const db = new Database(dbPath);
|
|
1272
|
-
const now = new Date().toISOString();
|
|
1273
|
-
|
|
1274
|
-
const upsertDoc = db.prepare(
|
|
1275
|
-
'INSERT INTO documents (path, kind, title, content_hash, content, updated_at) VALUES (?, ?, ?, ?, ?, ?) '
|
|
1276
|
-
+ 'ON CONFLICT(path) DO UPDATE SET kind=excluded.kind, title=excluded.title, content_hash=excluded.content_hash, content=excluded.content, updated_at=excluded.updated_at'
|
|
1277
|
-
);
|
|
1278
|
-
const selectDocId = db.prepare('SELECT id FROM documents WHERE path = ?');
|
|
1279
|
-
const deleteChunks = db.prepare('DELETE FROM document_chunks WHERE document_id = ?');
|
|
1280
|
-
const insertChunk = db.prepare(
|
|
1281
|
-
'INSERT INTO document_chunks (document_id, chunk_index, content, token_estimate) VALUES (?, ?, ?, ?)'
|
|
1282
|
-
);
|
|
1283
|
-
|
|
1284
|
-
const upsertHandoff = db.prepare(
|
|
1285
|
-
'INSERT INTO handoffs (file_path, from_agent, to_agent, title, created_at, status) VALUES (?, ?, ?, ?, ?, ?) '
|
|
1286
|
-
+ 'ON CONFLICT(file_path) DO UPDATE SET from_agent=excluded.from_agent, to_agent=excluded.to_agent, title=excluded.title, created_at=excluded.created_at'
|
|
1287
|
-
);
|
|
1288
|
-
|
|
1289
|
-
const upsertAdr = db.prepare(
|
|
1290
|
-
'INSERT INTO adrs (adr_code, title, file_path, status, updated_at) VALUES (?, ?, ?, ?, ?) '
|
|
1291
|
-
+ 'ON CONFLICT(adr_code) DO UPDATE SET title=excluded.title, file_path=excluded.file_path, status=excluded.status, updated_at=excluded.updated_at'
|
|
1292
|
-
);
|
|
1293
|
-
|
|
1294
|
-
const upsertSummary = db.prepare(
|
|
1295
|
-
'INSERT INTO summaries (scope, scope_key, file_path, summary, updated_at) VALUES (?, ?, ?, ?, ?) '
|
|
1296
|
-
+ 'ON CONFLICT(file_path) DO UPDATE SET scope=excluded.scope, scope_key=excluded.scope_key, summary=excluded.summary, updated_at=excluded.updated_at'
|
|
1297
|
-
);
|
|
1298
|
-
|
|
1299
|
-
const upsertTask = db.prepare(
|
|
1300
|
-
'INSERT INTO tasks (task_key, title, status, owner_agent, source_file, updated_at) VALUES (?, ?, ?, ?, ?, ?) '
|
|
1301
|
-
+ 'ON CONFLICT(task_key) DO UPDATE SET title=excluded.title, status=excluded.status, owner_agent=excluded.owner_agent, source_file=excluded.source_file, updated_at=excluded.updated_at'
|
|
1302
|
-
);
|
|
1303
|
-
|
|
1304
|
-
const tx = db.transaction(() => {
|
|
1305
|
-
for (const abs of mdFiles) {
|
|
1306
|
-
const rel = toPosix(path.relative(projectRoot, abs));
|
|
1307
|
-
const raw = fs.readFileSync(abs, 'utf8');
|
|
1308
|
-
const hash = crypto.createHash('sha256').update(raw).digest('hex');
|
|
1309
|
-
const kind = getKind(rel);
|
|
1310
|
-
const title = getTitle(raw);
|
|
1311
|
-
|
|
1312
|
-
upsertDoc.run(rel, kind, title, hash, raw, now);
|
|
1313
|
-
const row = selectDocId.get(rel);
|
|
1314
|
-
if (!row) continue;
|
|
1315
|
-
|
|
1316
|
-
deleteChunks.run(row.id);
|
|
1317
|
-
const chunks = splitChunks(raw);
|
|
1318
|
-
chunks.forEach((chunk, i) => {
|
|
1319
|
-
const tokens = Math.ceil(chunk.length / 4);
|
|
1320
|
-
insertChunk.run(row.id, i, chunk, tokens);
|
|
1321
|
-
});
|
|
1322
|
-
|
|
1323
|
-
if (kind === 'handoff' && !rel.endsWith('/README.md')) {
|
|
1324
|
-
const base = path.basename(rel, '.md');
|
|
1325
|
-
const fromTo = base.split('_').slice(1).join('_');
|
|
1326
|
-
const from = fromTo.split('_para_')[0] || null;
|
|
1327
|
-
const to = fromTo.split('_para_')[1] || null;
|
|
1328
|
-
upsertHandoff.run(rel, from, to, title || base, now, 'open');
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
if (kind === 'adr') {
|
|
1332
|
-
const code = path.basename(rel, '.md').split('-').slice(0, 2).join('-');
|
|
1333
|
-
upsertAdr.run(code, title || code, rel, 'accepted', now);
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
if (kind === 'summary') {
|
|
1337
|
-
const file = path.basename(rel, '.md');
|
|
1338
|
-
const scope = file.includes('global') ? 'global' : 'domain';
|
|
1339
|
-
const scopeKey = file.replace('-summary', '');
|
|
1340
|
-
upsertSummary.run(scope, scopeKey, rel, raw.slice(0, 20000), now);
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
if (rel === 'memory/40-delivery/current-sprint.md' || rel === 'memory/40-delivery/backlog.md') {
|
|
1344
|
-
const lines = raw.split('\\n');
|
|
1345
|
-
for (const line of lines) {
|
|
1346
|
-
const m = line.match(/^[-*]\\s+\\[\\s\\]\\s+(.+)$/);
|
|
1347
|
-
if (!m) continue;
|
|
1348
|
-
const taskTitle = m[1].trim();
|
|
1349
|
-
const taskKey = crypto.createHash('md5').update(rel + ':' + taskTitle).digest('hex');
|
|
1350
|
-
upsertTask.run(taskKey, taskTitle, 'open', null, rel, now);
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
});
|
|
1355
|
-
|
|
1356
|
-
tx();
|
|
1357
|
-
db.close();
|
|
1358
|
-
console.log('Sync concluido. Arquivos indexados: ' + mdFiles.length);
|
|
1359
|
-
`,
|
|
1360
|
-
|
|
1361
|
-
'backend/scripts/memory-db-query.mjs': `import path from 'node:path';
|
|
1362
|
-
import Database from 'better-sqlite3';
|
|
1363
|
-
import { fileURLToPath } from 'node:url';
|
|
1364
|
-
|
|
1365
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
1366
|
-
const __dirname = path.dirname(__filename);
|
|
1367
|
-
const backendRoot = path.resolve(__dirname, '..');
|
|
1368
|
-
const projectRoot = path.resolve(backendRoot, '..');
|
|
1369
|
-
const dbPath = path.join(projectRoot, '.memory', 'sqlite', 'context.db');
|
|
1370
|
-
|
|
1371
|
-
const args = process.argv.slice(2);
|
|
1372
|
-
const mode = args[0] || 'search';
|
|
1373
|
-
const term = args[1] || '';
|
|
1374
|
-
const limit = Number(args[2] || 10);
|
|
1375
|
-
|
|
1376
|
-
const db = new Database(dbPath, { readonly: true });
|
|
1377
|
-
|
|
1378
|
-
if (mode === 'handoffs') {
|
|
1379
|
-
const rows = db.prepare(
|
|
1380
|
-
'SELECT file_path, from_agent, to_agent, title, created_at FROM handoffs ORDER BY created_at DESC LIMIT ?'
|
|
1381
|
-
).all(limit);
|
|
1382
|
-
for (const row of rows) {
|
|
1383
|
-
console.log('- ' + row.created_at + ' | ' + row.from_agent + ' -> ' + row.to_agent + ' | ' + row.title);
|
|
1384
|
-
console.log(' ' + row.file_path);
|
|
1385
|
-
}
|
|
1386
|
-
process.exit(0);
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1389
|
-
if (mode === 'adrs') {
|
|
1390
|
-
const rows = db.prepare(
|
|
1391
|
-
'SELECT adr_code, title, status, file_path, updated_at FROM adrs ORDER BY adr_code LIMIT ?'
|
|
1392
|
-
).all(limit);
|
|
1393
|
-
for (const row of rows) {
|
|
1394
|
-
console.log('- ' + row.adr_code + ' | ' + row.status + ' | ' + row.title);
|
|
1395
|
-
console.log(' ' + row.file_path + ' (' + row.updated_at + ')');
|
|
1396
|
-
}
|
|
1397
|
-
process.exit(0);
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
const rows = db.prepare(
|
|
1401
|
-
'SELECT path, kind, title, substr(content, 1, 200) as snippet FROM documents '
|
|
1402
|
-
+ 'WHERE content LIKE ? OR title LIKE ? OR path LIKE ? '
|
|
1403
|
-
+ 'ORDER BY updated_at DESC LIMIT ?'
|
|
1404
|
-
).all('%' + term + '%', '%' + term + '%', '%' + term + '%', limit);
|
|
1405
|
-
|
|
1406
|
-
for (const row of rows) {
|
|
1407
|
-
console.log('- [' + row.kind + '] ' + row.path);
|
|
1408
|
-
if (row.title) console.log(' titulo: ' + row.title);
|
|
1409
|
-
console.log(' trecho: ' + row.snippet.replace(/\\n/g, ' '));
|
|
1410
|
-
}
|
|
1411
|
-
`
|
|
1412
|
-
};
|
|
1413
|
-
|
|
1414
|
-
for (const [relativePath, content] of Object.entries(files)) {
|
|
1415
|
-
writeFileSafe(path.join(base, relativePath), content);
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
function writeReadme(base) {
|
|
1420
|
-
const content = `# create-memory-nest-kit v0.5.0
|
|
1421
|
-
|
|
1422
|
-
Scaffold para projetos grandes com:
|
|
1423
|
-
- memoria hierarquica e resumida
|
|
1424
|
-
- suporte operacional para multiagentes
|
|
1425
|
-
- handoff e continuidade de execucao
|
|
1426
|
-
- API NestJS por padrao
|
|
1427
|
-
- comunicacao em pt-BR
|
|
1428
|
-
|
|
1429
|
-
## Importante sobre 1M+ de tokens
|
|
1430
|
-
Este kit **nao altera limite nativo** de contexto do modelo.
|
|
1431
|
-
Ele permite operar em larga escala com segmentacao, resumo e handoff incremental.
|
|
1432
|
-
|
|
1433
|
-
## Uso local
|
|
1434
|
-
|
|
1435
|
-
\`node ./bin/create-memory-nest-kit.js meu-projeto\`
|
|
1436
|
-
|
|
1437
|
-
## Uso via npx (GitHub)
|
|
1438
|
-
|
|
1439
|
-
\`npx github:SEU_USUARIO/create-memory-nest-kit meu-projeto\`
|
|
1440
|
-
|
|
1441
|
-
## Uso via npx (npm)
|
|
1442
|
-
|
|
1443
|
-
\`npx create-memory-nest-kit@latest meu-projeto\`
|
|
1444
|
-
|
|
1445
|
-
## Flags
|
|
1446
|
-
|
|
1447
|
-
- \`--force\`: sobrescreve arquivos existentes
|
|
1448
|
-
- \`--only-memory\`: gera apenas memoria + agents + skills
|
|
1449
|
-
- \`--no-gitkeep\`: nao cria .gitkeep em diretorios vazios
|
|
1450
|
-
|
|
1451
|
-
## Scripts uteis no projeto gerado
|
|
1452
|
-
|
|
1453
|
-
- \`node scripts/build-context-pack.mjs\`
|
|
1454
|
-
- \`node scripts/append-handoff.mjs worker-a worker-b "titulo"\`
|
|
1455
|
-
- \`cd backend && npm run memory:db:init\`
|
|
1456
|
-
- \`cd backend && npm run memory:db:sync\`
|
|
1457
|
-
- \`cd backend && npm run memory:db:query -- "termo"\`
|
|
1458
|
-
`;
|
|
1459
|
-
|
|
1460
|
-
writeFileSafe(path.join(base, 'README.md'), content);
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
function run() {
|
|
1464
|
-
try {
|
|
1465
|
-
ensureDir(targetDir);
|
|
1466
|
-
|
|
1467
|
-
writeMemoryAndOps(targetDir);
|
|
1468
|
-
if (!options.onlyMemory) writeNestApi(targetDir);
|
|
1469
|
-
writeReadme(targetDir);
|
|
1470
|
-
|
|
1471
|
-
log('✅ Estrutura v0.5.0 criada com sucesso.');
|
|
1472
|
-
log(`📁 Diretorio: ${targetDir}`);
|
|
1473
|
-
log('➡️ Proximos passos:');
|
|
1474
|
-
log(` 1) cd ${path.relative(process.cwd(), targetDir) || '.'}`);
|
|
1475
|
-
log(' 2) node scripts/build-context-pack.mjs');
|
|
1476
|
-
if (!options.onlyMemory) {
|
|
1477
|
-
log(' 3) cd backend && npm install');
|
|
1478
|
-
log(' 4) npm run start:dev');
|
|
1479
|
-
}
|
|
1480
|
-
} catch (error) {
|
|
1481
|
-
console.error(`❌ Erro: ${error.message}`);
|
|
1482
|
-
process.exit(1);
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
run();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import process from 'node:process';
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
const showHelp = args.includes('--help') || args.includes('-h');
|
|
8
|
+
|
|
9
|
+
if (showHelp) {
|
|
10
|
+
console.log(`
|
|
11
|
+
create-memory-nest-kit v0.5.0
|
|
12
|
+
|
|
13
|
+
Uso:
|
|
14
|
+
create-memory-nest-kit [diretorio] [opcoes]
|
|
15
|
+
|
|
16
|
+
Opcoes:
|
|
17
|
+
--force Sobrescreve arquivos existentes
|
|
18
|
+
--only-memory Gera apenas estrutura de memoria/agents/skills
|
|
19
|
+
--no-gitkeep Nao cria .gitkeep em diretorios vazios
|
|
20
|
+
-h, --help Mostra esta ajuda
|
|
21
|
+
`);
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const options = {
|
|
26
|
+
force: args.includes('--force'),
|
|
27
|
+
noGitkeep: args.includes('--no-gitkeep'),
|
|
28
|
+
onlyMemory: args.includes('--only-memory')
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const rawTarget = args.find((a) => !a.startsWith('-')) || '.';
|
|
32
|
+
const targetDir = path.resolve(process.cwd(), rawTarget);
|
|
33
|
+
const projectName = path.basename(targetDir);
|
|
34
|
+
|
|
35
|
+
function log(message) {
|
|
36
|
+
console.log(message);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ensureDir(dirPath) {
|
|
40
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function writeFileSafe(filePath, content) {
|
|
44
|
+
if (fs.existsSync(filePath) && !options.force) {
|
|
45
|
+
throw new Error(`Arquivo ja existe: ${filePath}. Use --force para sobrescrever.`);
|
|
46
|
+
}
|
|
47
|
+
ensureDir(path.dirname(filePath));
|
|
48
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function maybeGitkeep(dirPath) {
|
|
52
|
+
if (options.noGitkeep) return;
|
|
53
|
+
const keepFile = path.join(dirPath, '.gitkeep');
|
|
54
|
+
if (!fs.existsSync(keepFile)) {
|
|
55
|
+
fs.writeFileSync(keepFile, '', 'utf8');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function writeMemoryAndOps(base) {
|
|
60
|
+
const files = {
|
|
61
|
+
'memory/README.md': `# Memoria do Projeto
|
|
62
|
+
|
|
63
|
+
Esta estrutura foi desenhada para reduzir perda de contexto em projetos grandes.
|
|
64
|
+
|
|
65
|
+
## Principio
|
|
66
|
+
- Nao depender de um unico contexto gigante.
|
|
67
|
+
- Trabalhar com memoria em camadas + handoff incremental.
|
|
68
|
+
- Registrar decisoes, resumos e execucoes para continuidade.
|
|
69
|
+
`,
|
|
70
|
+
|
|
71
|
+
'memory/00-global/mission.md': `# Missao do Projeto
|
|
72
|
+
|
|
73
|
+
Construir software com clareza arquitetural, seguranca by-default e entrega continua.
|
|
74
|
+
|
|
75
|
+
## Principios
|
|
76
|
+
- Simplicidade primeiro
|
|
77
|
+
- Decisoes explicitas em ADR
|
|
78
|
+
- Qualidade e seguranca desde o inicio
|
|
79
|
+
- Documentacao viva
|
|
80
|
+
`,
|
|
81
|
+
|
|
82
|
+
'memory/00-global/standards.md': `# Padroes Globais
|
|
83
|
+
|
|
84
|
+
## Idioma
|
|
85
|
+
- Toda comunicacao e documentacao em **pt-BR**.
|
|
86
|
+
|
|
87
|
+
## Backend
|
|
88
|
+
- API criada em **NestJS** por padrao.
|
|
89
|
+
- Arquitetura modular por dominio.
|
|
90
|
+
|
|
91
|
+
## Qualidade
|
|
92
|
+
- Cada mudanca deve registrar impacto, risco e rollback.
|
|
93
|
+
- Priorizar padroes reutilizaveis.
|
|
94
|
+
`,
|
|
95
|
+
|
|
96
|
+
'memory/00-global/context-policy.md': `# Politica de Contexto Longo
|
|
97
|
+
|
|
98
|
+
## Objetivo
|
|
99
|
+
Permitir trabalho em larga escala sem depender de janela unica gigantesca.
|
|
100
|
+
|
|
101
|
+
## Regras
|
|
102
|
+
- Usar contexto em camadas: global -> dominio -> tarefa -> diff.
|
|
103
|
+
- Antes de cada tarefa: carregar apenas arquivos necessarios.
|
|
104
|
+
- A cada entrega: gerar resumo curto em memory/70-summaries.
|
|
105
|
+
- Em mudancas grandes: registrar handoff em memory/50-orchestration/handoffs.
|
|
106
|
+
|
|
107
|
+
## 🔄 Protocolo de Recuperacao (Engine Switch)
|
|
108
|
+
Se houver esgotamento de cota ou necessidade de mudar de IA:
|
|
109
|
+
1. Localize o arquivo \`.ia-instructions/models.json\`.
|
|
110
|
+
2. Identifique o proximo motor na \`fallback_chain\`.
|
|
111
|
+
3. Carregue as instrucoes do novo motor.
|
|
112
|
+
4. Forneca o conteúdo de \`.context/context-pack.md\` + o ultimo arquivo em \`memory/50-orchestration/handoffs/\`.
|
|
113
|
+
5. O novo motor assumira o trabalho a partir do ponto exato da ultima entrega.
|
|
114
|
+
|
|
115
|
+
## Nota importante
|
|
116
|
+
Esta estrutura **nao aumenta** limite nativo do modelo.
|
|
117
|
+
Ela reduz perda de memoria por segmentacao, resumo e continuidade operacional.
|
|
118
|
+
`,
|
|
119
|
+
|
|
120
|
+
'memory/00-global/agent-contract.md': `# Contrato de Agentes
|
|
121
|
+
|
|
122
|
+
## Orquestrador
|
|
123
|
+
- Decompõe trabalho em subtarefas independentes.
|
|
124
|
+
- Define dono por escopo de arquivo.
|
|
125
|
+
- Consolida handoffs e conflitos.
|
|
126
|
+
|
|
127
|
+
## Workers
|
|
128
|
+
- Implementam subtarefas com escopo claro.
|
|
129
|
+
- Nao alteram areas de outros agentes sem alinhamento.
|
|
130
|
+
- Entregam: alteracoes, riscos, testes e pendencias.
|
|
131
|
+
|
|
132
|
+
## Reviewer
|
|
133
|
+
- Verifica regressao, seguranca e cobertura de testes.
|
|
134
|
+
- Bloqueia merge se encontrar risco critico.
|
|
135
|
+
`,
|
|
136
|
+
|
|
137
|
+
'memory/00-global/context-index.md': `# Indice de Contexto
|
|
138
|
+
|
|
139
|
+
## Ordem de Leitura
|
|
140
|
+
1. memory/00-global/mission.md
|
|
141
|
+
2. memory/00-global/standards.md
|
|
142
|
+
3. memory/00-global/context-policy.md
|
|
143
|
+
4. memory/10-product/*
|
|
144
|
+
5. memory/20-architecture/*
|
|
145
|
+
6. memory/30-domains/<dominio>/*
|
|
146
|
+
7. memory/40-delivery/current-sprint.md
|
|
147
|
+
8. memory/90-decisions/ADR-*.md
|
|
148
|
+
9. memory/70-summaries/*
|
|
149
|
+
`,
|
|
150
|
+
|
|
151
|
+
'memory/10-product/vision.md': `# Visao de Produto
|
|
152
|
+
|
|
153
|
+
Descreva objetivo, publico-alvo, problema e proposta de valor.
|
|
154
|
+
`,
|
|
155
|
+
|
|
156
|
+
'memory/10-product/personas.md': `# Personas
|
|
157
|
+
|
|
158
|
+
Liste personas e dores principais.
|
|
159
|
+
`,
|
|
160
|
+
|
|
161
|
+
'memory/10-product/business-rules.md': `# Regras de Negocio
|
|
162
|
+
|
|
163
|
+
Documente regras imutaveis e validacoes criticas.
|
|
164
|
+
`,
|
|
165
|
+
|
|
166
|
+
'memory/10-product/nfrs.md': `# Requisitos Nao Funcionais
|
|
167
|
+
|
|
168
|
+
- Performance
|
|
169
|
+
- Seguranca
|
|
170
|
+
- Observabilidade
|
|
171
|
+
- Escalabilidade
|
|
172
|
+
`,
|
|
173
|
+
|
|
174
|
+
'memory/20-architecture/system-overview.md': `# Visao Geral da Arquitetura
|
|
175
|
+
|
|
176
|
+
Descreva contexto, fronteiras e integracoes principais.
|
|
177
|
+
`,
|
|
178
|
+
|
|
179
|
+
'memory/20-architecture/frontend.md': `# Frontend
|
|
180
|
+
|
|
181
|
+
Defina padroes de componentizacao, acessibilidade e performance.
|
|
182
|
+
`,
|
|
183
|
+
|
|
184
|
+
'memory/20-architecture/backend.md': `# Backend
|
|
185
|
+
|
|
186
|
+
## Diretriz principal
|
|
187
|
+
- Backend em **NestJS** por padrao.
|
|
188
|
+
|
|
189
|
+
## Estrutura sugerida
|
|
190
|
+
- Modulos por dominio
|
|
191
|
+
- DTO + validacao
|
|
192
|
+
- Servicos com regras de negocio
|
|
193
|
+
- Repositorios/integradores isolados
|
|
194
|
+
`,
|
|
195
|
+
|
|
196
|
+
'memory/20-architecture/data.md': `# Dados
|
|
197
|
+
|
|
198
|
+
Descreva entidades, relacionamentos e politicas de retencao.
|
|
199
|
+
`,
|
|
200
|
+
|
|
201
|
+
'memory/20-architecture/security.md': `# Seguranca
|
|
202
|
+
|
|
203
|
+
- Principio do menor privilegio
|
|
204
|
+
- Segredos fora do codigo
|
|
205
|
+
- Validacao de entrada em todas as rotas
|
|
206
|
+
- Logs sem dados sensiveis
|
|
207
|
+
`,
|
|
208
|
+
|
|
209
|
+
'memory/20-architecture/observability.md': `# Observabilidade
|
|
210
|
+
|
|
211
|
+
- Logs estruturados
|
|
212
|
+
- Metricas e tracing
|
|
213
|
+
- Alertas por SLO
|
|
214
|
+
`,
|
|
215
|
+
|
|
216
|
+
'memory/30-domains/auth/context.md': `# Contexto de Auth
|
|
217
|
+
|
|
218
|
+
Defina escopo funcional de autenticacao/autorizacao.
|
|
219
|
+
`,
|
|
220
|
+
|
|
221
|
+
'memory/30-domains/auth/rules.md': `# Regras de Auth
|
|
222
|
+
|
|
223
|
+
Liste regras e restricoes de seguranca.
|
|
224
|
+
`,
|
|
225
|
+
|
|
226
|
+
'memory/30-domains/auth/api.md': `# API de Auth
|
|
227
|
+
|
|
228
|
+
Documente endpoints, payloads e erros.
|
|
229
|
+
`,
|
|
230
|
+
|
|
231
|
+
'memory/30-domains/billing/context.md': `# Contexto de Billing
|
|
232
|
+
|
|
233
|
+
Defina cobranca, ciclo e integracoes.
|
|
234
|
+
`,
|
|
235
|
+
|
|
236
|
+
'memory/30-domains/billing/rules.md': `# Regras de Billing
|
|
237
|
+
|
|
238
|
+
Descreva calculos, status e excecoes.
|
|
239
|
+
`,
|
|
240
|
+
|
|
241
|
+
'memory/30-domains/billing/api.md': `# API de Billing
|
|
242
|
+
|
|
243
|
+
Documente endpoints e regras de idempotencia.
|
|
244
|
+
`,
|
|
245
|
+
|
|
246
|
+
'memory/40-delivery/roadmap.md': `# Roadmap
|
|
247
|
+
|
|
248
|
+
Mapeie entregas por trimestre/sprint.
|
|
249
|
+
`,
|
|
250
|
+
|
|
251
|
+
'memory/40-delivery/current-sprint.md': `# Sprint Atual
|
|
252
|
+
|
|
253
|
+
## Objetivos
|
|
254
|
+
-
|
|
255
|
+
|
|
256
|
+
## Itens
|
|
257
|
+
-
|
|
258
|
+
|
|
259
|
+
## Riscos
|
|
260
|
+
-
|
|
261
|
+
`,
|
|
262
|
+
|
|
263
|
+
'memory/40-delivery/backlog.md': `# Backlog
|
|
264
|
+
|
|
265
|
+
Liste itens priorizados com contexto minimo.
|
|
266
|
+
`,
|
|
267
|
+
|
|
268
|
+
'memory/50-orchestration/topology.md': `# Topologia Multiagente
|
|
269
|
+
|
|
270
|
+
## Papeis
|
|
271
|
+
- Orquestrador
|
|
272
|
+
- Worker Backend (NestJS)
|
|
273
|
+
- Worker Frontend
|
|
274
|
+
- Worker DBA
|
|
275
|
+
- Worker Security
|
|
276
|
+
- Reviewer
|
|
277
|
+
|
|
278
|
+
## Fluxo
|
|
279
|
+
1. Orquestrador cria plano e fatia trabalho.
|
|
280
|
+
2. Workers executam em paralelo com escopo isolado.
|
|
281
|
+
3. Handoffs sao registrados.
|
|
282
|
+
4. Reviewer valida e aprova.
|
|
283
|
+
`,
|
|
284
|
+
|
|
285
|
+
'memory/50-orchestration/routing.md': `# Roteamento de Tarefas
|
|
286
|
+
|
|
287
|
+
## Regras de roteamento
|
|
288
|
+
- API e dominio server-side -> backend-nest
|
|
289
|
+
- Schema/migracao/query -> dba
|
|
290
|
+
- Auth, hardening, segredos -> security
|
|
291
|
+
- UX/componentes -> frontend
|
|
292
|
+
|
|
293
|
+
## Critico
|
|
294
|
+
Subtarefas devem ter dono unico por arquivo para evitar conflito.
|
|
295
|
+
`,
|
|
296
|
+
|
|
297
|
+
'memory/50-orchestration/handoff-protocol.md': `# Protocolo de Handoff
|
|
298
|
+
|
|
299
|
+
Cada handoff deve conter:
|
|
300
|
+
- contexto minimo
|
|
301
|
+
- alteracoes realizadas
|
|
302
|
+
- arquivos tocados
|
|
303
|
+
- riscos e pontos abertos
|
|
304
|
+
- proximos passos objetivos
|
|
305
|
+
`,
|
|
306
|
+
|
|
307
|
+
'memory/50-orchestration/parallel-playbook.md': `# Playbook de Paralelizacao
|
|
308
|
+
|
|
309
|
+
## Quando paralelizar
|
|
310
|
+
- Subtarefas independentes por dominio.
|
|
311
|
+
- Escopo de escrita sem sobreposicao.
|
|
312
|
+
|
|
313
|
+
## Quando nao paralelizar
|
|
314
|
+
- Mudanca bloqueante para a proxima etapa.
|
|
315
|
+
- Refactor altamente acoplado no mesmo modulo.
|
|
316
|
+
`,
|
|
317
|
+
|
|
318
|
+
'memory/50-orchestration/handoffs/README.md': `# Handoffs
|
|
319
|
+
|
|
320
|
+
Registre cada transicao em arquivos markdown com timestamp.
|
|
321
|
+
Exemplo: 2026-04-18T12-30_worker-backend_para_reviewer.md
|
|
322
|
+
`,
|
|
323
|
+
|
|
324
|
+
'memory/60-runs/README.md': `# Runs
|
|
325
|
+
|
|
326
|
+
Log de execucao por ciclo/sprint.
|
|
327
|
+
`,
|
|
328
|
+
|
|
329
|
+
'memory/70-summaries/global-summary.md': `# Resumo Global
|
|
330
|
+
|
|
331
|
+
Atualize a cada marco importante com:
|
|
332
|
+
- estado atual
|
|
333
|
+
- decisoes novas
|
|
334
|
+
- riscos ativos
|
|
335
|
+
`,
|
|
336
|
+
|
|
337
|
+
'memory/70-summaries/domain-summary.md': `# Resumo por Dominio
|
|
338
|
+
|
|
339
|
+
Mantenha resumos curtos por dominio para carregamento rapido de contexto.
|
|
340
|
+
`,
|
|
341
|
+
|
|
342
|
+
'memory/80-data/memory-db.md': `# Memory DB (SQLite)
|
|
343
|
+
|
|
344
|
+
## Objetivo
|
|
345
|
+
Armazenar indice operacional da documentacao para busca e continuidade de contexto.
|
|
346
|
+
|
|
347
|
+
## Fonte da verdade
|
|
348
|
+
- Arquivos Markdown em memory/, docs/, agents/, skills/, prompts/
|
|
349
|
+
|
|
350
|
+
## Banco
|
|
351
|
+
- SQLite em .memory/sqlite/context.db
|
|
352
|
+
|
|
353
|
+
## Fluxo
|
|
354
|
+
1. Atualizar markdown
|
|
355
|
+
2. Rodar sincronizacao
|
|
356
|
+
3. Consultar contexto por texto ou tipo
|
|
357
|
+
`,
|
|
358
|
+
|
|
359
|
+
'memory/90-decisions/ADR-0001-template.md': `# ADR-0001: Titulo da Decisao
|
|
360
|
+
|
|
361
|
+
## Contexto
|
|
362
|
+
|
|
363
|
+
## Decisao
|
|
364
|
+
|
|
365
|
+
## Consequencias
|
|
366
|
+
|
|
367
|
+
## Alternativas consideradas
|
|
368
|
+
`,
|
|
369
|
+
|
|
370
|
+
'agents/README.md': `# Agents
|
|
371
|
+
|
|
372
|
+
Agentes especializados para dividir trabalho em paralelo.
|
|
373
|
+
`,
|
|
374
|
+
|
|
375
|
+
'agents/orchestrator.md': `# Agent: Orchestrator
|
|
376
|
+
|
|
377
|
+
## Responsabilidade
|
|
378
|
+
Planejamento, decomposicao de tarefas, atribuicao de ownership e consolidacao.
|
|
379
|
+
|
|
380
|
+
## Entrega minima
|
|
381
|
+
- plano objetivo
|
|
382
|
+
- distribuicao por agentes
|
|
383
|
+
- consolidacao de handoffs
|
|
384
|
+
`,
|
|
385
|
+
|
|
386
|
+
'agents/backend-nest.md': `# Agent: Backend NestJS
|
|
387
|
+
|
|
388
|
+
## Escopo
|
|
389
|
+
- modulos, controllers, services, dto, guard, pipe
|
|
390
|
+
- testes unitarios e e2e da API
|
|
391
|
+
|
|
392
|
+
## Padrao
|
|
393
|
+
- NestJS por padrao
|
|
394
|
+
- validacao de entrada obrigatoria
|
|
395
|
+
`,
|
|
396
|
+
|
|
397
|
+
'agents/frontend.md': `# Agent: Frontend
|
|
398
|
+
|
|
399
|
+
## Escopo
|
|
400
|
+
- componentes, acessibilidade, performance, UX
|
|
401
|
+
`,
|
|
402
|
+
|
|
403
|
+
'agents/dba.md': `# Agent: DBA
|
|
404
|
+
|
|
405
|
+
## Escopo
|
|
406
|
+
- modelagem, indices, migracoes, tuning de query
|
|
407
|
+
`,
|
|
408
|
+
|
|
409
|
+
'agents/security.md': `# Agent: Security
|
|
410
|
+
|
|
411
|
+
## Escopo
|
|
412
|
+
- threat modeling, hardening, authz/authn, secrets, auditoria
|
|
413
|
+
`,
|
|
414
|
+
|
|
415
|
+
'agents/reviewer.md': `# Agent: Reviewer
|
|
416
|
+
|
|
417
|
+
## Escopo
|
|
418
|
+
- regressao funcional
|
|
419
|
+
- riscos de seguranca
|
|
420
|
+
- cobertura de testes
|
|
421
|
+
`,
|
|
422
|
+
|
|
423
|
+
'skills/triage-task/SKILL.md': `# Skill: Triage de Tarefa
|
|
424
|
+
|
|
425
|
+
## Objetivo
|
|
426
|
+
Classificar demanda em: rapido, medio, complexo.
|
|
427
|
+
|
|
428
|
+
## Saida
|
|
429
|
+
- resumo
|
|
430
|
+
- risco
|
|
431
|
+
- owner sugerido
|
|
432
|
+
- fatias de execucao
|
|
433
|
+
`,
|
|
434
|
+
|
|
435
|
+
'skills/context-compaction/SKILL.md': `# Skill: Compactacao de Contexto
|
|
436
|
+
|
|
437
|
+
## Objetivo
|
|
438
|
+
Gerar resumo operacional sem perder decisoes chave.
|
|
439
|
+
|
|
440
|
+
## Regras
|
|
441
|
+
- manter fatos verificaveis
|
|
442
|
+
- remover redundancia
|
|
443
|
+
- preservar links para fontes internas
|
|
444
|
+
`,
|
|
445
|
+
|
|
446
|
+
'skills/handoff/SKILL.md': `# Skill: Handoff
|
|
447
|
+
|
|
448
|
+
## Template
|
|
449
|
+
- contexto
|
|
450
|
+
- alteracoes
|
|
451
|
+
- riscos
|
|
452
|
+
- pendencias
|
|
453
|
+
- proximo agente
|
|
454
|
+
`,
|
|
455
|
+
|
|
456
|
+
'skills/nest-api/SKILL.md': `# Skill: Nest API
|
|
457
|
+
|
|
458
|
+
## Checklist
|
|
459
|
+
- modulo criado
|
|
460
|
+
- dto com validacao
|
|
461
|
+
- controller + service
|
|
462
|
+
- testes
|
|
463
|
+
`,
|
|
464
|
+
|
|
465
|
+
'skills/self-healing/SKILL.md': `# Skill: Auto-Diagnóstico (Self-Healing)
|
|
466
|
+
|
|
467
|
+
## Objetivo
|
|
468
|
+
Resolver falhas de build, testes ou tipos sem intervenção humana.
|
|
469
|
+
|
|
470
|
+
## Fluxo
|
|
471
|
+
1. Analisar a stack trace completa do erro.
|
|
472
|
+
2. Identificar se é: erro de sintaxe, falta de dependência, erro de tipo ou lógica.
|
|
473
|
+
3. Consultar documentação interna ou padrões do projeto.
|
|
474
|
+
4. Propor correção mínima e rodar validação novamente.
|
|
475
|
+
`,
|
|
476
|
+
|
|
477
|
+
'skills/validate-handoff/SKILL.md': `# Skill: Validação e Review de Segurança (Gatekeeper)
|
|
478
|
+
|
|
479
|
+
## Objetivo
|
|
480
|
+
Atuar como Gatekeeper final para garantir que nenhum código inseguro ou incompleto entre no pipeline.
|
|
481
|
+
|
|
482
|
+
## Protocolo de Review (Obrigatório)
|
|
483
|
+
Antes de aceitar um handoff, o Reviewer deve validar:
|
|
484
|
+
|
|
485
|
+
1. **Compliance de Raciocínio**: O Worker preencheu o bloco \`## Raciocínio Estruturado\`? (Se não, rejeite imediatamente).
|
|
486
|
+
2. **Scan de Segurança**:
|
|
487
|
+
- Há logs sensíveis (PII, tokens) sendo impressos?
|
|
488
|
+
- As validações de input estão no DTO?
|
|
489
|
+
3. **Verificação de Handoff**:
|
|
490
|
+
- Os arquivos listados no handoff condizem com o diff real?
|
|
491
|
+
- Existem pendências (riscos) não documentadas?
|
|
492
|
+
|
|
493
|
+
## Saída do Reviewer
|
|
494
|
+
- [ ] Aprovado (Status: \`done\` no DB)
|
|
495
|
+
- [ ] Rejeitado (Status: \`blocked\` + pendências listadas)
|
|
496
|
+
`,
|
|
497
|
+
|
|
498
|
+
'skills/ui-fidelity/SKILL.md': `# Skill: Fidelidade Visual
|
|
499
|
+
|
|
500
|
+
## Objetivo
|
|
501
|
+
Garantir que a UI segue padrões de elite.
|
|
502
|
+
|
|
503
|
+
## Instrução
|
|
504
|
+
1. Consultar a biblioteca \`design-md/\` para inspiração de marca/padrão.
|
|
505
|
+
2. Comparar o código gerado com os padrões de espaçamento, tipografia e cores da referência.
|
|
506
|
+
3. Ajustar CSS/Componentes para atingir qualidade visual de nível mundial.
|
|
507
|
+
`,
|
|
508
|
+
|
|
509
|
+
'skills/reasoning-protocol/SKILL.md': `# Skill: Raciocínio Estruturado (Chain-of-Thought)
|
|
510
|
+
|
|
511
|
+
## Objetivo
|
|
512
|
+
Reduzir erros de implementação através de análise lógica explícita.
|
|
513
|
+
|
|
514
|
+
## Protocolo Obrigatório
|
|
515
|
+
Antes de qualquer código ou plano de ação, preencha o bloco \`## Raciocínio Estruturado\`:
|
|
516
|
+
|
|
517
|
+
1. **Entendimento**: O que foi pedido e qual o impacto no sistema?
|
|
518
|
+
2. **Restrições**: Quais arquivos NÃO posso tocar? Quais padrões devo seguir?
|
|
519
|
+
3. **Alternativas**: Existe mais de uma forma de fazer? Por que escolhi esta?
|
|
520
|
+
4. **Plano de Ataque**: Passo-a-passo lógico da implementação.
|
|
521
|
+
`,
|
|
522
|
+
|
|
523
|
+
'skills/MANIFEST.json': `{
|
|
524
|
+
"version": "0.5.0",
|
|
525
|
+
"skills": [
|
|
526
|
+
{ "id": "triage", "path": "skills/triage-task/SKILL.md", "description": "Classificação de tarefas" },
|
|
527
|
+
{ "id": "compaction", "path": "skills/context-compaction/SKILL.md", "description": "Compactação de memória" },
|
|
528
|
+
{ "id": "handoff", "path": "skills/handoff/SKILL.md", "description": "Protocolo de transição" },
|
|
529
|
+
{ "id": "nest-api", "path": "skills/nest-api/SKILL.md", "description": "Geração de endpoints NestJS" },
|
|
530
|
+
{ "id": "self-healing", "path": "skills/self-healing/SKILL.md", "description": "Resolução autônoma de erros" },
|
|
531
|
+
{ "id": "validate-handoff", "path": "skills/validate-handoff/SKILL.md", "description": "Checklist de qualidade de handoff" },
|
|
532
|
+
{ "id": "ui-fidelity", "path": "skills/ui-fidelity/SKILL.md", "description": "Auditoria estética de UI" },
|
|
533
|
+
{ "id": "reasoning", "path": "skills/reasoning-protocol/SKILL.md", "description": "Protocolo de raciocínio lógico" }
|
|
534
|
+
]
|
|
535
|
+
}
|
|
536
|
+
`,
|
|
537
|
+
|
|
538
|
+
'prompts/project-prompt-base.md': `# Prompt Base do Projeto
|
|
539
|
+
|
|
540
|
+
Voce e um agente de engenharia sênior neste repositorio.
|
|
541
|
+
|
|
542
|
+
Prioridade de contexto:
|
|
543
|
+
1. memory/00-global/mission.md
|
|
544
|
+
2. memory/00-global/standards.md
|
|
545
|
+
3. memory/00-global/context-policy.md
|
|
546
|
+
4. memory/10-product/*
|
|
547
|
+
5. memory/20-architecture/*
|
|
548
|
+
6. memory/30-domains/<dominio>/*
|
|
549
|
+
7. memory/40-delivery/current-sprint.md
|
|
550
|
+
8. memory/90-decisions/ADR-*.md
|
|
551
|
+
9. memory/70-summaries/*
|
|
552
|
+
|
|
553
|
+
Regras:
|
|
554
|
+
- comunicacao em pt-BR
|
|
555
|
+
- API em NestJS por padrao
|
|
556
|
+
- nao contradizer ADR sem sinalizar
|
|
557
|
+
- explicitar suposicoes
|
|
558
|
+
- **OBRIGATÓRIO**: Usar a skill \`reasoning\` e preencher o bloco \`## Raciocínio Estruturado\` antes de cada resposta técnica.
|
|
559
|
+
- entregar: raciocínio, entendimento, plano, implementacao, validacao e proximos passos
|
|
560
|
+
`,
|
|
561
|
+
|
|
562
|
+
'prompts/multi-agent-orchestrator.md': `# Prompt Orquestrador Multiagente
|
|
563
|
+
|
|
564
|
+
Atue como orquestrador. Divida o trabalho em subtarefas independentes, com ownership por arquivo.
|
|
565
|
+
|
|
566
|
+
Para cada subtarefa, entregue:
|
|
567
|
+
- objetivo
|
|
568
|
+
- escopo de escrita
|
|
569
|
+
- criterio de pronto
|
|
570
|
+
- risco principal
|
|
571
|
+
- agente dono
|
|
572
|
+
|
|
573
|
+
No final, consolide os handoffs em ordem cronologica.
|
|
574
|
+
`,
|
|
575
|
+
|
|
576
|
+
'prompts/worker-task-template.md': `# Prompt Worker
|
|
577
|
+
|
|
578
|
+
Voce recebeu uma subtarefa.
|
|
579
|
+
|
|
580
|
+
Responda com:
|
|
581
|
+
1. **Raciocínio Estruturado** (Uso obrigatório da skill \`reasoning\`)
|
|
582
|
+
2. Entendimento
|
|
583
|
+
3. Implementacao realizada
|
|
584
|
+
4. Arquivos alterados
|
|
585
|
+
5. Validacao/testes
|
|
586
|
+
6. Riscos e pendencias
|
|
587
|
+
`,
|
|
588
|
+
|
|
589
|
+
'AGENTS.md': `# AGENTS
|
|
590
|
+
|
|
591
|
+
## Linguagem
|
|
592
|
+
- Sempre responder e documentar em **pt-BR**.
|
|
593
|
+
|
|
594
|
+
## Stack
|
|
595
|
+
- API padrao do projeto: **NestJS**.
|
|
596
|
+
|
|
597
|
+
## Modo multiagente
|
|
598
|
+
- Orquestrador decompõe tarefas
|
|
599
|
+
- Workers executam em paralelo por ownership
|
|
600
|
+
- Reviewer valida riscos
|
|
601
|
+
|
|
602
|
+
## Memoria
|
|
603
|
+
- Seguir hierarchy em /memory
|
|
604
|
+
- Registrar handoff e resumo ao fim de cada entrega relevante
|
|
605
|
+
`,
|
|
606
|
+
|
|
607
|
+
'.memoryrc.json': `{
|
|
608
|
+
"strategy": "hierarchical",
|
|
609
|
+
"maxContextHint": "1M+ por segmentacao e resumo incremental",
|
|
610
|
+
"handoffDir": "memory/50-orchestration/handoffs",
|
|
611
|
+
"summaryDir": "memory/70-summaries",
|
|
612
|
+
"sqlitePath": ".memory/sqlite/context.db",
|
|
613
|
+
"language": "pt-BR",
|
|
614
|
+
"backendDefault": "nestjs"
|
|
615
|
+
}
|
|
616
|
+
`,
|
|
617
|
+
|
|
618
|
+
'scripts/build-context-pack.mjs': `import fs from 'node:fs';
|
|
619
|
+
import path from 'node:path';
|
|
620
|
+
import { fileURLToPath } from 'node:url';
|
|
621
|
+
|
|
622
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
623
|
+
const __dirname = path.dirname(__filename);
|
|
624
|
+
const root = path.resolve(__dirname, '..');
|
|
625
|
+
const outputDir = path.join(root, '.context');
|
|
626
|
+
const outFile = path.join(outputDir, 'context-pack.md');
|
|
627
|
+
|
|
628
|
+
const priorityFiles = [
|
|
629
|
+
'memory/00-global/mission.md',
|
|
630
|
+
'memory/00-global/standards.md',
|
|
631
|
+
'memory/00-global/context-policy.md',
|
|
632
|
+
'memory/20-architecture/backend.md',
|
|
633
|
+
'memory/40-delivery/current-sprint.md',
|
|
634
|
+
'memory/70-summaries/global-summary.md'
|
|
635
|
+
];
|
|
636
|
+
|
|
637
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
638
|
+
let content = '# Context Pack\\n\\n';
|
|
639
|
+
|
|
640
|
+
for (const rel of priorityFiles) {
|
|
641
|
+
const abs = path.join(root, rel);
|
|
642
|
+
if (!fs.existsSync(abs)) continue;
|
|
643
|
+
const raw = fs.readFileSync(abs, 'utf8').slice(0, 6000);
|
|
644
|
+
content += '## ' + rel + '\\n\\n' + raw + '\\n\\n';
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
fs.writeFileSync(outFile, content, 'utf8');
|
|
648
|
+
console.log('Context pack gerado em: ' + outFile);
|
|
649
|
+
`,
|
|
650
|
+
|
|
651
|
+
'scripts/append-handoff.mjs': `import fs from 'node:fs';
|
|
652
|
+
import path from 'node:path';
|
|
653
|
+
import { fileURLToPath } from 'node:url';
|
|
654
|
+
|
|
655
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
656
|
+
const __dirname = path.dirname(__filename);
|
|
657
|
+
const root = path.resolve(__dirname, '..');
|
|
658
|
+
|
|
659
|
+
const [from = 'agente-a', to = 'agente-b', title = 'handoff'] = process.argv.slice(2);
|
|
660
|
+
const dir = path.join(root, 'memory/50-orchestration/handoffs');
|
|
661
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
662
|
+
|
|
663
|
+
const stamp = new Date().toISOString().replace(/[:]/g, '-');
|
|
664
|
+
const file = path.join(dir, stamp + '_' + from + '_para_' + to + '.md');
|
|
665
|
+
|
|
666
|
+
const template = '# Handoff: ' + from + ' -> ' + to + '\\n\\n'
|
|
667
|
+
+ '## Titulo\\n' + title + '\\n\\n'
|
|
668
|
+
+ '## Contexto\\n-\\n\\n'
|
|
669
|
+
+ '## Alteracoes\\n-\\n\\n'
|
|
670
|
+
+ '## Riscos\\n-\\n\\n'
|
|
671
|
+
+ '## Pendencias\\n-\\n\\n'
|
|
672
|
+
+ '## Proximo passo\\n-\\n';
|
|
673
|
+
|
|
674
|
+
fs.writeFileSync(file, template, 'utf8');
|
|
675
|
+
console.log('Handoff criado: ' + file);
|
|
676
|
+
`,
|
|
677
|
+
|
|
678
|
+
'scripts/lib/skill-loader.mjs': `import fs from 'node:fs';
|
|
679
|
+
import path from 'node:path';
|
|
680
|
+
import { fileURLToPath } from 'node:url';
|
|
681
|
+
|
|
682
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
683
|
+
const __dirname = path.dirname(__filename);
|
|
684
|
+
const root = path.resolve(__dirname, '..', '..');
|
|
685
|
+
|
|
686
|
+
export function loadSkills() {
|
|
687
|
+
const manifestPath = path.join(root, 'skills', 'MANIFEST.json');
|
|
688
|
+
if (!fs.existsSync(manifestPath)) return [];
|
|
689
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
690
|
+
return manifest.skills;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
export function getSkill(id) {
|
|
694
|
+
const skills = loadSkills();
|
|
695
|
+
return skills.find(s => s.id === id);
|
|
696
|
+
}
|
|
697
|
+
`,
|
|
698
|
+
|
|
699
|
+
'scripts/memory-vacuum.mjs': `import fs from 'node:fs';
|
|
700
|
+
import path from 'node:path';
|
|
701
|
+
import { fileURLToPath } from 'node:url';
|
|
702
|
+
|
|
703
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
704
|
+
const __dirname = path.dirname(__filename);
|
|
705
|
+
const root = path.resolve(__dirname, '..');
|
|
706
|
+
const runsDir = path.join(root, 'memory/60-runs');
|
|
707
|
+
const archiveDir = path.join(runsDir, 'archive');
|
|
708
|
+
|
|
709
|
+
const TTL_DAYS = 30;
|
|
710
|
+
const now = Date.now();
|
|
711
|
+
|
|
712
|
+
if (!fs.existsSync(runsDir)) process.exit(0);
|
|
713
|
+
if (!fs.existsSync(archiveDir)) fs.mkdirSync(archiveDir, { recursive: true });
|
|
714
|
+
|
|
715
|
+
const entries = fs.readdirSync(runsDir, { withFileTypes: true });
|
|
716
|
+
|
|
717
|
+
let archived = 0;
|
|
718
|
+
for (const entry of entries) {
|
|
719
|
+
if (entry.name === 'README.md' || entry.name === 'archive' || entry.name === '.gitkeep') continue;
|
|
720
|
+
|
|
721
|
+
const abs = path.join(runsDir, entry.name);
|
|
722
|
+
const stats = fs.statSync(abs);
|
|
723
|
+
const ageDays = (now - stats.mtimeMs) / (1000 * 60 * 60 * 24);
|
|
724
|
+
|
|
725
|
+
if (ageDays > TTL_DAYS) {
|
|
726
|
+
const dest = path.join(archiveDir, entry.name);
|
|
727
|
+
fs.renameSync(abs, dest);
|
|
728
|
+
archived++;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
if (archived > 0) {
|
|
733
|
+
console.log('Vacuum: ' + archived + ' runs movidas para archive/');
|
|
734
|
+
}
|
|
735
|
+
`,
|
|
736
|
+
|
|
737
|
+
'scripts/memory-watcher.mjs': `import { watch } from 'node:fs';
|
|
738
|
+
import { exec } from 'node:child_process';
|
|
739
|
+
import path from 'node:path';
|
|
740
|
+
import { fileURLToPath } from 'node:url';
|
|
741
|
+
|
|
742
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
743
|
+
const __dirname = path.dirname(__filename);
|
|
744
|
+
const root = path.resolve(__dirname, '..');
|
|
745
|
+
|
|
746
|
+
const watchDirs = ['memory', 'agents', 'skills', 'prompts', 'docs'];
|
|
747
|
+
let timeout = null;
|
|
748
|
+
|
|
749
|
+
console.log('👀 Memory Watcher iniciado...');
|
|
750
|
+
|
|
751
|
+
watchDirs.forEach(dir => {
|
|
752
|
+
const absDir = path.join(root, dir);
|
|
753
|
+
watch(absDir, { recursive: true }, (eventType, filename) => {
|
|
754
|
+
if (filename && filename.endsWith('.md')) {
|
|
755
|
+
if (timeout) clearTimeout(timeout);
|
|
756
|
+
timeout = setTimeout(() => {
|
|
757
|
+
console.log('🔄 Mudança detectada em: ' + filename + '. Sincronizando SQLite...');
|
|
758
|
+
exec('npm run memory:db:sync', { cwd: path.join(root, 'backend') }, (err, stdout) => {
|
|
759
|
+
if (err) console.error('❌ Erro no sync: ' + err.message);
|
|
760
|
+
else console.log('✅ SQLite sincronizado.');
|
|
761
|
+
});
|
|
762
|
+
}, 1000);
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
});
|
|
766
|
+
`,
|
|
767
|
+
|
|
768
|
+
'.gitignore': `node_modules
|
|
769
|
+
dist
|
|
770
|
+
.env
|
|
771
|
+
.DS_Store
|
|
772
|
+
coverage
|
|
773
|
+
.context
|
|
774
|
+
`
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
for (const [relativePath, content] of Object.entries(files)) {
|
|
778
|
+
writeFileSafe(path.join(base, relativePath), content);
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
const emptyDirs = [
|
|
782
|
+
'memory/30-domains/shared',
|
|
783
|
+
'memory/90-decisions/archive',
|
|
784
|
+
'docs',
|
|
785
|
+
'scripts/lib',
|
|
786
|
+
'.memory/sqlite',
|
|
787
|
+
'.context'
|
|
788
|
+
];
|
|
789
|
+
|
|
790
|
+
for (const relDir of emptyDirs) {
|
|
791
|
+
const abs = path.join(base, relDir);
|
|
792
|
+
ensureDir(abs);
|
|
793
|
+
maybeGitkeep(abs);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function writeNestApi(base) {
|
|
798
|
+
const files = {
|
|
799
|
+
'backend/package.json': `{
|
|
800
|
+
"name": "${projectName}-api",
|
|
801
|
+
"version": "0.1.0",
|
|
802
|
+
"private": true,
|
|
803
|
+
"scripts": {
|
|
804
|
+
"build": "nest build",
|
|
805
|
+
"start": "nest start",
|
|
806
|
+
"start:dev": "nest start --watch",
|
|
807
|
+
"start:prod": "node dist/main",
|
|
808
|
+
"lint": "eslint \\\"src/**/*.ts\\\" --max-warnings=0",
|
|
809
|
+
"format": "prettier --write \\\"src/**/*.ts\\\" \\\"test/**/*.ts\\\"",
|
|
810
|
+
"test": "jest",
|
|
811
|
+
"test:watch": "jest --watch",
|
|
812
|
+
"test:cov": "jest --coverage",
|
|
813
|
+
"memory:db:init": "node scripts/memory-db-init.mjs",
|
|
814
|
+
"memory:db:sync": "node scripts/memory-db-sync.mjs",
|
|
815
|
+
"memory:db:query": "node scripts/memory-db-query.mjs",
|
|
816
|
+
"memory:watch": "node ../scripts/memory-watcher.mjs"
|
|
817
|
+
},
|
|
818
|
+
"jest": {
|
|
819
|
+
"moduleFileExtensions": ["js", "json", "ts"],
|
|
820
|
+
"rootDir": "src",
|
|
821
|
+
"testRegex": ".*\\\\.spec\\\\.ts$",
|
|
822
|
+
"transform": {
|
|
823
|
+
"^.+\\\\.(t|j)s$": "ts-jest"
|
|
824
|
+
},
|
|
825
|
+
"collectCoverageFrom": ["**/*.(t|j)s"],
|
|
826
|
+
"coverageDirectory": "../coverage",
|
|
827
|
+
"testEnvironment": "node"
|
|
828
|
+
},
|
|
829
|
+
"dependencies": {
|
|
830
|
+
"@nestjs/common": "^11.0.0",
|
|
831
|
+
"@nestjs/core": "^11.0.0",
|
|
832
|
+
"@nestjs/platform-express": "^11.0.0",
|
|
833
|
+
"better-sqlite3": "^11.8.1",
|
|
834
|
+
"reflect-metadata": "^0.2.2",
|
|
835
|
+
"rxjs": "^7.8.1"
|
|
836
|
+
},
|
|
837
|
+
"devDependencies": {
|
|
838
|
+
"@nestjs/cli": "^11.0.0",
|
|
839
|
+
"@nestjs/schematics": "^11.0.0",
|
|
840
|
+
"@nestjs/testing": "^11.0.0",
|
|
841
|
+
"@types/express": "^5.0.1",
|
|
842
|
+
"@types/better-sqlite3": "^11.2.1",
|
|
843
|
+
"@types/jest": "^29.5.14",
|
|
844
|
+
"@types/node": "^22.10.2",
|
|
845
|
+
"@types/supertest": "^6.0.2",
|
|
846
|
+
"eslint": "^9.16.0",
|
|
847
|
+
"eslint-config-prettier": "^9.1.0",
|
|
848
|
+
"jest": "^29.7.0",
|
|
849
|
+
"prettier": "^3.4.2",
|
|
850
|
+
"supertest": "^7.0.0",
|
|
851
|
+
"ts-jest": "^29.2.5",
|
|
852
|
+
"ts-loader": "^9.5.1",
|
|
853
|
+
"ts-node": "^10.9.2",
|
|
854
|
+
"tsconfig-paths": "^4.2.0",
|
|
855
|
+
"typescript": "^5.7.2"
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
`,
|
|
859
|
+
|
|
860
|
+
'backend/nest-cli.json': `{
|
|
861
|
+
"collection": "@nestjs/schematics",
|
|
862
|
+
"sourceRoot": "src"
|
|
863
|
+
}
|
|
864
|
+
`,
|
|
865
|
+
|
|
866
|
+
'backend/tsconfig.json': `{
|
|
867
|
+
"compilerOptions": {
|
|
868
|
+
"module": "commonjs",
|
|
869
|
+
"declaration": true,
|
|
870
|
+
"removeComments": true,
|
|
871
|
+
"emitDecoratorMetadata": true,
|
|
872
|
+
"experimentalDecorators": true,
|
|
873
|
+
"allowSyntheticDefaultImports": true,
|
|
874
|
+
"target": "es2021",
|
|
875
|
+
"sourceMap": true,
|
|
876
|
+
"outDir": "./dist",
|
|
877
|
+
"baseUrl": "./",
|
|
878
|
+
"incremental": true,
|
|
879
|
+
"strict": true,
|
|
880
|
+
"skipLibCheck": true
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
`,
|
|
884
|
+
|
|
885
|
+
'backend/tsconfig.build.json': `{
|
|
886
|
+
"extends": "./tsconfig.json",
|
|
887
|
+
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
|
888
|
+
}
|
|
889
|
+
`,
|
|
890
|
+
|
|
891
|
+
'backend/src/main.ts': `import { NestFactory } from '@nestjs/core';
|
|
892
|
+
import { AppModule } from './app.module';
|
|
893
|
+
|
|
894
|
+
async function bootstrap(): Promise<void> {
|
|
895
|
+
const app = await NestFactory.create(AppModule);
|
|
896
|
+
app.setGlobalPrefix('api');
|
|
897
|
+
await app.listen(process.env.PORT ? Number(process.env.PORT) : 3000);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
void bootstrap();
|
|
901
|
+
`,
|
|
902
|
+
|
|
903
|
+
'backend/src/app.module.ts': 'import { Module } from "@nestjs/common";\nimport { AppController } from "./app.controller";\nimport { AppService } from "./app.service";\nimport { OpsModule } from "./modules/ops/ops.module";\n\n@Module({\n imports: [OpsModule],\n controllers: [AppController],\n providers: [AppService]\n})\nexport class AppModule {}',
|
|
904
|
+
|
|
905
|
+
'backend/src/app.controller.ts': `import { Controller, Get } from '@nestjs/common';
|
|
906
|
+
import { AppService } from './app.service';
|
|
907
|
+
|
|
908
|
+
@Controller()
|
|
909
|
+
export class AppController {
|
|
910
|
+
constructor(private readonly appService: AppService) {}
|
|
911
|
+
|
|
912
|
+
@Get('health')
|
|
913
|
+
health(): { status: string } {
|
|
914
|
+
return this.appService.health();
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
`,
|
|
918
|
+
|
|
919
|
+
'backend/src/app.service.ts': `import { Injectable } from '@nestjs/common';
|
|
920
|
+
|
|
921
|
+
@Injectable()
|
|
922
|
+
export class AppService {
|
|
923
|
+
health(): { status: string } {
|
|
924
|
+
return { status: 'ok' };
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
`,
|
|
928
|
+
|
|
929
|
+
'backend/src/modules/ops/ops.service.ts': `import { Injectable } from '@nestjs/common';
|
|
930
|
+
import * as Database from 'better-sqlite3';
|
|
931
|
+
import * as path from 'node:path';
|
|
932
|
+
|
|
933
|
+
@Injectable()
|
|
934
|
+
export class OpsService {
|
|
935
|
+
private db: any;
|
|
936
|
+
|
|
937
|
+
constructor() {
|
|
938
|
+
const dbPath = path.resolve(process.cwd(), '..', '.memory', 'sqlite', 'context.db');
|
|
939
|
+
this.db = new (Database as any)(dbPath, { readonly: true });
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
getStats() {
|
|
943
|
+
const agents = this.db.prepare('SELECT agent_name, status, current_task FROM agent_sessions').all();
|
|
944
|
+
const tasks = this.db.prepare('SELECT status, COUNT(*) as count FROM tasks GROUP BY status').all();
|
|
945
|
+
const handoffs = this.db.prepare('SELECT from_agent, to_agent, title, created_at FROM handoffs ORDER BY created_at DESC LIMIT 5').all();
|
|
946
|
+
|
|
947
|
+
return { agents, tasks, handoffs };
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
`,
|
|
951
|
+
|
|
952
|
+
'backend/src/modules/ops/ops.controller.ts': `import { Controller, Get } from '@nestjs/common';
|
|
953
|
+
import { OpsService } from './ops.service';
|
|
954
|
+
|
|
955
|
+
@Controller('ops')
|
|
956
|
+
export class OpsController {
|
|
957
|
+
constructor(private readonly opsService: OpsService) {}
|
|
958
|
+
|
|
959
|
+
@Get('stats')
|
|
960
|
+
getStats() {
|
|
961
|
+
return this.opsService.getStats();
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
@Get()
|
|
965
|
+
renderDashboard() {
|
|
966
|
+
const stats = this.opsService.getStats();
|
|
967
|
+
|
|
968
|
+
return \`
|
|
969
|
+
<!DOCTYPE html>
|
|
970
|
+
<html lang="pt-BR">
|
|
971
|
+
<head>
|
|
972
|
+
<meta charset="UTF-8">
|
|
973
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
974
|
+
<title>Agentes Ops Dashboard</title>
|
|
975
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
976
|
+
<meta http-equiv="refresh" content="30">
|
|
977
|
+
</head>
|
|
978
|
+
<body class="bg-gray-900 text-gray-100 font-sans p-8">
|
|
979
|
+
<div class="max-w-6xl mx-auto">
|
|
980
|
+
<header class="flex justify-between items-center mb-12">
|
|
981
|
+
<h1 class="text-3xl font-bold text-blue-400">🚀 Agentes Operacionais</h1>
|
|
982
|
+
<div class="text-sm text-gray-400">Sincronizado via SQLite</div>
|
|
983
|
+
</header>
|
|
984
|
+
|
|
985
|
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
|
|
986
|
+
<!-- Agentes -->
|
|
987
|
+
<section class="bg-gray-800 p-6 rounded-xl border border-gray-700">
|
|
988
|
+
<h2 class="text-xl font-semibold mb-4 flex items-center">
|
|
989
|
+
<span class="mr-2">🤖</span> Status dos Agentes
|
|
990
|
+
</h2>
|
|
991
|
+
<div class="space-y-4">
|
|
992
|
+
\${stats.agents.map((a: any) => \`
|
|
993
|
+
<div class="p-3 bg-gray-900 rounded-lg border-l-4 \${a.status === 'IDLE' ? 'border-green-500' : 'border-yellow-500'}">
|
|
994
|
+
<div class="font-bold">\${a.agent_name}</div>
|
|
995
|
+
<div class="text-xs text-gray-400">\${a.status} \${a.current_task ? ' - ' + a.current_task : ''}</div>
|
|
996
|
+
</div>
|
|
997
|
+
\`).join('')}
|
|
998
|
+
</div>
|
|
999
|
+
</section>
|
|
1000
|
+
|
|
1001
|
+
<!-- Tarefas -->
|
|
1002
|
+
<section class="bg-gray-800 p-6 rounded-xl border border-gray-700">
|
|
1003
|
+
<h2 class="text-xl font-semibold mb-4 flex items-center">
|
|
1004
|
+
<span class="mr-2">📊</span> Backlog & Progresso
|
|
1005
|
+
</h2>
|
|
1006
|
+
<div class="space-y-4">
|
|
1007
|
+
\${stats.tasks.map((t: any) => \`
|
|
1008
|
+
<div class="flex justify-between items-center">
|
|
1009
|
+
<span class="capitalize">\${t.status}</span>
|
|
1010
|
+
<span class="bg-blue-600 px-2 py-1 rounded text-xs">\${t.count}</span>
|
|
1011
|
+
</div>
|
|
1012
|
+
\`).join('')}
|
|
1013
|
+
</div>
|
|
1014
|
+
</section>
|
|
1015
|
+
|
|
1016
|
+
<!-- Handoffs -->
|
|
1017
|
+
<section class="bg-gray-800 p-6 rounded-xl border border-gray-700">
|
|
1018
|
+
<h2 class="text-xl font-semibold mb-4 flex items-center">
|
|
1019
|
+
<span class="mr-2">🤝</span> Últimos Handoffs
|
|
1020
|
+
</h2>
|
|
1021
|
+
<div class="space-y-3">
|
|
1022
|
+
\${stats.handoffs.map((h: any) => \`
|
|
1023
|
+
<div class="text-xs border-b border-gray-700 pb-2">
|
|
1024
|
+
<div class="text-blue-300 font-medium">\${h.from_agent} → \${h.to_agent}</div>
|
|
1025
|
+
<div class="text-gray-400 truncate">\${h.title}</div>
|
|
1026
|
+
</div>
|
|
1027
|
+
\`).join('')}
|
|
1028
|
+
</div>
|
|
1029
|
+
</section>
|
|
1030
|
+
</div>
|
|
1031
|
+
|
|
1032
|
+
<footer class="mt-12 text-center text-gray-500 text-xs">
|
|
1033
|
+
Atualizado em: \${new Date().toLocaleString('pt-BR')} | create-memory-nest-kit v0.5.0
|
|
1034
|
+
</footer>
|
|
1035
|
+
</div>
|
|
1036
|
+
</body>
|
|
1037
|
+
</html>
|
|
1038
|
+
\`;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
`,
|
|
1042
|
+
|
|
1043
|
+
'backend/src/modules/ops/ops.module.ts': `import { Module } from '@nestjs/common';
|
|
1044
|
+
import { OpsController } from './ops.controller';
|
|
1045
|
+
import { OpsService } from './ops.service';
|
|
1046
|
+
|
|
1047
|
+
@Module({
|
|
1048
|
+
controllers: [OpsController],
|
|
1049
|
+
providers: [OpsService]
|
|
1050
|
+
})
|
|
1051
|
+
export class OpsModule {}
|
|
1052
|
+
`,
|
|
1053
|
+
|
|
1054
|
+
'backend/src/app.controller.spec.ts': `import { Test, TestingModule } from '@nestjs/testing';
|
|
1055
|
+
import { AppController } from './app.controller';
|
|
1056
|
+
import { AppService } from './app.service';
|
|
1057
|
+
|
|
1058
|
+
describe('AppController', () => {
|
|
1059
|
+
let controller: AppController;
|
|
1060
|
+
|
|
1061
|
+
beforeEach(async () => {
|
|
1062
|
+
const module: TestingModule = await Test.createTestingModule({
|
|
1063
|
+
controllers: [AppController],
|
|
1064
|
+
providers: [AppService]
|
|
1065
|
+
}).compile();
|
|
1066
|
+
|
|
1067
|
+
controller = module.get<AppController>(AppController);
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
it('health() deve retornar status ok', () => {
|
|
1071
|
+
expect(controller.health()).toEqual({ status: 'ok' });
|
|
1072
|
+
});
|
|
1073
|
+
});
|
|
1074
|
+
`,
|
|
1075
|
+
|
|
1076
|
+
'backend/test/app.e2e-spec.ts': `import { Test, TestingModule } from '@nestjs/testing';
|
|
1077
|
+
import { INestApplication } from '@nestjs/common';
|
|
1078
|
+
import request from 'supertest';
|
|
1079
|
+
import { AppModule } from '../src/app.module';
|
|
1080
|
+
|
|
1081
|
+
describe('AppController (e2e)', () => {
|
|
1082
|
+
let app: INestApplication;
|
|
1083
|
+
|
|
1084
|
+
beforeEach(async () => {
|
|
1085
|
+
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
1086
|
+
imports: [AppModule]
|
|
1087
|
+
}).compile();
|
|
1088
|
+
|
|
1089
|
+
app = moduleFixture.createNestApplication();
|
|
1090
|
+
await app.init();
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
it('/api/health (GET)', async () => {
|
|
1094
|
+
await request(app.getHttpServer())
|
|
1095
|
+
.get('/api/health')
|
|
1096
|
+
.expect(200)
|
|
1097
|
+
.expect({ status: 'ok' });
|
|
1098
|
+
});
|
|
1099
|
+
});
|
|
1100
|
+
`,
|
|
1101
|
+
|
|
1102
|
+
'backend/jest-e2e.json': `{
|
|
1103
|
+
"moduleFileExtensions": ["js", "json", "ts"],
|
|
1104
|
+
"rootDir": ".",
|
|
1105
|
+
"testEnvironment": "node",
|
|
1106
|
+
"testRegex": ".e2e-spec.ts$",
|
|
1107
|
+
"transform": {
|
|
1108
|
+
"^.+\\\\.(t|j)s$": "ts-jest"
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
`,
|
|
1112
|
+
|
|
1113
|
+
'backend/scripts/memory-db-schema.sql': `PRAGMA journal_mode = WAL;
|
|
1114
|
+
PRAGMA foreign_keys = ON;
|
|
1115
|
+
|
|
1116
|
+
CREATE TABLE IF NOT EXISTS documents (
|
|
1117
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1118
|
+
path TEXT NOT NULL UNIQUE,
|
|
1119
|
+
kind TEXT NOT NULL,
|
|
1120
|
+
title TEXT,
|
|
1121
|
+
content_hash TEXT NOT NULL,
|
|
1122
|
+
content TEXT NOT NULL,
|
|
1123
|
+
updated_at TEXT NOT NULL
|
|
1124
|
+
);
|
|
1125
|
+
|
|
1126
|
+
CREATE TABLE IF NOT EXISTS document_chunks (
|
|
1127
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1128
|
+
document_id INTEGER NOT NULL,
|
|
1129
|
+
chunk_index INTEGER NOT NULL,
|
|
1130
|
+
content TEXT NOT NULL,
|
|
1131
|
+
token_estimate INTEGER NOT NULL DEFAULT 0,
|
|
1132
|
+
FOREIGN KEY(document_id) REFERENCES documents(id) ON DELETE CASCADE
|
|
1133
|
+
);
|
|
1134
|
+
|
|
1135
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_document_chunks_unique
|
|
1136
|
+
ON document_chunks (document_id, chunk_index);
|
|
1137
|
+
|
|
1138
|
+
CREATE TABLE IF NOT EXISTS handoffs (
|
|
1139
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1140
|
+
file_path TEXT NOT NULL UNIQUE,
|
|
1141
|
+
from_agent TEXT,
|
|
1142
|
+
to_agent TEXT,
|
|
1143
|
+
title TEXT,
|
|
1144
|
+
created_at TEXT NOT NULL,
|
|
1145
|
+
status TEXT NOT NULL DEFAULT 'open'
|
|
1146
|
+
);
|
|
1147
|
+
|
|
1148
|
+
CREATE TABLE IF NOT EXISTS adrs (
|
|
1149
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1150
|
+
adr_code TEXT NOT NULL UNIQUE,
|
|
1151
|
+
title TEXT NOT NULL,
|
|
1152
|
+
file_path TEXT NOT NULL UNIQUE,
|
|
1153
|
+
status TEXT NOT NULL DEFAULT 'accepted',
|
|
1154
|
+
updated_at TEXT NOT NULL
|
|
1155
|
+
);
|
|
1156
|
+
|
|
1157
|
+
CREATE TABLE IF NOT EXISTS summaries (
|
|
1158
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1159
|
+
scope TEXT NOT NULL,
|
|
1160
|
+
scope_key TEXT NOT NULL,
|
|
1161
|
+
file_path TEXT NOT NULL UNIQUE,
|
|
1162
|
+
summary TEXT NOT NULL,
|
|
1163
|
+
updated_at TEXT NOT NULL
|
|
1164
|
+
);
|
|
1165
|
+
|
|
1166
|
+
CREATE UNIQUE INDEX IF NOT EXISTS idx_summaries_scope
|
|
1167
|
+
ON summaries (scope, scope_key);
|
|
1168
|
+
|
|
1169
|
+
CREATE TABLE IF NOT EXISTS tasks (
|
|
1170
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1171
|
+
task_key TEXT NOT NULL UNIQUE,
|
|
1172
|
+
title TEXT NOT NULL,
|
|
1173
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
1174
|
+
owner_agent TEXT,
|
|
1175
|
+
source_file TEXT NOT NULL,
|
|
1176
|
+
updated_at TEXT NOT NULL
|
|
1177
|
+
);
|
|
1178
|
+
|
|
1179
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
1180
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
1181
|
+
agent_name TEXT NOT NULL UNIQUE,
|
|
1182
|
+
status TEXT NOT NULL DEFAULT 'IDLE', -- IDLE, BUSY, FAILING
|
|
1183
|
+
current_task TEXT,
|
|
1184
|
+
updated_at TEXT NOT NULL
|
|
1185
|
+
);
|
|
1186
|
+
`,
|
|
1187
|
+
|
|
1188
|
+
'backend/scripts/memory-db-init.mjs': `import fs from 'node:fs';
|
|
1189
|
+
import path from 'node:path';
|
|
1190
|
+
import Database from 'better-sqlite3';
|
|
1191
|
+
import { fileURLToPath } from 'node:url';
|
|
1192
|
+
|
|
1193
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
1194
|
+
const __dirname = path.dirname(__filename);
|
|
1195
|
+
const backendRoot = path.resolve(__dirname, '..');
|
|
1196
|
+
const projectRoot = path.resolve(backendRoot, '..');
|
|
1197
|
+
const dbDir = path.join(projectRoot, '.memory', 'sqlite');
|
|
1198
|
+
const dbPath = path.join(dbDir, 'context.db');
|
|
1199
|
+
const schemaPath = path.join(__dirname, 'memory-db-schema.sql');
|
|
1200
|
+
|
|
1201
|
+
fs.mkdirSync(dbDir, { recursive: true });
|
|
1202
|
+
const schema = fs.readFileSync(schemaPath, 'utf8');
|
|
1203
|
+
const db = new Database(dbPath);
|
|
1204
|
+
db.exec(schema);
|
|
1205
|
+
db.close();
|
|
1206
|
+
|
|
1207
|
+
console.log('SQLite inicializado em: ' + dbPath);
|
|
1208
|
+
`,
|
|
1209
|
+
|
|
1210
|
+
'backend/scripts/memory-db-sync.mjs': `import fs from 'node:fs';
|
|
1211
|
+
import path from 'node:path';
|
|
1212
|
+
import crypto from 'node:crypto';
|
|
1213
|
+
import Database from 'better-sqlite3';
|
|
1214
|
+
import { fileURLToPath } from 'node:url';
|
|
1215
|
+
|
|
1216
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
1217
|
+
const __dirname = path.dirname(__filename);
|
|
1218
|
+
const backendRoot = path.resolve(__dirname, '..');
|
|
1219
|
+
const projectRoot = path.resolve(backendRoot, '..');
|
|
1220
|
+
const dbPath = path.join(projectRoot, '.memory', 'sqlite', 'context.db');
|
|
1221
|
+
|
|
1222
|
+
function walk(dir, out = []) {
|
|
1223
|
+
if (!fs.existsSync(dir)) return out;
|
|
1224
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
1225
|
+
if (entry.name === 'node_modules' || entry.name === '.git') continue;
|
|
1226
|
+
const abs = path.join(dir, entry.name);
|
|
1227
|
+
if (entry.isDirectory()) walk(abs, out);
|
|
1228
|
+
else if (entry.isFile() && entry.name.endsWith('.md')) out.push(abs);
|
|
1229
|
+
}
|
|
1230
|
+
return out;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
function toPosix(p) {
|
|
1234
|
+
return p.split(path.sep).join('/');
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
function getKind(relPath) {
|
|
1238
|
+
if (relPath.startsWith('memory/50-orchestration/handoffs/')) return 'handoff';
|
|
1239
|
+
if (relPath.startsWith('memory/90-decisions/ADR-')) return 'adr';
|
|
1240
|
+
if (relPath.startsWith('memory/70-summaries/')) return 'summary';
|
|
1241
|
+
if (relPath.startsWith('memory/')) return 'memory';
|
|
1242
|
+
if (relPath.startsWith('agents/')) return 'agent';
|
|
1243
|
+
if (relPath.startsWith('skills/')) return 'skill';
|
|
1244
|
+
if (relPath.startsWith('prompts/')) return 'prompt';
|
|
1245
|
+
if (relPath.startsWith('docs/')) return 'doc';
|
|
1246
|
+
return 'other';
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
function getTitle(md) {
|
|
1250
|
+
const m = md.match(/^#\\s+(.+)$/m);
|
|
1251
|
+
return m ? m[1].trim() : null;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
function splitChunks(content, size = 1600) {
|
|
1255
|
+
const chunks = [];
|
|
1256
|
+
for (let i = 0; i < content.length; i += size) {
|
|
1257
|
+
chunks.push(content.slice(i, i + size));
|
|
1258
|
+
}
|
|
1259
|
+
return chunks;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
const roots = ['memory', 'docs', 'agents', 'skills', 'prompts'].map((r) => path.join(projectRoot, r));
|
|
1263
|
+
const mdFiles = roots.flatMap((r) => walk(r)).sort();
|
|
1264
|
+
|
|
1265
|
+
if (!fs.existsSync(dbPath)) {
|
|
1266
|
+
console.error('Banco nao encontrado: ' + dbPath);
|
|
1267
|
+
console.error('Rode primeiro: npm run memory:db:init');
|
|
1268
|
+
process.exit(1);
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
const db = new Database(dbPath);
|
|
1272
|
+
const now = new Date().toISOString();
|
|
1273
|
+
|
|
1274
|
+
const upsertDoc = db.prepare(
|
|
1275
|
+
'INSERT INTO documents (path, kind, title, content_hash, content, updated_at) VALUES (?, ?, ?, ?, ?, ?) '
|
|
1276
|
+
+ 'ON CONFLICT(path) DO UPDATE SET kind=excluded.kind, title=excluded.title, content_hash=excluded.content_hash, content=excluded.content, updated_at=excluded.updated_at'
|
|
1277
|
+
);
|
|
1278
|
+
const selectDocId = db.prepare('SELECT id FROM documents WHERE path = ?');
|
|
1279
|
+
const deleteChunks = db.prepare('DELETE FROM document_chunks WHERE document_id = ?');
|
|
1280
|
+
const insertChunk = db.prepare(
|
|
1281
|
+
'INSERT INTO document_chunks (document_id, chunk_index, content, token_estimate) VALUES (?, ?, ?, ?)'
|
|
1282
|
+
);
|
|
1283
|
+
|
|
1284
|
+
const upsertHandoff = db.prepare(
|
|
1285
|
+
'INSERT INTO handoffs (file_path, from_agent, to_agent, title, created_at, status) VALUES (?, ?, ?, ?, ?, ?) '
|
|
1286
|
+
+ 'ON CONFLICT(file_path) DO UPDATE SET from_agent=excluded.from_agent, to_agent=excluded.to_agent, title=excluded.title, created_at=excluded.created_at'
|
|
1287
|
+
);
|
|
1288
|
+
|
|
1289
|
+
const upsertAdr = db.prepare(
|
|
1290
|
+
'INSERT INTO adrs (adr_code, title, file_path, status, updated_at) VALUES (?, ?, ?, ?, ?) '
|
|
1291
|
+
+ 'ON CONFLICT(adr_code) DO UPDATE SET title=excluded.title, file_path=excluded.file_path, status=excluded.status, updated_at=excluded.updated_at'
|
|
1292
|
+
);
|
|
1293
|
+
|
|
1294
|
+
const upsertSummary = db.prepare(
|
|
1295
|
+
'INSERT INTO summaries (scope, scope_key, file_path, summary, updated_at) VALUES (?, ?, ?, ?, ?) '
|
|
1296
|
+
+ 'ON CONFLICT(file_path) DO UPDATE SET scope=excluded.scope, scope_key=excluded.scope_key, summary=excluded.summary, updated_at=excluded.updated_at'
|
|
1297
|
+
);
|
|
1298
|
+
|
|
1299
|
+
const upsertTask = db.prepare(
|
|
1300
|
+
'INSERT INTO tasks (task_key, title, status, owner_agent, source_file, updated_at) VALUES (?, ?, ?, ?, ?, ?) '
|
|
1301
|
+
+ 'ON CONFLICT(task_key) DO UPDATE SET title=excluded.title, status=excluded.status, owner_agent=excluded.owner_agent, source_file=excluded.source_file, updated_at=excluded.updated_at'
|
|
1302
|
+
);
|
|
1303
|
+
|
|
1304
|
+
const tx = db.transaction(() => {
|
|
1305
|
+
for (const abs of mdFiles) {
|
|
1306
|
+
const rel = toPosix(path.relative(projectRoot, abs));
|
|
1307
|
+
const raw = fs.readFileSync(abs, 'utf8');
|
|
1308
|
+
const hash = crypto.createHash('sha256').update(raw).digest('hex');
|
|
1309
|
+
const kind = getKind(rel);
|
|
1310
|
+
const title = getTitle(raw);
|
|
1311
|
+
|
|
1312
|
+
upsertDoc.run(rel, kind, title, hash, raw, now);
|
|
1313
|
+
const row = selectDocId.get(rel);
|
|
1314
|
+
if (!row) continue;
|
|
1315
|
+
|
|
1316
|
+
deleteChunks.run(row.id);
|
|
1317
|
+
const chunks = splitChunks(raw);
|
|
1318
|
+
chunks.forEach((chunk, i) => {
|
|
1319
|
+
const tokens = Math.ceil(chunk.length / 4);
|
|
1320
|
+
insertChunk.run(row.id, i, chunk, tokens);
|
|
1321
|
+
});
|
|
1322
|
+
|
|
1323
|
+
if (kind === 'handoff' && !rel.endsWith('/README.md')) {
|
|
1324
|
+
const base = path.basename(rel, '.md');
|
|
1325
|
+
const fromTo = base.split('_').slice(1).join('_');
|
|
1326
|
+
const from = fromTo.split('_para_')[0] || null;
|
|
1327
|
+
const to = fromTo.split('_para_')[1] || null;
|
|
1328
|
+
upsertHandoff.run(rel, from, to, title || base, now, 'open');
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
if (kind === 'adr') {
|
|
1332
|
+
const code = path.basename(rel, '.md').split('-').slice(0, 2).join('-');
|
|
1333
|
+
upsertAdr.run(code, title || code, rel, 'accepted', now);
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
if (kind === 'summary') {
|
|
1337
|
+
const file = path.basename(rel, '.md');
|
|
1338
|
+
const scope = file.includes('global') ? 'global' : 'domain';
|
|
1339
|
+
const scopeKey = file.replace('-summary', '');
|
|
1340
|
+
upsertSummary.run(scope, scopeKey, rel, raw.slice(0, 20000), now);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
if (rel === 'memory/40-delivery/current-sprint.md' || rel === 'memory/40-delivery/backlog.md') {
|
|
1344
|
+
const lines = raw.split('\\n');
|
|
1345
|
+
for (const line of lines) {
|
|
1346
|
+
const m = line.match(/^[-*]\\s+\\[\\s\\]\\s+(.+)$/);
|
|
1347
|
+
if (!m) continue;
|
|
1348
|
+
const taskTitle = m[1].trim();
|
|
1349
|
+
const taskKey = crypto.createHash('md5').update(rel + ':' + taskTitle).digest('hex');
|
|
1350
|
+
upsertTask.run(taskKey, taskTitle, 'open', null, rel, now);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1355
|
+
|
|
1356
|
+
tx();
|
|
1357
|
+
db.close();
|
|
1358
|
+
console.log('Sync concluido. Arquivos indexados: ' + mdFiles.length);
|
|
1359
|
+
`,
|
|
1360
|
+
|
|
1361
|
+
'backend/scripts/memory-db-query.mjs': `import path from 'node:path';
|
|
1362
|
+
import Database from 'better-sqlite3';
|
|
1363
|
+
import { fileURLToPath } from 'node:url';
|
|
1364
|
+
|
|
1365
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
1366
|
+
const __dirname = path.dirname(__filename);
|
|
1367
|
+
const backendRoot = path.resolve(__dirname, '..');
|
|
1368
|
+
const projectRoot = path.resolve(backendRoot, '..');
|
|
1369
|
+
const dbPath = path.join(projectRoot, '.memory', 'sqlite', 'context.db');
|
|
1370
|
+
|
|
1371
|
+
const args = process.argv.slice(2);
|
|
1372
|
+
const mode = args[0] || 'search';
|
|
1373
|
+
const term = args[1] || '';
|
|
1374
|
+
const limit = Number(args[2] || 10);
|
|
1375
|
+
|
|
1376
|
+
const db = new Database(dbPath, { readonly: true });
|
|
1377
|
+
|
|
1378
|
+
if (mode === 'handoffs') {
|
|
1379
|
+
const rows = db.prepare(
|
|
1380
|
+
'SELECT file_path, from_agent, to_agent, title, created_at FROM handoffs ORDER BY created_at DESC LIMIT ?'
|
|
1381
|
+
).all(limit);
|
|
1382
|
+
for (const row of rows) {
|
|
1383
|
+
console.log('- ' + row.created_at + ' | ' + row.from_agent + ' -> ' + row.to_agent + ' | ' + row.title);
|
|
1384
|
+
console.log(' ' + row.file_path);
|
|
1385
|
+
}
|
|
1386
|
+
process.exit(0);
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
if (mode === 'adrs') {
|
|
1390
|
+
const rows = db.prepare(
|
|
1391
|
+
'SELECT adr_code, title, status, file_path, updated_at FROM adrs ORDER BY adr_code LIMIT ?'
|
|
1392
|
+
).all(limit);
|
|
1393
|
+
for (const row of rows) {
|
|
1394
|
+
console.log('- ' + row.adr_code + ' | ' + row.status + ' | ' + row.title);
|
|
1395
|
+
console.log(' ' + row.file_path + ' (' + row.updated_at + ')');
|
|
1396
|
+
}
|
|
1397
|
+
process.exit(0);
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
const rows = db.prepare(
|
|
1401
|
+
'SELECT path, kind, title, substr(content, 1, 200) as snippet FROM documents '
|
|
1402
|
+
+ 'WHERE content LIKE ? OR title LIKE ? OR path LIKE ? '
|
|
1403
|
+
+ 'ORDER BY updated_at DESC LIMIT ?'
|
|
1404
|
+
).all('%' + term + '%', '%' + term + '%', '%' + term + '%', limit);
|
|
1405
|
+
|
|
1406
|
+
for (const row of rows) {
|
|
1407
|
+
console.log('- [' + row.kind + '] ' + row.path);
|
|
1408
|
+
if (row.title) console.log(' titulo: ' + row.title);
|
|
1409
|
+
console.log(' trecho: ' + row.snippet.replace(/\\n/g, ' '));
|
|
1410
|
+
}
|
|
1411
|
+
`
|
|
1412
|
+
};
|
|
1413
|
+
|
|
1414
|
+
for (const [relativePath, content] of Object.entries(files)) {
|
|
1415
|
+
writeFileSafe(path.join(base, relativePath), content);
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
function writeReadme(base) {
|
|
1420
|
+
const content = `# create-memory-nest-kit v0.5.0
|
|
1421
|
+
|
|
1422
|
+
Scaffold para projetos grandes com:
|
|
1423
|
+
- memoria hierarquica e resumida
|
|
1424
|
+
- suporte operacional para multiagentes
|
|
1425
|
+
- handoff e continuidade de execucao
|
|
1426
|
+
- API NestJS por padrao
|
|
1427
|
+
- comunicacao em pt-BR
|
|
1428
|
+
|
|
1429
|
+
## Importante sobre 1M+ de tokens
|
|
1430
|
+
Este kit **nao altera limite nativo** de contexto do modelo.
|
|
1431
|
+
Ele permite operar em larga escala com segmentacao, resumo e handoff incremental.
|
|
1432
|
+
|
|
1433
|
+
## Uso local
|
|
1434
|
+
|
|
1435
|
+
\`node ./bin/create-memory-nest-kit.js meu-projeto\`
|
|
1436
|
+
|
|
1437
|
+
## Uso via npx (GitHub)
|
|
1438
|
+
|
|
1439
|
+
\`npx github:SEU_USUARIO/create-memory-nest-kit meu-projeto\`
|
|
1440
|
+
|
|
1441
|
+
## Uso via npx (npm)
|
|
1442
|
+
|
|
1443
|
+
\`npx create-memory-nest-kit@latest meu-projeto\`
|
|
1444
|
+
|
|
1445
|
+
## Flags
|
|
1446
|
+
|
|
1447
|
+
- \`--force\`: sobrescreve arquivos existentes
|
|
1448
|
+
- \`--only-memory\`: gera apenas memoria + agents + skills
|
|
1449
|
+
- \`--no-gitkeep\`: nao cria .gitkeep em diretorios vazios
|
|
1450
|
+
|
|
1451
|
+
## Scripts uteis no projeto gerado
|
|
1452
|
+
|
|
1453
|
+
- \`node scripts/build-context-pack.mjs\`
|
|
1454
|
+
- \`node scripts/append-handoff.mjs worker-a worker-b "titulo"\`
|
|
1455
|
+
- \`cd backend && npm run memory:db:init\`
|
|
1456
|
+
- \`cd backend && npm run memory:db:sync\`
|
|
1457
|
+
- \`cd backend && npm run memory:db:query -- "termo"\`
|
|
1458
|
+
`;
|
|
1459
|
+
|
|
1460
|
+
writeFileSafe(path.join(base, 'README.md'), content);
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
function run() {
|
|
1464
|
+
try {
|
|
1465
|
+
ensureDir(targetDir);
|
|
1466
|
+
|
|
1467
|
+
writeMemoryAndOps(targetDir);
|
|
1468
|
+
if (!options.onlyMemory) writeNestApi(targetDir);
|
|
1469
|
+
writeReadme(targetDir);
|
|
1470
|
+
|
|
1471
|
+
log('✅ Estrutura v0.5.0 criada com sucesso.');
|
|
1472
|
+
log(`📁 Diretorio: ${targetDir}`);
|
|
1473
|
+
log('➡️ Proximos passos:');
|
|
1474
|
+
log(` 1) cd ${path.relative(process.cwd(), targetDir) || '.'}`);
|
|
1475
|
+
log(' 2) node scripts/build-context-pack.mjs');
|
|
1476
|
+
if (!options.onlyMemory) {
|
|
1477
|
+
log(' 3) cd backend && npm install');
|
|
1478
|
+
log(' 4) npm run start:dev');
|
|
1479
|
+
}
|
|
1480
|
+
} catch (error) {
|
|
1481
|
+
console.error(`❌ Erro: ${error.message}`);
|
|
1482
|
+
process.exit(1);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
run();
|