@onion-ai/cli 1.0.0-beta.1
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/LICENSE +21 -0
- package/README.md +529 -0
- package/bin/onion.js +6 -0
- package/framework/CLAUDE.md +45 -0
- package/framework/VERSION +1 -0
- package/framework/agents/compliance/iso-22301-specialist.md +985 -0
- package/framework/agents/compliance/iso-27001-specialist.md +713 -0
- package/framework/agents/compliance/pmbok-specialist.md +739 -0
- package/framework/agents/compliance/security-information-master.md +907 -0
- package/framework/agents/compliance/soc2-specialist.md +889 -0
- package/framework/agents/deployment/docker-specialist.md +1192 -0
- package/framework/agents/development/c4-architecture-specialist.md +745 -0
- package/framework/agents/development/c4-documentation-specialist.md +695 -0
- package/framework/agents/development/clickup-specialist.md +396 -0
- package/framework/agents/development/cursor-specialist.md +277 -0
- package/framework/agents/development/docs-reverse-engineer.md +417 -0
- package/framework/agents/development/gamma-api-specialist.md +1168 -0
- package/framework/agents/development/gitflow-specialist.md +1206 -0
- package/framework/agents/development/linux-security-specialist.md +675 -0
- package/framework/agents/development/mermaid-specialist.md +515 -0
- package/framework/agents/development/nodejs-specialist.md +672 -0
- package/framework/agents/development/nx-migration-specialist.md +866 -0
- package/framework/agents/development/nx-monorepo-specialist.md +618 -0
- package/framework/agents/development/postgres-specialist.md +1123 -0
- package/framework/agents/development/react-developer.md +131 -0
- package/framework/agents/development/runflow-specialist.md +277 -0
- package/framework/agents/development/system-documentation-orchestrator.md +1387 -0
- package/framework/agents/development/task-specialist.md +677 -0
- package/framework/agents/git/branch-code-reviewer.md +225 -0
- package/framework/agents/git/branch-documentation-writer.md +161 -0
- package/framework/agents/git/branch-metaspec-checker.md +67 -0
- package/framework/agents/git/branch-test-planner.md +176 -0
- package/framework/agents/meta/agent-creator-specialist.md +1266 -0
- package/framework/agents/meta/command-creator-specialist.md +1676 -0
- package/framework/agents/meta/metaspec-gate-keeper.md +240 -0
- package/framework/agents/meta/onion.md +824 -0
- package/framework/agents/product/branding-positioning-specialist.md +1029 -0
- package/framework/agents/product/extract-meeting-specialist.md +394 -0
- package/framework/agents/product/meeting-consolidator.md +482 -0
- package/framework/agents/product/pain-price-specialist.md +508 -0
- package/framework/agents/product/presentation-orchestrator.md +1190 -0
- package/framework/agents/product/product-agent.md +201 -0
- package/framework/agents/product/story-points-framework-specialist.md +538 -0
- package/framework/agents/product/storytelling-business-specialist.md +890 -0
- package/framework/agents/research/research-agent.md +292 -0
- package/framework/agents/review/code-reviewer.md +154 -0
- package/framework/agents/review/corporate-compliance-specialist.md +370 -0
- package/framework/agents/testing/test-agent.md +424 -0
- package/framework/agents/testing/test-engineer.md +294 -0
- package/framework/agents/testing/test-planner.md +117 -0
- package/framework/commands/common/prompts/README.md +208 -0
- package/framework/commands/common/prompts/clickup-patterns.md +144 -0
- package/framework/commands/common/prompts/code-review-checklist.md +168 -0
- package/framework/commands/common/prompts/git-workflow-patterns.md +235 -0
- package/framework/commands/common/prompts/output-formats.md +240 -0
- package/framework/commands/common/prompts/technical.md +194 -0
- package/framework/commands/common/templates/abstraction-template.md +399 -0
- package/framework/commands/common/templates/agent-template.md +353 -0
- package/framework/commands/common/templates/business_context_template.md +748 -0
- package/framework/commands/common/templates/command-template.md +273 -0
- package/framework/commands/common/templates/technical_context_template.md +526 -0
- package/framework/commands/design/screen-spec.md +505 -0
- package/framework/commands/development/runflow-dev.md +465 -0
- package/framework/commands/docs/build-business-docs.md +299 -0
- package/framework/commands/docs/build-compliance-docs.md +143 -0
- package/framework/commands/docs/build-index.md +119 -0
- package/framework/commands/docs/build-tech-docs.md +221 -0
- package/framework/commands/docs/docs-health.md +141 -0
- package/framework/commands/docs/help.md +278 -0
- package/framework/commands/docs/refine-vision.md +25 -0
- package/framework/commands/docs/reverse-consolidate.md +158 -0
- package/framework/commands/docs/sync-sessions.md +354 -0
- package/framework/commands/docs/validate-docs.md +157 -0
- package/framework/commands/engineer/bump.md +29 -0
- package/framework/commands/engineer/docs.md +11 -0
- package/framework/commands/engineer/hotfix.md +183 -0
- package/framework/commands/engineer/plan.md +85 -0
- package/framework/commands/engineer/pr-update.md +219 -0
- package/framework/commands/engineer/pr.md +117 -0
- package/framework/commands/engineer/pre-pr.md +81 -0
- package/framework/commands/engineer/start.md +254 -0
- package/framework/commands/engineer/validate-phase-sync.md +134 -0
- package/framework/commands/engineer/warm-up.md +20 -0
- package/framework/commands/engineer/work.md +155 -0
- package/framework/commands/f/company-context-extractor.md +93 -0
- package/framework/commands/f/process-meetings.md +103 -0
- package/framework/commands/git/README.md +682 -0
- package/framework/commands/git/code-review.md +213 -0
- package/framework/commands/git/fast-commit.md +43 -0
- package/framework/commands/git/feature/finish.md +88 -0
- package/framework/commands/git/feature/publish.md +89 -0
- package/framework/commands/git/feature/start.md +172 -0
- package/framework/commands/git/help.md +100 -0
- package/framework/commands/git/hotfix/finish.md +96 -0
- package/framework/commands/git/hotfix/start.md +92 -0
- package/framework/commands/git/init.md +111 -0
- package/framework/commands/git/release/finish.md +96 -0
- package/framework/commands/git/release/start.md +93 -0
- package/framework/commands/git/sync.md +199 -0
- package/framework/commands/meta/all-tools.md +58 -0
- package/framework/commands/meta/analyze-complex-problem.md +186 -0
- package/framework/commands/meta/create-abstraction.md +882 -0
- package/framework/commands/meta/create-agent-express.md +98 -0
- package/framework/commands/meta/create-agent.md +210 -0
- package/framework/commands/meta/create-command.md +203 -0
- package/framework/commands/meta/create-knowledge-base.md +143 -0
- package/framework/commands/meta/create-task-structure.md +150 -0
- package/framework/commands/meta/setup-integration.md +274 -0
- package/framework/commands/onion.md +169 -0
- package/framework/commands/product/README.md +249 -0
- package/framework/commands/product/analyze-pain-price.md +694 -0
- package/framework/commands/product/branding.md +458 -0
- package/framework/commands/product/check.md +46 -0
- package/framework/commands/product/checklist-sync.md +239 -0
- package/framework/commands/product/collect.md +95 -0
- package/framework/commands/product/consolidate-meetings.md +291 -0
- package/framework/commands/product/estimate.md +511 -0
- package/framework/commands/product/extract-meeting.md +226 -0
- package/framework/commands/product/feature.md +416 -0
- package/framework/commands/product/light-arch.md +82 -0
- package/framework/commands/product/presentation.md +174 -0
- package/framework/commands/product/refine.md +161 -0
- package/framework/commands/product/spec.md +79 -0
- package/framework/commands/product/task-check.md +378 -0
- package/framework/commands/product/task.md +603 -0
- package/framework/commands/product/validate-task.md +325 -0
- package/framework/commands/product/warm-up.md +24 -0
- package/framework/commands/quick/analisys.md +17 -0
- package/framework/commands/test/e2e.md +377 -0
- package/framework/commands/test/integration.md +508 -0
- package/framework/commands/test/unit.md +381 -0
- package/framework/commands/validate/collab/pair-testing.md +657 -0
- package/framework/commands/validate/collab/three-amigos.md +534 -0
- package/framework/commands/validate/qa-points/estimate.md +660 -0
- package/framework/commands/validate/test-strategy/analyze.md +1201 -0
- package/framework/commands/validate/test-strategy/create.md +411 -0
- package/framework/commands/validate/workflow.md +370 -0
- package/framework/commands/warm-up.md +20 -0
- package/framework/docs/architecture/acoplamento-clickup-problema-analise.md +468 -0
- package/framework/docs/architecture/desacoplamento-roadmap.md +364 -0
- package/framework/docs/architecture/validacao-fase-1.md +235 -0
- package/framework/docs/c4/c4-detection-rules.md +395 -0
- package/framework/docs/c4/c4-documentation-templates.md +579 -0
- package/framework/docs/c4/c4-mermaid-patterns.md +331 -0
- package/framework/docs/c4/c4-templates.md +256 -0
- package/framework/docs/clickup/clickup-acceptance-criteria-strategy.md +329 -0
- package/framework/docs/clickup/clickup-auto-update-strategy.md +340 -0
- package/framework/docs/clickup/clickup-comment-formatter.md +239 -0
- package/framework/docs/clickup/clickup-description-fix.md +384 -0
- package/framework/docs/clickup/clickup-dual-comment-strategy.md +528 -0
- package/framework/docs/clickup/clickup-formatting.md +302 -0
- package/framework/docs/clickup/separador-tamanho-otimizado.md +258 -0
- package/framework/docs/engineer/pre-pr-acceptance-validation.md +256 -0
- package/framework/docs/onion/ESPERANTO.md +293 -0
- package/framework/docs/onion/agents-reference.md +832 -0
- package/framework/docs/onion/clickup-integration.md +780 -0
- package/framework/docs/onion/commands-guide.md +924 -0
- package/framework/docs/onion/engineering-flows.md +900 -0
- package/framework/docs/onion/getting-started.md +803 -0
- package/framework/docs/onion/maintenance-checklist.md +421 -0
- package/framework/docs/onion/naming-conventions.md +286 -0
- package/framework/docs/onion/practical-examples.md +854 -0
- package/framework/docs/product/story-points-integration.md +269 -0
- package/framework/docs/product/story-points-validation.md +237 -0
- package/framework/docs/reviews/task-manager-docs-review-2025-11-24.md +184 -0
- package/framework/docs/strategies/clickup-comment-patterns.md +766 -0
- package/framework/docs/strategies/clickup-integration-tests.md +602 -0
- package/framework/docs/strategies/clickup-mcp-wrappers-tests.md +888 -0
- package/framework/docs/strategies/clickup-regression-tests.md +587 -0
- package/framework/docs/strategies/visual-patterns.md +315 -0
- package/framework/docs/templates/README.md +649 -0
- package/framework/docs/templates/adr-template.md +226 -0
- package/framework/docs/templates/analysis-template.md +280 -0
- package/framework/docs/templates/execution-plan-template.md +430 -0
- package/framework/docs/templates/guide-template.md +367 -0
- package/framework/docs/templates/phase-execution-prompt-template.md +504 -0
- package/framework/docs/templates/reference-template.md +522 -0
- package/framework/docs/templates/solution-template.md +390 -0
- package/framework/docs/tools/README.md +356 -0
- package/framework/docs/tools/agents.md +365 -0
- package/framework/docs/tools/commands.md +669 -0
- package/framework/docs/tools/cursor.md +539 -0
- package/framework/docs/tools/mcps.md +937 -0
- package/framework/docs/tools/rules.md +461 -0
- package/framework/rules/language-and-documentation.mdc +371 -0
- package/framework/rules/nestjs-controllers.md +83 -0
- package/framework/rules/nestjs-dtos.md +255 -0
- package/framework/rules/nestjs-modules.md +141 -0
- package/framework/rules/nestjs-services.md +230 -0
- package/framework/rules/nx-rules.mdc +41 -0
- package/framework/rules/onion-patterns.mdc +197 -0
- package/framework/skills/codebase-visualizer/SKILL.md +26 -0
- package/framework/skills/codebase-visualizer/scripts/visualize.py +131 -0
- package/framework/skills/collect/SKILL.md +84 -0
- package/framework/skills/create-rule/SKILL.md +152 -0
- package/framework/skills/db-schema-visualizer/SKILL.md +49 -0
- package/framework/skills/db-schema-visualizer/scripts/visualize.py +1191 -0
- package/framework/skills/sync-meetings/SKILL.md +239 -0
- package/framework/utils/clickup-mcp-wrappers.md +744 -0
- package/framework/utils/date-time-standards.md +200 -0
- package/framework/utils/task-manager/README.md +94 -0
- package/framework/utils/task-manager/adapters/asana.md +377 -0
- package/framework/utils/task-manager/adapters/clickup.md +467 -0
- package/framework/utils/task-manager/adapters/linear.md +421 -0
- package/framework/utils/task-manager/detector.md +299 -0
- package/framework/utils/task-manager/factory.md +363 -0
- package/framework/utils/task-manager/interface.md +248 -0
- package/framework/utils/task-manager/types.md +409 -0
- package/package.json +41 -0
- package/src/cli.js +73 -0
- package/src/commands/doctor.js +191 -0
- package/src/commands/init.js +287 -0
- package/src/commands/install.js +261 -0
- package/src/commands/list.js +152 -0
- package/src/commands/uninstall.js +90 -0
- package/src/commands/update.js +26 -0
- package/src/utils/fs.js +89 -0
- package/src/utils/log.js +35 -0
- package/src/utils/paths.js +32 -0
- package/src/utils/prompt.js +76 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- 'apps/api/src/modules/**/*.module.ts'
|
|
4
|
+
- 'apps/api/src/modules/**/index.ts'
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# NestJS Module Standards
|
|
8
|
+
|
|
9
|
+
Reference implementation: `apps/api/src/modules/initiatives/initiatives.module.ts`
|
|
10
|
+
|
|
11
|
+
## Module Types
|
|
12
|
+
|
|
13
|
+
### Feature modules (initiatives, creators, brands)
|
|
14
|
+
|
|
15
|
+
Portal-split structure when both portals need separate endpoints:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
modules/[feature]/
|
|
19
|
+
├── admin/
|
|
20
|
+
│ ├── [name].controller.ts
|
|
21
|
+
│ └── dto/
|
|
22
|
+
│ ├── [action].dto.ts
|
|
23
|
+
│ ├── responses/[resource].response.ts
|
|
24
|
+
│ └── index.ts
|
|
25
|
+
├── creator/
|
|
26
|
+
│ ├── [name].controller.ts
|
|
27
|
+
│ └── dto/
|
|
28
|
+
│ └── index.ts
|
|
29
|
+
├── shared/
|
|
30
|
+
│ ├── [name].service.ts
|
|
31
|
+
│ └── dto/ # Only if both portals share the same DTO
|
|
32
|
+
├── [feature].module.ts
|
|
33
|
+
└── index.ts
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Simpler features (like brands settings) can use admin-only structure without creator/:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
modules/[feature]/
|
|
40
|
+
├── admin/
|
|
41
|
+
│ ├── [name]-admin.controller.ts
|
|
42
|
+
│ └── dto/
|
|
43
|
+
├── [feature].controller.ts # Public controller (if needed)
|
|
44
|
+
├── [feature].service.ts
|
|
45
|
+
├── [feature].module.ts
|
|
46
|
+
└── index.ts
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Infrastructure modules (auth, remote-files, queue)
|
|
50
|
+
|
|
51
|
+
Flat structure, no portal split:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
modules/[feature]/
|
|
55
|
+
├── [feature].controller.ts
|
|
56
|
+
├── [feature].service.ts
|
|
57
|
+
├── dto/
|
|
58
|
+
├── guards/
|
|
59
|
+
├── decorators/
|
|
60
|
+
├── [feature].module.ts
|
|
61
|
+
└── index.ts
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Module Registration
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
@Module({
|
|
68
|
+
imports: [DatabaseModule, AuthModule], // Dependencies
|
|
69
|
+
controllers: [AdminController, CreatorController],
|
|
70
|
+
providers: [
|
|
71
|
+
ResourceService,
|
|
72
|
+
ResourceScheduler,
|
|
73
|
+
BrandAccessGuard, // Scoped guard as provider
|
|
74
|
+
],
|
|
75
|
+
exports: [ResourceService], // Only export what other modules need
|
|
76
|
+
})
|
|
77
|
+
export class FeatureModule {}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Add a JSDoc block documenting the module's responsibilities:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
/**
|
|
84
|
+
* Feature Module
|
|
85
|
+
*
|
|
86
|
+
* Manages [resource] lifecycle including CRUD, [specific concern], and [other concern].
|
|
87
|
+
*
|
|
88
|
+
* Controllers:
|
|
89
|
+
* - AdminController: Brand admin CRUD operations
|
|
90
|
+
* - CreatorController: Creator-facing endpoints
|
|
91
|
+
*
|
|
92
|
+
* Services:
|
|
93
|
+
* - ResourceService: Core business logic (shared)
|
|
94
|
+
*/
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Index Exports
|
|
98
|
+
|
|
99
|
+
### Module index (`modules/[feature]/index.ts`)
|
|
100
|
+
|
|
101
|
+
Export only what downstream modules need:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
export { FeatureModule } from './feature.module';
|
|
105
|
+
export { FeatureService } from './shared/feature.service'; // If consumed by other modules
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Shared index (`shared/index.ts`)
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
export { ResourceService } from './resource.service';
|
|
112
|
+
export { ResourceScheduler } from './resource.scheduler';
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Service Placement Rules
|
|
116
|
+
|
|
117
|
+
- Service used by ONE portal → place next to that portal's controller
|
|
118
|
+
- Service used by BOTH portals → place in `shared/`
|
|
119
|
+
- Service used by OTHER modules → place in `shared/` and add to module `exports`
|
|
120
|
+
|
|
121
|
+
## DTO Placement Rules
|
|
122
|
+
|
|
123
|
+
- Admin-only DTOs → `admin/dto/`
|
|
124
|
+
- Creator-only DTOs → `creator/dto/`
|
|
125
|
+
- Shared DTOs (same shape used by both) → `shared/dto/`
|
|
126
|
+
- Response sub-types → `dto/responses/` subdirectory
|
|
127
|
+
|
|
128
|
+
## Hard Rules
|
|
129
|
+
|
|
130
|
+
- `admin/` and `creator/` must never import from each other
|
|
131
|
+
- Every `dto/` directory must have a barrel `index.ts`
|
|
132
|
+
- Guards used only within the module → register as providers in the module
|
|
133
|
+
- Guards used across modules → register in `common/guards/`
|
|
134
|
+
|
|
135
|
+
## Common Mistakes
|
|
136
|
+
|
|
137
|
+
- Exporting services that no other module needs (leaks internal implementation)
|
|
138
|
+
- Missing barrel exports causing relative import chains (`../../../shared/`)
|
|
139
|
+
- Placing admin-only services in `shared/` prematurely
|
|
140
|
+
- Circular imports between feature modules (use forwardRef or restructure)
|
|
141
|
+
- Forgetting to register `BrandAccessGuard` as a provider when using it
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths:
|
|
3
|
+
- 'apps/api/src/modules/**/*.service.ts'
|
|
4
|
+
- 'apps/api/src/modules/**/*.scheduler.ts'
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# NestJS Service Standards
|
|
8
|
+
|
|
9
|
+
Reference implementation: `apps/api/src/modules/initiatives/shared/initiatives.service.ts`
|
|
10
|
+
|
|
11
|
+
## Class Setup
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
@Injectable()
|
|
15
|
+
export class ResourceService {
|
|
16
|
+
private readonly logger = new Logger(ResourceService.name);
|
|
17
|
+
|
|
18
|
+
constructor(private readonly prisma: PrismaService) {}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- Every service must have a `Logger` with the class name
|
|
23
|
+
- Add `@consumers` JSDoc tag listing which controller(s) use it:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
/**
|
|
27
|
+
* @consumers ResourceController, ResourceCreatorController
|
|
28
|
+
*/
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Prisma Include/Select Constants
|
|
32
|
+
|
|
33
|
+
Define reusable include clauses at module scope:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
const RESOURCE_INCLUDE = {
|
|
37
|
+
relation: true,
|
|
38
|
+
nested: { include: { deepRelation: true } },
|
|
39
|
+
} satisfies Prisma.ResourceInclude; // satisfies (not as const) for type safety
|
|
40
|
+
|
|
41
|
+
type ResourceWithRelations = Prisma.ResourceGetPayload<{
|
|
42
|
+
include: typeof RESOURCE_INCLUDE;
|
|
43
|
+
}>;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For simple selects:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
const RESOURCE_SELECT = {
|
|
50
|
+
id: true,
|
|
51
|
+
name: true,
|
|
52
|
+
slug: true,
|
|
53
|
+
} satisfies Prisma.ResourceSelect;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Query Building
|
|
57
|
+
|
|
58
|
+
Optional filters with spread:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
const where: Prisma.ResourceWhereInput = {
|
|
62
|
+
brandId,
|
|
63
|
+
...(status && { status }),
|
|
64
|
+
...(type && { type }),
|
|
65
|
+
...(search && {
|
|
66
|
+
OR: [{ name: { contains: search, mode: 'insensitive' as const } }],
|
|
67
|
+
}),
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## List Methods (Pagination)
|
|
72
|
+
|
|
73
|
+
Always use `Promise.all` for parallel data + count:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
const [items, total] = await Promise.all([
|
|
77
|
+
this.prisma.resource.findMany({
|
|
78
|
+
where,
|
|
79
|
+
include: RESOURCE_INCLUDE,
|
|
80
|
+
orderBy: { [sortBy]: sortOrder },
|
|
81
|
+
skip: (page - 1) * limit,
|
|
82
|
+
take: limit,
|
|
83
|
+
}),
|
|
84
|
+
this.prisma.resource.count({ where }),
|
|
85
|
+
]);
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
data: items.map((i) => this.toResponse(i as ResourceWithRelations)),
|
|
89
|
+
total,
|
|
90
|
+
page,
|
|
91
|
+
limit,
|
|
92
|
+
totalPages: Math.ceil(total / limit),
|
|
93
|
+
};
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Transactions
|
|
97
|
+
|
|
98
|
+
Use for any operation touching multiple tables:
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
const result = await this.prisma.$transaction(async (tx) => {
|
|
102
|
+
const created = await tx.resource.create({ data: { ... } });
|
|
103
|
+
|
|
104
|
+
if (relatedItems?.length) {
|
|
105
|
+
await tx.relatedItem.createMany({
|
|
106
|
+
data: relatedItems.map((item) => ({ ...item, resourceId: created.id })),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Return full object with relations
|
|
111
|
+
return tx.resource.findUniqueOrThrow({
|
|
112
|
+
where: { id: created.id },
|
|
113
|
+
include: RESOURCE_INCLUDE,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
For array relation updates, delete + recreate inside transaction:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
await tx.resourceItem.deleteMany({ where: { resourceId: id } });
|
|
122
|
+
await tx.resourceItem.createMany({ data: newItems.map(...) });
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Validation
|
|
126
|
+
|
|
127
|
+
Sync validation first, then async:
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
// 1. Sync business rules
|
|
131
|
+
this.validateBusinessRules(dto);
|
|
132
|
+
|
|
133
|
+
// 2. Async checks (file ownership, uniqueness)
|
|
134
|
+
if (dto.fileId) {
|
|
135
|
+
await this.validateFileOwnership(dto.fileId, userId);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Use `Pick<>` for reusable validators:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
private validateOptions(
|
|
143
|
+
dto: Pick<CreateResourceDto, 'fieldA' | 'fieldB'>,
|
|
144
|
+
): void {
|
|
145
|
+
if (dto.fieldA && dto.fieldB) {
|
|
146
|
+
throw new BadRequestException('Only one of fieldA or fieldB allowed');
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
For partial updates, only validate fields being updated:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
if (dto.fieldA !== undefined || dto.fieldB !== undefined) {
|
|
155
|
+
this.validateOptions(dto);
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Response Transformation
|
|
160
|
+
|
|
161
|
+
Private `toResponse` method converts Prisma entities to response DTOs:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
private toResponse(entity: ResourceWithRelations): ResourceResponse {
|
|
165
|
+
return {
|
|
166
|
+
id: entity.id,
|
|
167
|
+
date: entity.date.toISOString().split('T')[0], // Date-only: YYYY-MM-DD
|
|
168
|
+
createdAt: entity.createdAt.toISOString(), // Datetime: full ISO
|
|
169
|
+
optionalField: entity.optionalField ?? undefined, // null → undefined
|
|
170
|
+
amount: entity.amount ? Number(entity.amount) : undefined, // Decimal → number
|
|
171
|
+
items: entity.items.map((i) => ({ id: i.id, name: i.name })),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
- Use `?? undefined` (not `|| undefined`) to clean nulls
|
|
177
|
+
- Date-only fields: `.toISOString().split('T')[0]`
|
|
178
|
+
- Prisma Decimal fields: `Number(entity.field)`
|
|
179
|
+
|
|
180
|
+
## Error Handling
|
|
181
|
+
|
|
182
|
+
| Exception | HTTP | When |
|
|
183
|
+
| --------------------- | ---- | ------------------------------------------- |
|
|
184
|
+
| `NotFoundException` | 404 | Resource not found |
|
|
185
|
+
| `BadRequestException` | 400 | Validation failure, business rule violation |
|
|
186
|
+
| `ConflictException` | 409 | Duplicate action, state conflict |
|
|
187
|
+
| `ForbiddenException` | 403 | Authorization beyond guard scope |
|
|
188
|
+
|
|
189
|
+
## Logging
|
|
190
|
+
|
|
191
|
+
Log every write operation with resource IDs:
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
this.logger.log(`Created resource ${resource.id} for brand ${brandId}`);
|
|
195
|
+
this.logger.log(`Updated resource ${id}`);
|
|
196
|
+
this.logger.error('Failed to process resource', error);
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Use conditional logging for batch results:
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
if (count > 0) {
|
|
203
|
+
this.logger.log(`Processed ${count} items`);
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Scheduler Pattern
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
@Cron(CronExpression.EVERY_DAY_AT_MIDNIGHT)
|
|
211
|
+
async handleExpiredItems(): Promise<void> {
|
|
212
|
+
this.logger.log('Running expired items check...');
|
|
213
|
+
try {
|
|
214
|
+
const count = await this.service.completeExpired();
|
|
215
|
+
this.logger.log(count > 0 ? `Completed ${count} item(s)` : 'No items found');
|
|
216
|
+
} catch (error) {
|
|
217
|
+
this.logger.error('Failed to process expired items', error);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Common Mistakes
|
|
223
|
+
|
|
224
|
+
- Missing `Logger` on service class
|
|
225
|
+
- Using `as const` instead of `satisfies Prisma.XInclude` (loses Prisma type checking)
|
|
226
|
+
- Sequential queries instead of `Promise.all` for independent data fetches
|
|
227
|
+
- Using `|| undefined` instead of `?? undefined` (breaks on `0` and `''`)
|
|
228
|
+
- Logging without resource IDs (impossible to trace)
|
|
229
|
+
- Missing transaction for multi-table writes (data inconsistency risk)
|
|
230
|
+
- Validating all fields on partial update instead of only provided ones
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
// This file is automatically generated by Nx Console
|
|
8
|
+
|
|
9
|
+
You are in an nx workspace using Nx 19.5.3 and pnpm as the package manager.
|
|
10
|
+
|
|
11
|
+
You have access to the Nx MCP server and the tools it provides. Use them. Follow these guidelines in order to best help the user:
|
|
12
|
+
|
|
13
|
+
# General Guidelines
|
|
14
|
+
- When answering questions, use the nx_workspace tool first to gain an understanding of the workspace architecture
|
|
15
|
+
- For questions around nx configuration, best practices or if you're unsure, use the nx_docs tool to get relevant, up-to-date docs!! Always use this instead of assuming things about nx configuration
|
|
16
|
+
- If the user needs help with an Nx configuration or project graph error, use the 'nx_workspace' tool to get any errors
|
|
17
|
+
- To help answer questions about the workspace structure or simply help with demonstrating how tasks depend on each other, use the 'nx_visualize_graph' tool
|
|
18
|
+
|
|
19
|
+
# Generation Guidelines
|
|
20
|
+
If the user wants to generate something, use the following flow:
|
|
21
|
+
|
|
22
|
+
- learn about the nx workspace and any specifics the user needs by using the 'nx_workspace' tool and the 'nx_project_details' tool if applicable
|
|
23
|
+
- get the available generators using the 'nx_generators' tool
|
|
24
|
+
- decide which generator to use. If no generators seem relevant, check the 'nx_available_plugins' tool to see if the user could install a plugin to help them
|
|
25
|
+
- get generator details using the 'nx_generator_schema' tool
|
|
26
|
+
- you may use the 'nx_docs' tool to learn more about a specific generator or technology if you're unsure
|
|
27
|
+
- decide which options to provide in order to best complete the user's request. Don't make any assumptions and keep the options minimalistic
|
|
28
|
+
- open the generator UI using the 'nx_open_generate_ui' tool
|
|
29
|
+
- wait for the user to finish the generator
|
|
30
|
+
- read the generator log file using the 'nx_read_generator_log' tool
|
|
31
|
+
- use the information provided in the log file to answer the user's question or continue with what they were doing
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# CI Error Guidelines
|
|
35
|
+
If the user wants help with fixing an error in their CI pipeline, use the following flow:
|
|
36
|
+
- Retrieve the list of current CI Pipeline Executions (CIPEs) using the 'nx_cloud_cipe_details' tool
|
|
37
|
+
- If there are any errors, use the 'nx_cloud_fix_cipe_failure' tool to retrieve the logs for a specific task
|
|
38
|
+
- Use the task logs to see what's wrong and help the user fix their problem. Use the appropriate tools if necessary
|
|
39
|
+
- Make sure that the problem is fixed by running the task that you passed into the 'nx_cloud_fix_cipe_failure' tool
|
|
40
|
+
|
|
41
|
+
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Padrões de nomenclatura, estrutura e convenções do Sistema Onion
|
|
3
|
+
globs: .claude/**
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
# 🧅 Padrões do Sistema Onion
|
|
7
|
+
|
|
8
|
+
## 🎯 Objetivo
|
|
9
|
+
|
|
10
|
+
Definir padrões consistentes para nomenclatura, estrutura e convenções do Sistema Onion v3.0.
|
|
11
|
+
|
|
12
|
+
## 📁 Estrutura de Diretórios
|
|
13
|
+
|
|
14
|
+
### Comandos (.claude/commands/)
|
|
15
|
+
```
|
|
16
|
+
.claude/commands/
|
|
17
|
+
├── engineer/ # Fluxos de desenvolvimento
|
|
18
|
+
├── product/ # Gestão de produto
|
|
19
|
+
├── git/ # Operações Git
|
|
20
|
+
│ ├── feature/ # Git flow - features
|
|
21
|
+
│ ├── hotfix/ # Git flow - hotfixes
|
|
22
|
+
│ └── release/ # Git flow - releases
|
|
23
|
+
├── docs/ # Documentação
|
|
24
|
+
├── meta/ # Meta-comandos (criadores)
|
|
25
|
+
├── validate/ # Validações
|
|
26
|
+
├── quick/ # Ações rápidas
|
|
27
|
+
└── common/ # Recursos compartilhados
|
|
28
|
+
├── templates/ # Templates base
|
|
29
|
+
└── prompts/ # Prompts modulares
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Agentes (.claude/agents/)
|
|
33
|
+
```
|
|
34
|
+
.claude/agents/
|
|
35
|
+
├── development/ # Dev: python, react, postgres
|
|
36
|
+
├── product/ # Produto: product-agent, task-specialist
|
|
37
|
+
├── compliance/ # Compliance: regulatory, security
|
|
38
|
+
├── meta/ # Meta: onion, metaspec-gate-keeper
|
|
39
|
+
├── review/ # Review: code-reviewer
|
|
40
|
+
├── testing/ # Testes: test-engineer, test-planner
|
|
41
|
+
├── research/ # Pesquisa: research-agent
|
|
42
|
+
├── git/ # Git: branch-*, code-review
|
|
43
|
+
└── common/ # Templates compartilhados
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Sessions (.claude/sessions/)
|
|
47
|
+
```
|
|
48
|
+
.claude/sessions/<feature-slug>/
|
|
49
|
+
├── context.md # Contexto e IDs ClickUp
|
|
50
|
+
├── architecture.md # Decisões arquiteturais
|
|
51
|
+
├── plan.md # Plano de fases
|
|
52
|
+
└── notes.md # Notas de desenvolvimento
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## 📝 Nomenclatura
|
|
56
|
+
|
|
57
|
+
### Feature Slugs
|
|
58
|
+
```bash
|
|
59
|
+
# Padrão: kebab-case descritivo
|
|
60
|
+
✅ user-authentication
|
|
61
|
+
✅ payment-integration
|
|
62
|
+
✅ onion-v3-refactoring
|
|
63
|
+
|
|
64
|
+
❌ UserAuth
|
|
65
|
+
❌ payment_integration
|
|
66
|
+
❌ feature123
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Task IDs (ClickUp)
|
|
70
|
+
```bash
|
|
71
|
+
# Formato: alfanumérico ClickUp
|
|
72
|
+
✅ 86adf8jj6
|
|
73
|
+
✅ 86adf8kr3
|
|
74
|
+
|
|
75
|
+
# Referência em documentos:
|
|
76
|
+
**Task ID**: 86adf8jj6
|
|
77
|
+
**Subtask ID**: `86adf8kr3`
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Comandos
|
|
81
|
+
```bash
|
|
82
|
+
# Nome: kebab-case
|
|
83
|
+
✅ create-agent
|
|
84
|
+
✅ code-review
|
|
85
|
+
✅ warm-up
|
|
86
|
+
|
|
87
|
+
# Caminho: /categoria/nome
|
|
88
|
+
✅ /engineer/start
|
|
89
|
+
✅ /product/task
|
|
90
|
+
✅ /git/feature/start
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Agentes
|
|
94
|
+
```bash
|
|
95
|
+
# Nome: kebab-case + sufixo descritivo
|
|
96
|
+
✅ python-developer.md
|
|
97
|
+
✅ task-specialist.md
|
|
98
|
+
✅ code-reviewer.md
|
|
99
|
+
|
|
100
|
+
# Referência: @nome (sem extensão)
|
|
101
|
+
✅ @python-developer
|
|
102
|
+
✅ @onion
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## 📋 Estrutura de Arquivos
|
|
106
|
+
|
|
107
|
+
### Comando (YAML Header Obrigatório)
|
|
108
|
+
```yaml
|
|
109
|
+
---
|
|
110
|
+
name: nome-comando
|
|
111
|
+
description: Descrição curta (1-2 linhas)
|
|
112
|
+
model: sonnet
|
|
113
|
+
category: engineer|product|git|docs|meta|validate|quick
|
|
114
|
+
tags: [tag1, tag2]
|
|
115
|
+
version: "3.0.0"
|
|
116
|
+
updated: "YYYY-MM-DD"
|
|
117
|
+
---
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Agente (YAML Header Obrigatório)
|
|
121
|
+
```yaml
|
|
122
|
+
---
|
|
123
|
+
name: nome-agente
|
|
124
|
+
description: Descrição da especialização
|
|
125
|
+
model: sonnet
|
|
126
|
+
category: development|product|meta|compliance|review|testing|research|git
|
|
127
|
+
tags: [tag1, tag2]
|
|
128
|
+
expertise: [area1, area2, area3]
|
|
129
|
+
version: "3.0.0"
|
|
130
|
+
updated: "YYYY-MM-DD"
|
|
131
|
+
---
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## 🔗 Integração ClickUp MCP
|
|
135
|
+
|
|
136
|
+
### Identificação de Workspace
|
|
137
|
+
```typescript
|
|
138
|
+
// Sempre usar workspace_id explícito
|
|
139
|
+
workspace_id: "90131664218" // Workspace padrão
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Padrões de Comentários
|
|
143
|
+
- **Subtask**: Comentário DETALHADO (métricas, arquivos, decisões)
|
|
144
|
+
- **Task Principal**: Comentário RESUMIDO (fase, status, próximo)
|
|
145
|
+
|
|
146
|
+
### Formatação de Comentários
|
|
147
|
+
```
|
|
148
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
149
|
+
✅ FASE N CONCLUÍDA - Nome da Fase
|
|
150
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
151
|
+
📅 YYYY-MM-DD | Status: DONE
|
|
152
|
+
|
|
153
|
+
📊 **Resultados:**
|
|
154
|
+
∟ Item 1: valor
|
|
155
|
+
∟ Item 2: valor
|
|
156
|
+
|
|
157
|
+
🚀 Próxima: Fase N+1 - Nome
|
|
158
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## ⚡ Limites e Métricas
|
|
162
|
+
|
|
163
|
+
| Métrica | Limite | Razão |
|
|
164
|
+
|---------|--------|-------|
|
|
165
|
+
| Linhas por comando | < 400 | Otimização de tokens |
|
|
166
|
+
| Linhas por agente | < 300 | Foco e clareza |
|
|
167
|
+
| Expertise por agente | 3-5 | Especialização |
|
|
168
|
+
| Tags por arquivo | 3-7 | Organização |
|
|
169
|
+
|
|
170
|
+
## 🔄 Fluxos Principais
|
|
171
|
+
|
|
172
|
+
### Feature Development
|
|
173
|
+
```bash
|
|
174
|
+
/product/task "descrição" # Criar task ClickUp
|
|
175
|
+
/engineer/start <slug> # Iniciar sessão
|
|
176
|
+
/engineer/work # Continuar trabalho
|
|
177
|
+
/engineer/pre-pr # Preparar PR
|
|
178
|
+
/engineer/pr # Criar PR
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Criação de Componentes
|
|
182
|
+
```bash
|
|
183
|
+
/meta/create-agent <nome> # Criar agente
|
|
184
|
+
/meta/create-command <nome> # Criar comando
|
|
185
|
+
/docs/build-tech-docs # Documentar
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## 📚 Referências
|
|
189
|
+
|
|
190
|
+
- Knowledge Bases: `docs/knowbase/`
|
|
191
|
+
- Templates: `.claude/commands/common/templates/`
|
|
192
|
+
- Prompts: `.claude/commands/common/prompts/`
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
**Última atualização:** 2025-11-24
|
|
197
|
+
**Versão:** 3.0.0
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codebase-visualizer
|
|
3
|
+
description: Generate an interactive collapsible tree visualization of your codebase. Use when exploring a new repo, understanding project structure, or identifying large files.
|
|
4
|
+
allowed-tools: Bash(python *)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Codebase Visualizer
|
|
8
|
+
|
|
9
|
+
Generate an interactive HTML tree view that shows your project's file structure with collapsible directories.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Run the visualization script from your project root:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
python3 .claude/skills/codebase-visualizer/scripts/visualize.py .
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This creates `codebase-map.html` in the current directory and opens it in your default browser.
|
|
20
|
+
|
|
21
|
+
## What the visualization shows
|
|
22
|
+
|
|
23
|
+
- **Collapsible directories**: Click folders to expand/collapse
|
|
24
|
+
- **File sizes**: Displayed next to each file
|
|
25
|
+
- **Colors**: Different colors for different file types
|
|
26
|
+
- **Directory totals**: Shows aggregate size of each folder
|