@mind-fold/open-flow 0.1.9 → 0.1.11
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/README.md +1 -0
- package/dist/configurators/templates.d.ts.map +1 -1
- package/dist/configurators/templates.js +14 -837
- package/dist/configurators/templates.js.map +1 -1
- package/dist/configurators/workflow.d.ts.map +1 -1
- package/dist/configurators/workflow.js +24 -1547
- package/dist/configurators/workflow.js.map +1 -1
- package/dist/templates/commands/before-backend-dev.txt +10 -0
- package/dist/templates/commands/before-frontend-dev.txt +10 -0
- package/dist/templates/commands/check-backend.txt +9 -0
- package/dist/templates/commands/check-frontend.txt +9 -0
- package/dist/templates/commands/create-command.txt +155 -0
- package/dist/templates/commands/generate-backend-structure.txt +341 -0
- package/dist/templates/commands/generate-frontend-structure.txt +297 -0
- package/dist/templates/commands/index.d.ts +18 -0
- package/dist/templates/commands/index.d.ts.map +1 -0
- package/dist/templates/commands/index.js +19 -0
- package/dist/templates/commands/index.js.map +1 -0
- package/dist/templates/commands/init-agent.txt +11 -0
- package/dist/templates/commands/onboard-developer.txt +34 -0
- package/dist/templates/commands/record-agent-flow.txt +64 -0
- package/dist/templates/commands/record-question.txt +38 -0
- package/dist/templates/commands/update-backend-structure.txt +16 -0
- package/dist/templates/commands/update-frontend-structure.txt +16 -0
- package/dist/templates/extract.d.ts +20 -0
- package/dist/templates/extract.d.ts.map +1 -0
- package/dist/templates/extract.js +34 -0
- package/dist/templates/extract.js.map +1 -0
- package/dist/templates/markdown/agent-progress-index.d.ts +2 -0
- package/dist/templates/markdown/agent-progress-index.d.ts.map +1 -0
- package/dist/templates/markdown/agent-progress-index.js +5 -0
- package/dist/templates/markdown/agent-progress-index.js.map +1 -0
- package/dist/templates/markdown/agent-progress-index.md.txt +124 -0
- package/dist/templates/markdown/backend-doc.d.ts +2 -0
- package/dist/templates/markdown/backend-doc.d.ts.map +1 -0
- package/dist/templates/markdown/backend-doc.js +5 -0
- package/dist/templates/markdown/backend-doc.js.map +1 -0
- package/dist/templates/markdown/backend-doc.md.txt +154 -0
- package/dist/templates/markdown/backend-index.d.ts +2 -0
- package/dist/templates/markdown/backend-index.d.ts.map +1 -0
- package/dist/templates/markdown/backend-index.js +5 -0
- package/dist/templates/markdown/backend-index.js.map +1 -0
- package/dist/templates/markdown/backend-index.md.txt +45 -0
- package/dist/templates/markdown/flow.d.ts +2 -0
- package/dist/templates/markdown/flow.d.ts.map +1 -0
- package/dist/templates/markdown/flow.js +5 -0
- package/dist/templates/markdown/flow.js.map +1 -0
- package/dist/templates/markdown/flow.md.txt +342 -0
- package/dist/templates/markdown/frontend-doc.d.ts +2 -0
- package/dist/templates/markdown/frontend-doc.d.ts.map +1 -0
- package/dist/templates/markdown/frontend-doc.js +5 -0
- package/dist/templates/markdown/frontend-doc.js.map +1 -0
- package/dist/templates/markdown/frontend-doc.md.txt +175 -0
- package/dist/templates/markdown/frontend-index.d.ts +2 -0
- package/dist/templates/markdown/frontend-index.d.ts.map +1 -0
- package/dist/templates/markdown/frontend-index.js +5 -0
- package/dist/templates/markdown/frontend-index.js.map +1 -0
- package/dist/templates/markdown/frontend-index.md.txt +46 -0
- package/dist/templates/markdown/gitignore.d.ts +2 -0
- package/dist/templates/markdown/gitignore.d.ts.map +1 -0
- package/dist/templates/markdown/gitignore.js +5 -0
- package/dist/templates/markdown/gitignore.js.map +1 -0
- package/dist/templates/markdown/gitignore.txt +3 -0
- package/dist/templates/markdown/index.d.ts +12 -0
- package/dist/templates/markdown/index.d.ts.map +1 -0
- package/dist/templates/markdown/index.js +13 -0
- package/dist/templates/markdown/index.js.map +1 -0
- package/dist/templates/scripts/add-session.d.ts +2 -0
- package/dist/templates/scripts/add-session.d.ts.map +1 -0
- package/dist/templates/scripts/add-session.js +5 -0
- package/dist/templates/scripts/add-session.js.map +1 -0
- package/dist/templates/scripts/add-session.sh.txt +257 -0
- package/dist/templates/scripts/extract-md-headings.d.ts +2 -0
- package/dist/templates/scripts/extract-md-headings.d.ts.map +1 -0
- package/dist/templates/scripts/extract-md-headings.js +5 -0
- package/dist/templates/scripts/extract-md-headings.js.map +1 -0
- package/dist/templates/scripts/extract-md-headings.sh.txt +260 -0
- package/dist/templates/scripts/feature.d.ts +2 -0
- package/dist/templates/scripts/feature.d.ts.map +1 -0
- package/dist/templates/scripts/feature.js +5 -0
- package/dist/templates/scripts/feature.js.map +1 -0
- package/dist/templates/scripts/feature.sh.txt +243 -0
- package/dist/templates/scripts/get-context.d.ts +2 -0
- package/dist/templates/scripts/get-context.d.ts.map +1 -0
- package/dist/templates/scripts/get-context.js +5 -0
- package/dist/templates/scripts/get-context.js.map +1 -0
- package/dist/templates/scripts/get-context.sh.txt +243 -0
- package/dist/templates/scripts/get-developer.d.ts +2 -0
- package/dist/templates/scripts/get-developer.d.ts.map +1 -0
- package/dist/templates/scripts/get-developer.js +5 -0
- package/dist/templates/scripts/get-developer.js.map +1 -0
- package/dist/templates/scripts/get-developer.sh.txt +16 -0
- package/dist/templates/scripts/index.d.ts +12 -0
- package/dist/templates/scripts/index.d.ts.map +1 -0
- package/dist/templates/scripts/index.js +13 -0
- package/dist/templates/scripts/index.js.map +1 -0
- package/dist/templates/scripts/init-developer.d.ts +2 -0
- package/dist/templates/scripts/init-developer.d.ts.map +1 -0
- package/dist/templates/scripts/init-developer.js +5 -0
- package/dist/templates/scripts/init-developer.js.map +1 -0
- package/dist/templates/scripts/init-developer.sh.txt +114 -0
- package/dist/templates/scripts/update-index.d.ts +2 -0
- package/dist/templates/scripts/update-index.d.ts.map +1 -0
- package/dist/templates/scripts/update-index.js +5 -0
- package/dist/templates/scripts/update-index.js.map +1 -0
- package/dist/templates/scripts/update-index.sh.txt +244 -0
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/configurators/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAA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,CAAC,SAAS,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;AACF,CAAC;AAED,KAAK,UAAU,wBAAwB,CAAC,GAAW;IAClD,EAAE,CAAC,aAAa,CACf,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,kCAAkC,CAAC,EAClD,yBAAyB,CACzB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,wBAAwB,CAAC,GAAW;IAClD,EAAE,CAAC,aAAa,CACf,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,sCAAsC,CAAC,EACtD,oBAAoB,CACpB,CAAC;IACF,EAAE,CAAC,aAAa,CACf,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oCAAoC,CAAC,EACpD,kBAAkB,CAClB,CAAC;IACF,EAAE,CAAC,aAAa,CACf,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,qCAAqC,CAAC,EACrD,mBAAmB,CACnB,CAAC;IACF,EAAE,CAAC,aAAa,CACf,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,mCAAmC,CAAC,EACnD,iBAAiB,CACjB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,GAAW;IACtC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,kBAAkB,CAAC,EAAE,aAAa,CAAC,CAAC;AACrE,CAAC;AAED,KAAK,UAAU,uBAAuB,CAAC,GAAW;IACjD,EAAE,CAAC,aAAa,CACf,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,qBAAqB,CAAC,EACrC,wBAAwB,CACxB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Read the backend development guidelines before starting your development task.
|
|
2
|
+
|
|
3
|
+
Execute these steps:
|
|
4
|
+
1. Read `workflow/structure/backend/index.md` to find relevant section IDs for your task
|
|
5
|
+
2. Extract specific sections: `sed -n '/@@@section:ID/,/@@@\/section:ID/p' workflow/structure/backend/doc.md`
|
|
6
|
+
3. Understand the coding standards and patterns you need to follow
|
|
7
|
+
4. Then proceed with your development plan
|
|
8
|
+
|
|
9
|
+
This step is **mandatory** before writing any backend code.
|
|
10
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Read the frontend development guidelines before starting your development task.
|
|
2
|
+
|
|
3
|
+
Execute these steps:
|
|
4
|
+
1. Read `workflow/structure/frontend/index.md` to find relevant section IDs for your task
|
|
5
|
+
2. Extract specific sections: `sed -n '/@@@section:ID/,/@@@\/section:ID/p' workflow/structure/frontend/doc.md`
|
|
6
|
+
3. Understand the coding standards and patterns you need to follow
|
|
7
|
+
4. Then proceed with your development plan
|
|
8
|
+
|
|
9
|
+
This step is **mandatory** before writing any frontend code.
|
|
10
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Check if the code you just wrote follows the backend development guidelines.
|
|
2
|
+
|
|
3
|
+
Execute these steps:
|
|
4
|
+
1. Run `git status` to see modified files
|
|
5
|
+
2. Read `workflow/structure/backend/index.md` to find relevant section IDs
|
|
6
|
+
3. Extract specific sections: `sed -n '/@@@section:ID/,/@@@\/section:ID/p' workflow/structure/backend/doc.md`
|
|
7
|
+
4. Review your code against the guidelines
|
|
8
|
+
5. Report any violations and fix them if found
|
|
9
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Check if the code you just wrote follows the frontend development guidelines.
|
|
2
|
+
|
|
3
|
+
Execute these steps:
|
|
4
|
+
1. Run `git status` to see modified files
|
|
5
|
+
2. Read `workflow/structure/frontend/index.md` to find relevant section IDs
|
|
6
|
+
3. Extract specific sections: `sed -n '/@@@section:ID/,/@@@\/section:ID/p' workflow/structure/frontend/doc.md`
|
|
7
|
+
4. Review your code against the guidelines
|
|
8
|
+
5. Report any violations and fix them if found
|
|
9
|
+
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Create New Slash Command
|
|
2
|
+
|
|
3
|
+
Create a new slash command in both `.cursor/commands/` and `.claude/commands/` directories based on user requirements.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
/create-command <command-name> <description>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Example**:
|
|
12
|
+
```
|
|
13
|
+
/create-command review-pr Check PR code changes against project guidelines
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Execution Steps
|
|
17
|
+
|
|
18
|
+
### 1. Parse Input
|
|
19
|
+
|
|
20
|
+
Extract from user input:
|
|
21
|
+
- **Command name**: Use kebab-case (e.g., `review-pr`)
|
|
22
|
+
- **Description**: What the command should accomplish
|
|
23
|
+
|
|
24
|
+
### 2. Analyze Requirements
|
|
25
|
+
|
|
26
|
+
Determine command type based on description:
|
|
27
|
+
- **Initialization**: Read docs, establish context
|
|
28
|
+
- **Pre-development**: Read guidelines, check dependencies
|
|
29
|
+
- **Code check**: Validate code quality and guideline compliance
|
|
30
|
+
- **Recording**: Record progress, questions, structure changes
|
|
31
|
+
- **Generation**: Generate docs, code templates
|
|
32
|
+
|
|
33
|
+
### 3. Generate Command Content
|
|
34
|
+
|
|
35
|
+
Based on command type, generate appropriate content:
|
|
36
|
+
|
|
37
|
+
**Simple command** (1-3 lines):
|
|
38
|
+
```markdown
|
|
39
|
+
Concise instruction describing what to do
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Complex command** (with steps):
|
|
43
|
+
```markdown
|
|
44
|
+
# Command Title
|
|
45
|
+
|
|
46
|
+
Command description
|
|
47
|
+
|
|
48
|
+
## Steps
|
|
49
|
+
|
|
50
|
+
### 1. First Step
|
|
51
|
+
Specific action
|
|
52
|
+
|
|
53
|
+
### 2. Second Step
|
|
54
|
+
Specific action
|
|
55
|
+
|
|
56
|
+
## Output Format (if needed)
|
|
57
|
+
|
|
58
|
+
Template
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 4. Create Files
|
|
62
|
+
|
|
63
|
+
Create in both directories:
|
|
64
|
+
- `.cursor/commands/<command-name>.md`
|
|
65
|
+
- `.claude/commands/<command-name>.md`
|
|
66
|
+
|
|
67
|
+
### 5. Confirm Creation
|
|
68
|
+
|
|
69
|
+
Output result:
|
|
70
|
+
```
|
|
71
|
+
✅ Created Slash Command: /<command-name>
|
|
72
|
+
|
|
73
|
+
File paths:
|
|
74
|
+
- .cursor/commands/<command-name>.md
|
|
75
|
+
- .claude/commands/<command-name>.md
|
|
76
|
+
|
|
77
|
+
Usage:
|
|
78
|
+
/<command-name>
|
|
79
|
+
|
|
80
|
+
Description:
|
|
81
|
+
<description>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Command Content Guidelines
|
|
85
|
+
|
|
86
|
+
### ✅ Good command content
|
|
87
|
+
|
|
88
|
+
1. **Clear and concise**: Immediately understandable
|
|
89
|
+
2. **Executable**: AI can follow steps directly
|
|
90
|
+
3. **Well-scoped**: Clear boundaries of what to do and not do
|
|
91
|
+
4. **Has output**: Specifies expected output format (if needed)
|
|
92
|
+
|
|
93
|
+
### ❌ Avoid
|
|
94
|
+
|
|
95
|
+
1. **Too vague**: e.g., "optimize code"
|
|
96
|
+
2. **Too complex**: Single command should not exceed 100 lines
|
|
97
|
+
3. **Duplicate functionality**: Check if similar command exists first
|
|
98
|
+
|
|
99
|
+
## Naming Conventions
|
|
100
|
+
|
|
101
|
+
| Command Type | Prefix | Example |
|
|
102
|
+
|--------------|--------|---------|
|
|
103
|
+
| Initialization | `init-` | `init-agent` |
|
|
104
|
+
| Pre-development | `before-` | `before-frontend-dev` |
|
|
105
|
+
| Check | `check-` | `check-frontend` |
|
|
106
|
+
| Record | `record-` | `record-agent-flow` |
|
|
107
|
+
| Generate | `generate-` | `generate-api-doc` |
|
|
108
|
+
| Update | `update-` | `update-changelog` |
|
|
109
|
+
| Other | Verb-first | `review-code`, `sync-data` |
|
|
110
|
+
|
|
111
|
+
## Example
|
|
112
|
+
|
|
113
|
+
### Input
|
|
114
|
+
```
|
|
115
|
+
/create-command review-pr Check PR code changes against project guidelines
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Generated Command Content
|
|
119
|
+
```markdown
|
|
120
|
+
# PR Code Review
|
|
121
|
+
|
|
122
|
+
Check current PR code changes against project guidelines.
|
|
123
|
+
|
|
124
|
+
## Steps
|
|
125
|
+
|
|
126
|
+
### 1. Get Changed Files
|
|
127
|
+
```bash
|
|
128
|
+
git diff main...HEAD --name-only
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 2. Categorized Review
|
|
132
|
+
|
|
133
|
+
**Frontend files** (`apps/web/`):
|
|
134
|
+
- Reference `workflow/structure/frontend/index.md`
|
|
135
|
+
|
|
136
|
+
**Backend files** (`packages/api/`):
|
|
137
|
+
- Reference `workflow/structure/backend/index.md`
|
|
138
|
+
|
|
139
|
+
### 3. Output Review Report
|
|
140
|
+
|
|
141
|
+
Format:
|
|
142
|
+
|
|
143
|
+
## PR Review Report
|
|
144
|
+
|
|
145
|
+
### Changed Files
|
|
146
|
+
- [file list]
|
|
147
|
+
|
|
148
|
+
### Check Results
|
|
149
|
+
- ✅ Passed items
|
|
150
|
+
- ❌ Issues found
|
|
151
|
+
|
|
152
|
+
### Suggestions
|
|
153
|
+
- [improvement suggestions]
|
|
154
|
+
```
|
|
155
|
+
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# Generate Backend Structure Guidelines
|
|
2
|
+
|
|
3
|
+
## Task Description
|
|
4
|
+
|
|
5
|
+
Scan the project's backend code, analyze existing code patterns and tech stack, then auto-generate `doc.md` (detailed guidelines) with section markers, then generate `index.md` (navigation index) using section IDs.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ⚠️ CRITICAL: Requirements
|
|
10
|
+
|
|
11
|
+
1. **Language**: All documentation must be written in **English**
|
|
12
|
+
2. **Section Markers**: Use `@@@section:kebab-case-id` and `@@@/section:kebab-case-id` to mark sections
|
|
13
|
+
3. **Index**: Reference sections by ID, not line numbers
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Execution Steps
|
|
18
|
+
|
|
19
|
+
### Step 1: Identify Backend Directory
|
|
20
|
+
|
|
21
|
+
Scan these possible backend directories to determine the main backend code location:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Common backend directories
|
|
25
|
+
ls -la packages/api/ 2>/dev/null || \
|
|
26
|
+
ls -la apps/api/ 2>/dev/null || \
|
|
27
|
+
ls -la server/ 2>/dev/null || \
|
|
28
|
+
ls -la backend/ 2>/dev/null || \
|
|
29
|
+
ls -la src/api/ 2>/dev/null || \
|
|
30
|
+
ls -la api/ 2>/dev/null
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Step 2: Identify Tech Stack
|
|
34
|
+
|
|
35
|
+
Analyze `package.json` and code files to identify:
|
|
36
|
+
|
|
37
|
+
**Frameworks and Libraries**:
|
|
38
|
+
- [ ] Runtime: Node.js / Bun / Deno
|
|
39
|
+
- [ ] Framework: Express / Fastify / Hono / Nest.js / Next.js API
|
|
40
|
+
- [ ] ORM: Drizzle / Prisma / TypeORM / Sequelize / Knex
|
|
41
|
+
- [ ] Database: PostgreSQL / MySQL / MongoDB / SQLite
|
|
42
|
+
- [ ] Validation: Zod / Yup / Joi / class-validator
|
|
43
|
+
- [ ] API Style: REST / GraphQL / tRPC / oRPC / gRPC
|
|
44
|
+
- [ ] Authentication: better-auth / next-auth / passport / jwt
|
|
45
|
+
|
|
46
|
+
**Toolchain**:
|
|
47
|
+
- [ ] Types: TypeScript / JavaScript
|
|
48
|
+
- [ ] Linter: Biome / ESLint
|
|
49
|
+
- [ ] Testing: Vitest / Jest / Mocha
|
|
50
|
+
|
|
51
|
+
### Step 3: Analyze Code Patterns
|
|
52
|
+
|
|
53
|
+
Scan backend code to extract the following patterns:
|
|
54
|
+
|
|
55
|
+
**Directory Structure**:
|
|
56
|
+
```bash
|
|
57
|
+
# List main directory structure
|
|
58
|
+
find [backend-dir] -type d -maxdepth 3 | head -50
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Module Organization Patterns**:
|
|
62
|
+
- Module division style (by feature / by layer)
|
|
63
|
+
- File naming conventions
|
|
64
|
+
- Export patterns
|
|
65
|
+
|
|
66
|
+
**Type Definition Patterns**:
|
|
67
|
+
- Zod Schema organization
|
|
68
|
+
- Type export standards
|
|
69
|
+
- Input/Output type definitions
|
|
70
|
+
|
|
71
|
+
**Router/Endpoint Patterns**:
|
|
72
|
+
- Route organization
|
|
73
|
+
- Middleware usage
|
|
74
|
+
- Parameter validation approach
|
|
75
|
+
|
|
76
|
+
**Database Operation Patterns**:
|
|
77
|
+
- Query function organization
|
|
78
|
+
- Transaction handling
|
|
79
|
+
- Batch operation patterns
|
|
80
|
+
|
|
81
|
+
**Error Handling Patterns**:
|
|
82
|
+
- Error type definitions
|
|
83
|
+
- Exception catching approach
|
|
84
|
+
- Response format standards
|
|
85
|
+
|
|
86
|
+
**Logging Patterns**:
|
|
87
|
+
- Logging tool
|
|
88
|
+
- Log level usage
|
|
89
|
+
- Structured log format
|
|
90
|
+
|
|
91
|
+
### Step 4: Generate `doc.md` with Section Markers
|
|
92
|
+
|
|
93
|
+
Create directory and generate detailed guidelines:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
mkdir -p workflow/structure/backend
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**doc.md template** (adjust based on project):
|
|
100
|
+
|
|
101
|
+
```markdown
|
|
102
|
+
# Backend Development Guidelines
|
|
103
|
+
|
|
104
|
+
These guidelines define the development standards and best practices for [Project Name] backend modules.
|
|
105
|
+
|
|
106
|
+
@@@section:directory-structure
|
|
107
|
+
## 📁 Directory Structure Guidelines
|
|
108
|
+
|
|
109
|
+
### Module Organization
|
|
110
|
+
[describe directory structure]
|
|
111
|
+
|
|
112
|
+
@@@/section:directory-structure
|
|
113
|
+
|
|
114
|
+
@@@section:type-safety
|
|
115
|
+
## 🎯 Type Safety Guidelines
|
|
116
|
+
|
|
117
|
+
@@@section:non-null-assertion
|
|
118
|
+
### 1. TypeScript Non-null Assertion Rules
|
|
119
|
+
|
|
120
|
+
**Never use non-null assertion operator (`!`), use local variable extraction instead**
|
|
121
|
+
|
|
122
|
+
#### ❌ Wrong Approach
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
if (user.profileId) {
|
|
126
|
+
await db.update(profiles)
|
|
127
|
+
.set({ name: newName })
|
|
128
|
+
.where(eq(profiles.id, user.profileId!)); // ❌ non-null assertion
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### ✅ Correct Approach
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
if (user.profileId) {
|
|
136
|
+
const profileId = user.profileId; // type narrowed to string
|
|
137
|
+
await db.update(profiles)
|
|
138
|
+
.set({ name: newName })
|
|
139
|
+
.where(eq(profiles.id, profileId)); // ✅ type safe
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
@@@/section:non-null-assertion
|
|
144
|
+
|
|
145
|
+
@@@section:zod-schema
|
|
146
|
+
### 2. Zod Schema Definition
|
|
147
|
+
|
|
148
|
+
**All API endpoints must use Zod to define input/output schemas**
|
|
149
|
+
|
|
150
|
+
@@@/section:zod-schema
|
|
151
|
+
|
|
152
|
+
@@@section:response-format
|
|
153
|
+
### 3. Response Format Standards
|
|
154
|
+
|
|
155
|
+
#### Single Operation Response
|
|
156
|
+
```typescript
|
|
157
|
+
{
|
|
158
|
+
success: boolean, // operation result
|
|
159
|
+
reason?: string, // success message or failure reason
|
|
160
|
+
error?: string, // detailed error info
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
#### Batch Operation Response
|
|
165
|
+
```typescript
|
|
166
|
+
{
|
|
167
|
+
success: boolean, // overall result
|
|
168
|
+
total: number, // total processed
|
|
169
|
+
processed: number, // succeeded count
|
|
170
|
+
failed: number, // failed count
|
|
171
|
+
errors?: Array<{id: string, error: string}>
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
@@@/section:response-format
|
|
176
|
+
|
|
177
|
+
@@@/section:type-safety
|
|
178
|
+
|
|
179
|
+
@@@section:logging
|
|
180
|
+
## 🪵 Logging Guidelines
|
|
181
|
+
|
|
182
|
+
### Use Structured Logging
|
|
183
|
+
|
|
184
|
+
**Never use `console.log` or `console.error`**
|
|
185
|
+
|
|
186
|
+
[code examples]
|
|
187
|
+
|
|
188
|
+
@@@/section:logging
|
|
189
|
+
|
|
190
|
+
@@@section:database-operations
|
|
191
|
+
## 🗄️ Database Operation Guidelines
|
|
192
|
+
|
|
193
|
+
@@@section:no-loops
|
|
194
|
+
### 🚨 Never Execute Database Operations in Loops
|
|
195
|
+
|
|
196
|
+
[anti-pattern and correct pattern examples]
|
|
197
|
+
|
|
198
|
+
@@@/section:no-loops
|
|
199
|
+
|
|
200
|
+
### Batch Insert
|
|
201
|
+
[code example]
|
|
202
|
+
|
|
203
|
+
### Conflict Handling
|
|
204
|
+
[code example with onConflictDoUpdate]
|
|
205
|
+
|
|
206
|
+
@@@/section:database-operations
|
|
207
|
+
|
|
208
|
+
@@@section:error-handling
|
|
209
|
+
## 🎨 Error Handling
|
|
210
|
+
|
|
211
|
+
### Graceful Degradation
|
|
212
|
+
[code example]
|
|
213
|
+
|
|
214
|
+
### Promise.allSettled
|
|
215
|
+
[code example for batch operations]
|
|
216
|
+
|
|
217
|
+
@@@/section:error-handling
|
|
218
|
+
|
|
219
|
+
@@@section:router-guidelines
|
|
220
|
+
## 🎯 Router Guidelines
|
|
221
|
+
|
|
222
|
+
### Hono Router Example
|
|
223
|
+
[code example]
|
|
224
|
+
|
|
225
|
+
### oRPC Router Example
|
|
226
|
+
[code example]
|
|
227
|
+
|
|
228
|
+
@@@/section:router-guidelines
|
|
229
|
+
|
|
230
|
+
@@@section:checklist
|
|
231
|
+
## ✅ Checklist
|
|
232
|
+
|
|
233
|
+
Before committing, confirm:
|
|
234
|
+
|
|
235
|
+
- [ ] All API inputs use Zod Schema validation
|
|
236
|
+
- [ ] All API outputs have clear type definitions
|
|
237
|
+
- [ ] Response format includes `success` and `reason` fields
|
|
238
|
+
- [ ] Database operations not executed in loops
|
|
239
|
+
- [ ] Batch operations use `Promise.allSettled`
|
|
240
|
+
- [ ] Use `logger` instead of `console`
|
|
241
|
+
- [ ] No non-null assertions `!`
|
|
242
|
+
- [ ] Error handling returns degraded result instead of throwing
|
|
243
|
+
- [ ] `pnpm lint` passes
|
|
244
|
+
- [ ] `pnpm type-check` passes
|
|
245
|
+
|
|
246
|
+
@@@/section:checklist
|
|
247
|
+
|
|
248
|
+
@@@section:reference-examples
|
|
249
|
+
## 📚 Reference Examples
|
|
250
|
+
|
|
251
|
+
| Feature | Reference File |
|
|
252
|
+
|---------|----------------|
|
|
253
|
+
| [Feature1] | `[path]` |
|
|
254
|
+
|
|
255
|
+
@@@/section:reference-examples
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Step 5: Generate `index.md` with Section IDs
|
|
259
|
+
|
|
260
|
+
```markdown
|
|
261
|
+
# Backend Development Guidelines Index
|
|
262
|
+
|
|
263
|
+
> **Full Documentation**: See `./doc.md` for detailed guidelines
|
|
264
|
+
|
|
265
|
+
This index helps you quickly locate the sections needed for backend tasks.
|
|
266
|
+
|
|
267
|
+
## Quick Navigation
|
|
268
|
+
|
|
269
|
+
| Section | Key Content | Section ID |
|
|
270
|
+
|---------|-------------|------------|
|
|
271
|
+
| 📁 Directory Structure | Module directory template, examples | `directory-structure` |
|
|
272
|
+
| 🎯 Type Safety Guidelines | TypeScript rules, Zod Schema | `type-safety` |
|
|
273
|
+
| 🪵 Logging Guidelines | Structured logging, no console | `logging` |
|
|
274
|
+
| 🗄️ Database Operations | Query directory, batch operations | `database-operations` |
|
|
275
|
+
| 🎨 Error Handling | Graceful degradation, response format | `error-handling` |
|
|
276
|
+
| 🎯 Router Guidelines | Route definitions, middleware | `router-guidelines` |
|
|
277
|
+
| ✅ Checklist | Pre-commit checks | `checklist` |
|
|
278
|
+
|
|
279
|
+
## How to Read Sections
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
# Extract a specific section by ID
|
|
283
|
+
sed -n '/@@@section:database-operations/,/@@@\/section:database-operations/p' doc.md
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## By Scenario
|
|
287
|
+
|
|
288
|
+
### Scenario 1: Create New API Module
|
|
289
|
+
- Required: 📁 Directory Structure (`directory-structure`)
|
|
290
|
+
- Also read: 🎯 Type Safety Guidelines (`type-safety`)
|
|
291
|
+
|
|
292
|
+
### Scenario 2: Write Database Operations
|
|
293
|
+
- Required: 🗄️ Database Operations (`database-operations`)
|
|
294
|
+
- Reference: 🎨 Error Handling (`error-handling`)
|
|
295
|
+
|
|
296
|
+
### Scenario 3: Add New Endpoint
|
|
297
|
+
- Required: 🎯 Router Guidelines (`router-guidelines`)
|
|
298
|
+
- Reference: 🎯 Type Safety Guidelines (`type-safety`)
|
|
299
|
+
|
|
300
|
+
[... add more scenarios based on project needs ...]
|
|
301
|
+
|
|
302
|
+
## Core Rules Quick Reference
|
|
303
|
+
|
|
304
|
+
| Rule | Section ID |
|
|
305
|
+
|------|------------|
|
|
306
|
+
| **All inputs/outputs must have Zod Schema** | `zod-schema` |
|
|
307
|
+
| **Response body must include success + reason** | `response-format` |
|
|
308
|
+
| **Never await database in loops** | `no-loops` |
|
|
309
|
+
| **No non-null assertions** | `non-null-assertion` |
|
|
310
|
+
|
|
311
|
+
## Reference Examples
|
|
312
|
+
|
|
313
|
+
| Feature | Reference File |
|
|
314
|
+
|---------|----------------|
|
|
315
|
+
| Complete module structure | `[path]` |
|
|
316
|
+
| Zod Schema definition | `[path]` |
|
|
317
|
+
| Database operations | `[path]` |
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## Output Requirements
|
|
323
|
+
|
|
324
|
+
1. **Create directory**: `mkdir -p workflow/structure/backend`
|
|
325
|
+
2. **Write in English**: All documentation must be in English
|
|
326
|
+
3. **Add section markers**: Use `@@@section:id` and `@@@/section:id` format
|
|
327
|
+
4. **Generate index.md**: Reference sections by ID, not line numbers
|
|
328
|
+
5. **Use actual project code**: Examples should come from real project files
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## Completion Confirmation
|
|
333
|
+
|
|
334
|
+
- [ ] `doc.md` created with detailed guidelines in **English**
|
|
335
|
+
- [ ] Section markers added to all major sections
|
|
336
|
+
- [ ] `index.md` created with section IDs
|
|
337
|
+
- [ ] Example code from actual project files
|
|
338
|
+
- [ ] Covers all major patterns used in project
|
|
339
|
+
|
|
340
|
+
Report: "Backend structure guidelines generated, please check `workflow/structure/backend/` directory"
|
|
341
|
+
|