generator-mico-cli 0.2.31 → 0.2.32
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 +145 -18
- package/bin/mico.js +76 -0
- package/generators/h5-react/ignore-list.json +1 -0
- package/generators/h5-react/index.js +349 -0
- package/generators/h5-react/meta.json +11 -0
- package/generators/h5-react/templates/.commitlintrc.js +7 -0
- package/generators/h5-react/templates/.cursor/rules/cicd-deploy.mdc +104 -0
- package/generators/h5-react/templates/.cursor/rules/common-intl.mdc +42 -0
- package/generators/h5-react/templates/.cursor/rules/git-hooks.mdc +40 -0
- package/generators/h5-react/templates/.cursor/rules/internal-packages.mdc +46 -0
- package/generators/h5-react/templates/.cursor/rules/monorepo.mdc +64 -0
- package/generators/h5-react/templates/.cursor/rules/package-json.mdc +52 -0
- package/generators/h5-react/templates/.cursor/rules/tailwind-umi.mdc +60 -0
- package/generators/h5-react/templates/.cursor/rules/umi-app.mdc +74 -0
- package/generators/h5-react/templates/.cursor/rules/umi-config.mdc +86 -0
- package/generators/h5-react/templates/.cursor/rules/umi-mock.mdc +80 -0
- package/generators/h5-react/templates/.cursor/rules/workspace-request.mdc +52 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/SKILL.md +213 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/evals/evals.json +23 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/references/cursor-rule-template.md +60 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/references/phase-1-scanning.md +102 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/references/phase-2-context-analysis.md +102 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/references/phase-3-pattern-extraction.md +105 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/references/phase-4-module-mapping.md +65 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/references/phase-5-glossary.md +63 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/references/templates/DEV_PATTERNS.tpl.md +77 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/references/templates/GLOSSARY.tpl.md +17 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/references/templates/MODULE_MAP.tpl.md +45 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/references/templates/PROJECT_CONTEXT.tpl.md +155 -0
- package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/references/update-mode.md +116 -0
- package/generators/h5-react/templates/.env.development +5 -0
- package/generators/h5-react/templates/.env.production +5 -0
- package/generators/h5-react/templates/.env.testing +5 -0
- package/generators/h5-react/templates/.husky/commit-msg +2 -0
- package/generators/h5-react/templates/.husky/pre-commit +2 -0
- package/generators/h5-react/templates/.lintstagedrc.js +8 -0
- package/generators/h5-react/templates/.prettierrc.json +7 -0
- package/generators/h5-react/templates/CICD/before_build.sh +76 -0
- package/generators/h5-react/templates/CICD/start_dev.sh +54 -0
- package/generators/h5-react/templates/CICD/start_local.sh +30 -0
- package/generators/h5-react/templates/CICD/start_prod.sh +53 -0
- package/generators/h5-react/templates/CICD/start_test.sh +55 -0
- package/generators/h5-react/templates/CICD/wangsu_fresh_dev.sh +19 -0
- package/generators/h5-react/templates/CICD/wangsu_fresh_prod.sh +19 -0
- package/generators/h5-react/templates/CICD/wangsu_fresh_test.sh +19 -0
- package/generators/h5-react/templates/README.md +301 -0
- package/generators/h5-react/templates/_gitignore +30 -0
- package/generators/h5-react/templates/_npmrc +6 -0
- package/generators/h5-react/templates/apps/.gitkeep +0 -0
- package/generators/h5-react/templates/dev.preset.json +10 -0
- package/generators/h5-react/templates/package.json +56 -0
- package/generators/h5-react/templates/packages/common-intl/README.md +180 -0
- package/generators/h5-react/templates/packages/common-intl/eslint.config.ts +12 -0
- package/generators/h5-react/templates/packages/common-intl/package.json +31 -0
- package/generators/h5-react/templates/packages/common-intl/src/index.ts +3 -0
- package/generators/h5-react/templates/packages/common-intl/src/intl.ts +100 -0
- package/generators/h5-react/templates/packages/common-intl/tsconfig.json +3 -0
- package/generators/h5-react/templates/packages/components/eslint.config.ts +12 -0
- package/generators/h5-react/templates/packages/components/package.json +32 -0
- package/generators/h5-react/templates/packages/components/src/Layout/ImmersiveHeader.tsx +126 -0
- package/generators/h5-react/templates/packages/components/src/Layout/LayoutFooter.tsx +72 -0
- package/generators/h5-react/templates/packages/components/src/Layout/index.tsx +121 -0
- package/generators/h5-react/templates/packages/components/src/assets/image/back.png +0 -0
- package/generators/h5-react/templates/packages/components/src/index.ts +0 -0
- package/generators/h5-react/templates/packages/components/tsconfig.json +13 -0
- package/generators/h5-react/templates/packages/components/typings.d.ts +1 -0
- package/generators/h5-react/templates/packages/constant/eslint.config.ts +12 -0
- package/generators/h5-react/templates/packages/constant/package.json +19 -0
- package/generators/h5-react/templates/packages/constant/src/index.ts +0 -0
- package/generators/h5-react/templates/packages/constant/src/member.ts +8 -0
- package/generators/h5-react/templates/packages/constant/tsconfig.json +3 -0
- package/generators/h5-react/templates/packages/deeplink/eslint.config.ts +12 -0
- package/generators/h5-react/templates/packages/deeplink/package.json +18 -0
- package/generators/h5-react/templates/packages/deeplink/src/index.ts +7 -0
- package/generators/h5-react/templates/packages/deeplink/tsconfig.json +3 -0
- package/generators/h5-react/templates/packages/domain/eslint.config.ts +12 -0
- package/generators/h5-react/templates/packages/domain/package.json +18 -0
- package/generators/h5-react/templates/packages/domain/src/index.ts +29 -0
- package/generators/h5-react/templates/packages/domain/tsconfig.json +3 -0
- package/generators/h5-react/templates/packages/domain/types.d.ts +11 -0
- package/generators/h5-react/templates/packages/eslint/eslint.config.base.ts +36 -0
- package/generators/h5-react/templates/packages/eslint/eslint.config.react.ts +33 -0
- package/generators/h5-react/templates/packages/eslint/package.json +22 -0
- package/generators/h5-react/templates/packages/js-bridge/eslint.config.ts +17 -0
- package/generators/h5-react/templates/packages/js-bridge/package.json +23 -0
- package/generators/h5-react/templates/packages/js-bridge/src/call.ts +126 -0
- package/generators/h5-react/templates/packages/js-bridge/src/closeH5Page.ts +9 -0
- package/generators/h5-react/templates/packages/js-bridge/src/getUserInfo.ts +96 -0
- package/generators/h5-react/templates/packages/js-bridge/src/index.ts +15 -0
- package/generators/h5-react/templates/packages/js-bridge/tsconfig.json +3 -0
- package/generators/h5-react/templates/packages/js-bridge/type.d.ts +24 -0
- package/generators/h5-react/templates/packages/request/axios.d.ts +42 -0
- package/generators/h5-react/templates/packages/request/eslint.config.ts +17 -0
- package/generators/h5-react/templates/packages/request/package.json +22 -0
- package/generators/h5-react/templates/packages/request/src/index.ts +165 -0
- package/generators/h5-react/templates/packages/request/src/interceptors.ts +126 -0
- package/generators/h5-react/templates/packages/request/src/types.ts +101 -0
- package/generators/h5-react/templates/packages/request/src/url-resolver.ts +66 -0
- package/generators/h5-react/templates/packages/request/src/utils.ts +12 -0
- package/generators/h5-react/templates/packages/request/tsconfig.json +3 -0
- package/generators/h5-react/templates/packages/request/umi.d.ts +94 -0
- package/generators/h5-react/templates/packages/typescript/package.json +11 -0
- package/generators/h5-react/templates/packages/typescript/tsconfig.base.json +23 -0
- package/generators/h5-react/templates/packages/typescript/tsconfig.react.json +7 -0
- package/generators/h5-react/templates/packages/umi-config/eslint.config.ts +12 -0
- package/generators/h5-react/templates/packages/umi-config/package.json +31 -0
- package/generators/h5-react/templates/packages/umi-config/src/config.dev.ts +34 -0
- package/generators/h5-react/templates/packages/umi-config/src/config.prod.development.ts +17 -0
- package/generators/h5-react/templates/packages/umi-config/src/config.prod.production.ts +42 -0
- package/generators/h5-react/templates/packages/umi-config/src/config.prod.testing.ts +17 -0
- package/generators/h5-react/templates/packages/umi-config/src/config.prod.ts +56 -0
- package/generators/h5-react/templates/packages/umi-config/src/config.ts +86 -0
- package/generators/h5-react/templates/packages/umi-config/src/index.ts +25 -0
- package/generators/h5-react/templates/packages/umi-config/src/plugins/apply-sentry-plugin.ts +57 -0
- package/generators/h5-react/templates/packages/umi-config/src/type.d.ts +3 -0
- package/generators/h5-react/templates/packages/umi-config/tsconfig.json +3 -0
- package/generators/h5-react/templates/packages/utils/eslint.config.ts +12 -0
- package/generators/h5-react/templates/packages/utils/package.json +27 -0
- package/generators/h5-react/templates/packages/utils/src/date.ts +21 -0
- package/generators/h5-react/templates/packages/utils/src/env.ts +40 -0
- package/generators/h5-react/templates/packages/utils/src/index.ts +3 -0
- package/generators/h5-react/templates/packages/utils/src/md5.ts +17 -0
- package/generators/h5-react/templates/packages/utils/src/mock.ts +83 -0
- package/generators/h5-react/templates/packages/utils/src/number.ts +23 -0
- package/generators/h5-react/templates/packages/utils/src/tailwind.ts +12 -0
- package/generators/h5-react/templates/packages/utils/src/url.ts +19 -0
- package/generators/h5-react/templates/packages/utils/tsconfig.json +9 -0
- package/generators/h5-react/templates/page.config.ts +1 -0
- package/generators/h5-react/templates/pnpm-workspace.yaml +17 -0
- package/generators/h5-react/templates/scripts/collect-dist.js +78 -0
- package/generators/h5-react/templates/scripts/dev-preset.js +265 -0
- package/generators/h5-react/templates/scripts/dev-preset.schema.json +39 -0
- package/generators/h5-react/templates/scripts/dev.js +133 -0
- package/generators/h5-react/templates/scripts/gateway.ts +241 -0
- package/generators/h5-react/templates/turbo.json +86 -0
- package/generators/subapp-h5/ignore-list.json +1 -0
- package/generators/subapp-h5/index.js +424 -0
- package/generators/subapp-h5/meta.json +10 -0
- package/generators/subapp-h5/templates/.env +1 -0
- package/generators/subapp-h5/templates/.stylelintrc.js +22 -0
- package/generators/subapp-h5/templates/config/config.dev.ts +7 -0
- package/generators/subapp-h5/templates/config/config.prod.development.ts +7 -0
- package/generators/subapp-h5/templates/config/config.prod.production.ts +10 -0
- package/generators/subapp-h5/templates/config/config.prod.testing.ts +7 -0
- package/generators/subapp-h5/templates/config/config.prod.ts +7 -0
- package/generators/subapp-h5/templates/config/config.ts +6 -0
- package/generators/subapp-h5/templates/config/routes.ts +13 -0
- package/generators/subapp-h5/templates/eslint.config.ts +12 -0
- package/generators/subapp-h5/templates/mock/user.ts +34 -0
- package/generators/subapp-h5/templates/package.json +42 -0
- package/generators/subapp-h5/templates/src/app.tsx +14 -0
- package/generators/subapp-h5/templates/src/assets/yay.jpg +0 -0
- package/generators/subapp-h5/templates/src/intl.ts +37 -0
- package/generators/subapp-h5/templates/src/layouts/index.tsx +10 -0
- package/generators/subapp-h5/templates/src/pages/index.tsx +22 -0
- package/generators/subapp-h5/templates/src/services/user.ts +38 -0
- package/generators/subapp-h5/templates/tailwind.config.js +16 -0
- package/generators/subapp-h5/templates/tailwind.css +7 -0
- package/generators/subapp-h5/templates/tsconfig.json +3 -0
- package/generators/subapp-h5/templates/typings.d.ts +1 -0
- package/lib/setup-multica-desktop.js +154 -0
- package/package.json +1 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: biz-app-analyzer
|
|
3
|
+
description: Analyze a business application's codebase and generate a structured AI knowledge base — four Markdown documents that capture project context, architecture, development patterns, and domain glossary. Use this skill whenever the user mentions "analyze project", "generate project docs", "help AI understand my project", "project knowledge base", "project context", or complains that "AI doesn't understand my project" or "I have to re-explain the project every time". Also use it when the user provides a PRD but the AI lacks project context to act on it, or when onboarding to an unfamiliar codebase. Even if the user just says "look at this project" or "what does this codebase do", this skill is likely the right tool.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Biz App Analyzer
|
|
7
|
+
|
|
8
|
+
Generate a structured AI knowledge base from any business application codebase. The output is a set of Markdown documents that give future AI conversations deep understanding of the project — its purpose, architecture, mechanisms, development patterns, and domain vocabulary.
|
|
9
|
+
|
|
10
|
+
## What This Skill Produces
|
|
11
|
+
|
|
12
|
+
Four documents, saved to `.ai-docs/` in the project root:
|
|
13
|
+
|
|
14
|
+
| Document | Core Question It Answers |
|
|
15
|
+
|----------|------------------------|
|
|
16
|
+
| `PROJECT_CONTEXT.md` | What is this project, how is the code organized, and how do things work under the hood? |
|
|
17
|
+
| `DEV_PATTERNS.md` | When given a new requirement, what's the standard way to implement it in this project? |
|
|
18
|
+
| `MODULE_MAP.md` | For a specific page/module, what routes, APIs, stores, and components are involved? |
|
|
19
|
+
| `GLOSSARY.md` | What do project-specific terms mean, and how do PRD terms map to code? |
|
|
20
|
+
|
|
21
|
+
Together these documents enable an AI to behave like a developer who has spent months on the project — knowing where things are, how things connect, and what patterns to follow.
|
|
22
|
+
|
|
23
|
+
## Execution Flow
|
|
24
|
+
|
|
25
|
+
The analysis runs in five phases. Each phase builds on the previous one's findings. For detailed instructions on each phase, read the corresponding reference file.
|
|
26
|
+
|
|
27
|
+
### Phase 1: Project Scanning
|
|
28
|
+
|
|
29
|
+
Read `references/phase-1-scanning.md` for detailed instructions.
|
|
30
|
+
|
|
31
|
+
Identify what this project is at a technical level. Locate the dependency manifest (package.json, requirements.txt, go.mod, Cargo.toml, etc.), scan the source directory tree, read build configuration, and extract environment variable names.
|
|
32
|
+
|
|
33
|
+
**What to read:** Dependency manifest, build config files, `.env*` files (names only), source directory tree (3 levels deep).
|
|
34
|
+
|
|
35
|
+
**What to produce:** A mental model of the tech stack, directory layout, and environment setup. This guides all subsequent phases.
|
|
36
|
+
|
|
37
|
+
### Phase 2: Context Analysis
|
|
38
|
+
|
|
39
|
+
Read `references/phase-2-context-analysis.md` for detailed instructions.
|
|
40
|
+
|
|
41
|
+
Understand how the project works by analyzing its core mechanisms — not file-by-file, but as interconnected systems. Find and analyze these five mechanisms:
|
|
42
|
+
|
|
43
|
+
1. **Request layer** — How HTTP requests are made, authenticated, and error-handled
|
|
44
|
+
2. **Routing & navigation** — How URLs map to pages, how navigation guards work
|
|
45
|
+
3. **State management** — What data is shared across components and how
|
|
46
|
+
4. **Auth & permissions** — How users are authenticated and how access is controlled
|
|
47
|
+
5. **Shared capabilities** — What reusable components, hooks, and utilities exist and how they're meant to be used together
|
|
48
|
+
|
|
49
|
+
**What to produce:** Fill in the `PROJECT_CONTEXT.md` template from `references/templates/`.
|
|
50
|
+
|
|
51
|
+
### Phase 3: Pattern Extraction
|
|
52
|
+
|
|
53
|
+
Read `references/phase-3-pattern-extraction.md` for detailed instructions.
|
|
54
|
+
|
|
55
|
+
Discover how developers in this project typically build things. Sample 2-3 representative pages from different business modules, read their full source code, and identify recurring structural patterns — the "recipes" that get repeated across the codebase.
|
|
56
|
+
|
|
57
|
+
**What to produce:** Fill in the `DEV_PATTERNS.md` template from `references/templates/`.
|
|
58
|
+
|
|
59
|
+
### Phase 4: Module Mapping
|
|
60
|
+
|
|
61
|
+
Read `references/phase-4-module-mapping.md` for detailed instructions.
|
|
62
|
+
|
|
63
|
+
Build an index of every page/module and its dependencies. For each page, extract which route it serves, which APIs it calls, which stores it uses, and which shared components it imports.
|
|
64
|
+
|
|
65
|
+
**What to produce:** Fill in the `MODULE_MAP.md` template from `references/templates/`.
|
|
66
|
+
|
|
67
|
+
### Phase 5: Glossary Generation
|
|
68
|
+
|
|
69
|
+
Read `references/phase-5-glossary.md` for detailed instructions.
|
|
70
|
+
|
|
71
|
+
Extract domain-specific vocabulary from all previous phases. Identify terms that a newcomer (human or AI) would not immediately understand — both business terms and project-specific technical terms.
|
|
72
|
+
|
|
73
|
+
**What to produce:** Fill in the `GLOSSARY.md` template from `references/templates/`.
|
|
74
|
+
|
|
75
|
+
### Finalization: Meta File and Cursor Rule
|
|
76
|
+
|
|
77
|
+
After all five phases are complete and the four documents are written to `.ai-docs/`, do two more things:
|
|
78
|
+
|
|
79
|
+
**1. Write `.ai-docs-meta.json`** — a snapshot of the project's current state, used by the update mode to detect changes later. The structure:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"generated_at": "ISO 8601 timestamp",
|
|
84
|
+
"project_root": "absolute path",
|
|
85
|
+
"files_snapshot": {
|
|
86
|
+
"views_modules": ["list of top-level directories under views/"],
|
|
87
|
+
"pages": ["list of all .vue/.tsx page file paths under views/"],
|
|
88
|
+
"components": ["list of files/directories under components/"],
|
|
89
|
+
"hooks": ["list of files under hooks/ or composables/"],
|
|
90
|
+
"stores": ["list of files under store/ or stores/"],
|
|
91
|
+
"critical_files": {
|
|
92
|
+
"path/to/request-wrapper": "last modified ISO timestamp",
|
|
93
|
+
"path/to/router-entry": "last modified ISO timestamp",
|
|
94
|
+
"path/to/auth-guard": "last modified ISO timestamp",
|
|
95
|
+
"path/to/main-entry": "last modified ISO timestamp",
|
|
96
|
+
"package.json": "last modified ISO timestamp"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**2. Generate `.cursor/rules/ai-docs.mdc`** — a Cursor Rule that tells future AI sessions how to consume the knowledge base. Read `references/cursor-rule-template.md` for the template. This rule ensures that AI automatically reads `PROJECT_CONTEXT.md` for context and checks document freshness before starting work.
|
|
103
|
+
|
|
104
|
+
## Output Quality Standards
|
|
105
|
+
|
|
106
|
+
### PROJECT_CONTEXT.md
|
|
107
|
+
|
|
108
|
+
This is the most important document. An AI reading only this file should understand 80% of what it needs to work in the project. Quality checks:
|
|
109
|
+
|
|
110
|
+
- The project overview should make sense to someone who has never seen the codebase. Explain what the product does, who uses it, and why it exists — not just "a Vue 3 project".
|
|
111
|
+
- Every mechanism must describe the **flow**, not just list files. "A request goes through proxy.js which adds auth headers, hits the backend at /proxy/maidocha_svr/*, checks for 20x status codes, and extracts data from response.content" is useful. "proxy.js handles API requests" is not.
|
|
112
|
+
- Shared components must document their **collaboration patterns**, not just their Props. "CustomTable watches readParam for changes and auto-fetches data from readURL" tells the AI how to use it. A Props table alone does not.
|
|
113
|
+
- Include concrete examples where they clarify a mechanism. A snippet of how a typical page calls an API is worth more than an abstract description.
|
|
114
|
+
|
|
115
|
+
### DEV_PATTERNS.md
|
|
116
|
+
|
|
117
|
+
This document bridges understanding and action. An AI reading a PRD should be able to match the requirement to a pattern and know exactly what files to create and modify. Quality checks:
|
|
118
|
+
|
|
119
|
+
- Each pattern must have a **trigger condition** — what kind of PRD requirement maps to this pattern.
|
|
120
|
+
- Each pattern must list the **complete set of files** to create and modify, including side-effects like route registration and i18n entries.
|
|
121
|
+
- Each pattern must name a **reference page** — a real existing page that exemplifies the pattern, so the AI can read it as a concrete template.
|
|
122
|
+
- Patterns should be ordered by frequency. The most common pattern first.
|
|
123
|
+
|
|
124
|
+
### MODULE_MAP.md
|
|
125
|
+
|
|
126
|
+
This is a lookup table. When an AI needs to modify a specific page, it checks here to understand the blast radius. Quality checks:
|
|
127
|
+
|
|
128
|
+
- Every page should have its route path, API endpoints, stores, and component dependencies listed.
|
|
129
|
+
- Group by business module for easy scanning.
|
|
130
|
+
- For large projects (50+ pages), focus on key pages per module rather than exhaustive listing.
|
|
131
|
+
|
|
132
|
+
### GLOSSARY.md
|
|
133
|
+
|
|
134
|
+
This prevents misunderstanding. Quality checks:
|
|
135
|
+
|
|
136
|
+
- Include both business terms (what the domain calls things) and technical terms (what the codebase calls things).
|
|
137
|
+
- If PRD language differs from code language, explicitly map between them.
|
|
138
|
+
- Keep definitions concise — one line per term is ideal.
|
|
139
|
+
|
|
140
|
+
## Analysis Principles
|
|
141
|
+
|
|
142
|
+
These principles apply across all phases. They represent the difference between a document that merely describes files and one that truly transfers understanding.
|
|
143
|
+
|
|
144
|
+
### Analyze mechanisms, not files
|
|
145
|
+
|
|
146
|
+
Don't produce a tour of the filesystem. Instead, trace how things actually work end-to-end. "When a user visits a page, what happens?" is a better organizing question than "What does router/index.ts contain?"
|
|
147
|
+
|
|
148
|
+
Files are containers for mechanisms. The mechanism is what matters. A request might flow through three files — describe the flow once, mentioning the files as waypoints.
|
|
149
|
+
|
|
150
|
+
### Document connections, not islands
|
|
151
|
+
|
|
152
|
+
A component's value is not in what Props it accepts — it's in how it collaborates with other parts of the system. CustomTable's readParam + readURL pattern, combined with CustomSearchBar's @update event, forms a cohesive data-fetching mechanism. Document that mechanism, not two isolated component descriptions.
|
|
153
|
+
|
|
154
|
+
Similarly, a Store's value is in which pages consume it and how. An API endpoint's value is in which page calls it and what triggers the call.
|
|
155
|
+
|
|
156
|
+
### Capture patterns, not instances
|
|
157
|
+
|
|
158
|
+
If ten pages follow the same CRUD structure, describe the pattern once and list which pages follow it. Don't repeat the same structure ten times. This is both more concise and more useful — when the AI builds page eleven, it needs the pattern, not a list of examples.
|
|
159
|
+
|
|
160
|
+
### Serve action, not comprehension
|
|
161
|
+
|
|
162
|
+
Every piece of information should help the AI make a decision. Ask: "If I were implementing a PRD requirement, would this information help me decide what to do?" If not, it's noise.
|
|
163
|
+
|
|
164
|
+
"The project uses Pinia for state management" is trivia. "User permissions are stored in permissStore — read permissStore.userInfo.side_menus to check menu access, and call permissStore.getUser() in route guards to refresh auth state" is actionable.
|
|
165
|
+
|
|
166
|
+
## Adapting to Different Project Types
|
|
167
|
+
|
|
168
|
+
This skill works with any business application. The five mechanisms in Phase 2 exist in virtually every app — they just manifest differently.
|
|
169
|
+
|
|
170
|
+
**Frontend apps** (SPA, SSR): All five mechanisms are typically present. The request layer might be axios/fetch wrappers. Routing is client-side. State management varies by framework. Shared capabilities include UI components and composables/hooks.
|
|
171
|
+
|
|
172
|
+
**Backend services** (API servers, microservices): The "request layer" becomes the API framework's middleware and handler pattern. "Routing" becomes API route definitions. "State management" becomes database models and caching. "Shared capabilities" becomes middleware, validators, and utility modules.
|
|
173
|
+
|
|
174
|
+
**Full-stack apps** (Next.js, Nuxt, etc.): Analyze the frontend and backend aspects separately, then document how they connect (API routes, server actions, data fetching patterns).
|
|
175
|
+
|
|
176
|
+
**Mobile apps** (React Native, Flutter): Similar to frontend apps but with platform-specific navigation patterns and native module integrations.
|
|
177
|
+
|
|
178
|
+
If a mechanism doesn't exist in a project (e.g., a simple CLI tool has no routing), skip it. Don't force the framework — document what's actually there.
|
|
179
|
+
|
|
180
|
+
## Update Mode
|
|
181
|
+
|
|
182
|
+
When the user says "update project docs", "refresh the knowledge base", or similar — don't rerun the full analysis. Instead, run a lightweight incremental update.
|
|
183
|
+
|
|
184
|
+
Read `references/update-mode.md` for the detailed detection and update procedure.
|
|
185
|
+
|
|
186
|
+
The core idea: read `.ai-docs-meta.json` (generated during the initial run), compare it against the current project state, and determine what changed. Changes fall into three tiers:
|
|
187
|
+
|
|
188
|
+
**Tier 1 — Auto-fixable.** Pages added or removed. Update `MODULE_MAP.md` by reading the new page's imports (for additions) or removing the entry (for deletions). No user interaction needed beyond confirmation.
|
|
189
|
+
|
|
190
|
+
**Tier 2 — Targeted update.** New shared components, hooks, or stores added. Read the new files, analyze their interface and purpose, and update the relevant section of `PROJECT_CONTEXT.md`. Ask the user to confirm the additions look right.
|
|
191
|
+
|
|
192
|
+
**Tier 3 — Full regeneration recommended.** Architectural changes detected (request wrapper, router guards, auth mechanism modified), new business modules appeared, or package.json has major dependency changes. Inform the user and suggest rerunning the full analysis. The existing documents are likely stale in ways that targeted patches can't reliably fix.
|
|
193
|
+
|
|
194
|
+
After any update, rewrite `.ai-docs-meta.json` with the new snapshot.
|
|
195
|
+
|
|
196
|
+
## After Generation
|
|
197
|
+
|
|
198
|
+
Once the four documents are generated in `.ai-docs/` (or updated via Update Mode):
|
|
199
|
+
|
|
200
|
+
1. **Cursor Rule auto-generated**: The Finalization step creates `.cursor/rules/ai-docs.mdc`, which tells future AI sessions to read `PROJECT_CONTEXT.md` for context and check document freshness. If this rule already exists (from a previous run), it will be overwritten with the latest version.
|
|
201
|
+
|
|
202
|
+
2. **Other documents on demand**: `DEV_PATTERNS.md`, `MODULE_MAP.md`, and `GLOSSARY.md` are read by AI when relevant — when implementing a feature, modifying a specific module, or encountering unfamiliar terms. The Cursor Rule includes guidance on when to consult each document.
|
|
203
|
+
|
|
204
|
+
3. **Freshness checking**: The generated Cursor Rule instructs AI to read `.ai-docs-meta.json` and compare against the current project state before starting work. If significant drift is detected, the AI will suggest running this skill in Update Mode.
|
|
205
|
+
|
|
206
|
+
## Limitations
|
|
207
|
+
|
|
208
|
+
Be upfront about what this skill cannot do:
|
|
209
|
+
|
|
210
|
+
- Analysis is based on static code reading. It does not execute code, run tests, or observe runtime behavior. Dynamic patterns (like plugin systems or reflection-heavy code) may be incompletely captured.
|
|
211
|
+
- The quality of generated documents depends on how well-structured the project is. A chaotic codebase with no consistent patterns will produce less useful output — but the analysis will honestly reflect that chaos rather than invent patterns that don't exist.
|
|
212
|
+
- Business domain understanding is inferred from code structure, naming, and comments. If the codebase uses cryptic naming with no comments, domain analysis will be shallow. The glossary section will flag terms it cannot confidently define.
|
|
213
|
+
- For monorepos with multiple distinct applications, run the analysis separately on each application's source directory rather than on the repo root.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill_name": "biz-app-analyzer",
|
|
3
|
+
"evals": [
|
|
4
|
+
{
|
|
5
|
+
"id": 1,
|
|
6
|
+
"prompt": "帮我分析一下 maidocha-dashboard 这个项目,生成 AI 知识库文档,让后续 AI 能快速理解这个项目",
|
|
7
|
+
"expected_output": "在项目 .ai-docs/ 目录下生成 4 份 Markdown 文件:PROJECT_CONTEXT.md(包含技术栈、目录结构、请求机制、路由权限、共享组件等完整上下文)、DEV_PATTERNS.md(包含 CRUD 等开发模式及参考页面)、MODULE_MAP.md(按业务模块列出每个页面的路由/API/Store/组件依赖)、GLOSSARY.md(业务术语和技术术语定义)",
|
|
8
|
+
"files": []
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"id": 2,
|
|
12
|
+
"prompt": "我每次跟 AI 聊这个项目都要重新解释一遍技术栈和目录结构,太烦了。能不能帮我生成一套文档,以后 AI 读了就能直接干活?项目在 /Users/mico/Micos/maidocha-dashboard",
|
|
13
|
+
"expected_output": "同上,生成 4 份结构化文档。重点检查:PROJECT_CONTEXT.md 中对请求模式的描述是否足够详细(包括 proxy 模式和活动 API 模式的区分),DEV_PATTERNS.md 中是否提取了 CRUD 管理页面的标准模式并给出了参考页面路径",
|
|
14
|
+
"files": []
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": 3,
|
|
18
|
+
"prompt": "look at the project at /Users/mico/Micos/maidocha-dashboard and help me understand how it's structured. I want documentation that will help AI assistants work with this codebase effectively.",
|
|
19
|
+
"expected_output": "Same 4 documents generated. Key quality check: the analysis should work even when prompted in English, producing documents that accurately capture the Chinese-language business domain (guild management, soulstar activities, etc.) with proper term definitions in the glossary",
|
|
20
|
+
"files": []
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Cursor Rule Template
|
|
2
|
+
|
|
3
|
+
After generating the AI knowledge base, create a Cursor Rule file at `.cursor/rules/ai-docs.mdc` in the target project. This rule ensures future AI sessions automatically consume the knowledge base.
|
|
4
|
+
|
|
5
|
+
Use the template below. Replace `{project_name}` with the actual project name discovered during Phase 1.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Template Content
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
---
|
|
13
|
+
description: AI knowledge base for {project_name}. Provides project context, architecture, development patterns, module mapping, and domain glossary. This rule is auto-generated by the biz-app-analyzer skill.
|
|
14
|
+
globs:
|
|
15
|
+
alwaysApply: true
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# AI Knowledge Base
|
|
19
|
+
|
|
20
|
+
This project has a structured AI knowledge base in `.ai-docs/`. Use it to understand the project before making changes.
|
|
21
|
+
|
|
22
|
+
## Before Starting Any Development Task
|
|
23
|
+
|
|
24
|
+
1. Read `.ai-docs/PROJECT_CONTEXT.md` to understand the project's tech stack, architecture, request mechanisms, routing, state management, permissions, and shared components.
|
|
25
|
+
|
|
26
|
+
2. Check document freshness: read `.ai-docs-meta.json` and compare `generated_at` against today's date. If more than 30 days have passed, or if the current task involves modules/files not mentioned in the documents, suggest the user run `biz-app-analyzer` to refresh the knowledge base.
|
|
27
|
+
|
|
28
|
+
## When Implementing a New Feature or PRD Requirement
|
|
29
|
+
|
|
30
|
+
1. Read `.ai-docs/DEV_PATTERNS.md` to identify which development pattern matches the requirement.
|
|
31
|
+
2. Read `.ai-docs/GLOSSARY.md` if the requirement contains domain-specific terms.
|
|
32
|
+
3. Follow the matched pattern's file checklist, standard structure, and data flow.
|
|
33
|
+
4. Use the pattern's reference page as a concrete implementation template.
|
|
34
|
+
|
|
35
|
+
## When Modifying an Existing Page or Module
|
|
36
|
+
|
|
37
|
+
1. Read `.ai-docs/MODULE_MAP.md` to see the page's dependencies — routes, APIs, stores, and components involved.
|
|
38
|
+
2. Assess the blast radius: which other pages share the same stores or components?
|
|
39
|
+
|
|
40
|
+
## When Encountering Unfamiliar Terms
|
|
41
|
+
|
|
42
|
+
1. Check `.ai-docs/GLOSSARY.md` for business and technical term definitions.
|
|
43
|
+
|
|
44
|
+
## Freshness Check Details
|
|
45
|
+
|
|
46
|
+
Read `.ai-docs-meta.json` and quickly compare:
|
|
47
|
+
- Are there new directories under views/ not listed in `files_snapshot.views_modules`? → New business module, suggest update.
|
|
48
|
+
- Are there new files under components/ or hooks/ not in the snapshot? → New shared capabilities, suggest update.
|
|
49
|
+
- Is `generated_at` more than 30 days ago? → Suggest full refresh.
|
|
50
|
+
|
|
51
|
+
If changes are detected, inform the user: "The project knowledge base may be outdated. Consider running the biz-app-analyzer skill to update it."
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Notes
|
|
57
|
+
|
|
58
|
+
- Set `alwaysApply: true` so this rule is active in every conversation about the project.
|
|
59
|
+
- The `globs` field is left empty intentionally — this rule applies globally, not to specific file patterns.
|
|
60
|
+
- If the project already has a `.cursor/rules/ai-docs.mdc` from a previous run, overwrite it. The content may have been updated.
|
package/generators/h5-react/templates/.cursor/skills/biz-app-analyzer/references/phase-1-scanning.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Phase 1: Project Scanning
|
|
2
|
+
|
|
3
|
+
The goal of this phase is to build a technical profile of the project — what it's built with, how files are organized, and what environments it targets. This profile guides every subsequent phase.
|
|
4
|
+
|
|
5
|
+
## Step 1: Locate the Project Root
|
|
6
|
+
|
|
7
|
+
Find the dependency manifest file. This is the anchor that identifies the project root:
|
|
8
|
+
|
|
9
|
+
- **JavaScript/TypeScript**: `package.json`
|
|
10
|
+
- **Python**: `pyproject.toml`, `requirements.txt`, or `setup.py`
|
|
11
|
+
- **Go**: `go.mod`
|
|
12
|
+
- **Rust**: `Cargo.toml`
|
|
13
|
+
- **Java**: `pom.xml` or `build.gradle`
|
|
14
|
+
- **Ruby**: `Gemfile`
|
|
15
|
+
- **PHP**: `composer.json`
|
|
16
|
+
|
|
17
|
+
If the user provided a path to a subdirectory, walk up until you find the manifest. If the project is a monorepo (multiple manifest files at different levels), ask the user which application to analyze, or analyze the one at the path they specified.
|
|
18
|
+
|
|
19
|
+
## Step 2: Identify the Tech Stack
|
|
20
|
+
|
|
21
|
+
Read the dependency manifest and extract:
|
|
22
|
+
|
|
23
|
+
**Core framework and version.** Not just "Vue" but "Vue 3.5.13". Not just "React" but "React 18.2 with Next.js 14". The version matters because APIs and patterns differ significantly across major versions.
|
|
24
|
+
|
|
25
|
+
**UI library.** Element Plus, Ant Design, Vant, Material UI, Chakra, Tailwind — this determines what component vocabulary the project speaks.
|
|
26
|
+
|
|
27
|
+
**State management.** Pinia, Vuex, Redux, Zustand, MobX, Jotai — or none (prop drilling / context only).
|
|
28
|
+
|
|
29
|
+
**Build tool.** Vite, Webpack, Rollup, esbuild, Turbopack — and its version.
|
|
30
|
+
|
|
31
|
+
**Language.** TypeScript (check for tsconfig.json and its strict mode setting) or JavaScript. Check for type-checking strictness.
|
|
32
|
+
|
|
33
|
+
**Other significant dependencies.** Internationalization (vue-i18n, react-intl), HTTP clients (axios, ky, ofetch), charting (echarts, chart.js), rich text editors, file upload, monitoring (Sentry), etc. Focus on dependencies that shape how code is written, not utility libraries like lodash.
|
|
34
|
+
|
|
35
|
+
## Step 3: Scan the Source Directory
|
|
36
|
+
|
|
37
|
+
Generate a directory tree of the source root (typically `src/` or `app/`), 3 levels deep. For each top-level directory, note what kind of files it contains based on naming patterns:
|
|
38
|
+
|
|
39
|
+
- Directories like `views/`, `pages/`, `screens/` → page components
|
|
40
|
+
- Directories like `components/`, `ui/` → shared/reusable components
|
|
41
|
+
- Directories like `hooks/`, `composables/`, `lib/` → shared logic
|
|
42
|
+
- Directories like `store/`, `stores/`, `state/` → state management
|
|
43
|
+
- Directories like `api/`, `services/`, `requests/` → API layer
|
|
44
|
+
- Directories like `router/`, `routes/` → routing configuration
|
|
45
|
+
- Directories like `utils/`, `helpers/`, `common/` → utility functions
|
|
46
|
+
- Directories like `types/`, `interfaces/`, `models/` → type definitions
|
|
47
|
+
- Directories like `assets/`, `static/`, `public/` → static resources
|
|
48
|
+
- Directories like `locale/`, `i18n/`, `lang/` → internationalization
|
|
49
|
+
- Directories like `middleware/`, `guards/`, `permission/` → access control
|
|
50
|
+
- Directories like `plugins/`, `directives/` → framework extensions
|
|
51
|
+
- Directories like `config/`, `constants/`, `enums/` → configuration and constants
|
|
52
|
+
|
|
53
|
+
Not every project will have all of these. Record what's actually there.
|
|
54
|
+
|
|
55
|
+
## Step 4: Read Build Configuration
|
|
56
|
+
|
|
57
|
+
Read the build configuration file (vite.config.ts, webpack.config.js, next.config.js, etc.) and extract information that affects development:
|
|
58
|
+
|
|
59
|
+
- **Path aliases**: `@/` → `src/`, `@components/` → `src/components/`, etc. These are essential for understanding import paths throughout the codebase.
|
|
60
|
+
- **Dev server proxy rules**: These reveal how the frontend connects to backend services during development. Proxy paths like `/api` → `https://backend.example.com` indicate the real API structure.
|
|
61
|
+
- **Environment-specific behavior**: Different build targets (development, staging, production) and how they're configured.
|
|
62
|
+
- **Plugin configuration**: Auto-import plugins, component resolvers, and other build-time transforms that affect how code is written.
|
|
63
|
+
|
|
64
|
+
## Step 5: Extract Environment Variables
|
|
65
|
+
|
|
66
|
+
Read `.env`, `.env.development`, `.env.production`, and similar files. Extract **variable names only**, never values. Group them by purpose:
|
|
67
|
+
|
|
68
|
+
- API endpoints (e.g., `VITE_API_BASE_URL`, `NEXT_PUBLIC_API_URL`)
|
|
69
|
+
- Feature flags (e.g., `VITE_ENABLE_ANALYTICS`)
|
|
70
|
+
- Third-party service keys (e.g., `VITE_SENTRY_DSN` — note the name, not the value)
|
|
71
|
+
|
|
72
|
+
This reveals what external services the project depends on and how environments differ.
|
|
73
|
+
|
|
74
|
+
## Step 6: Check for Existing Documentation
|
|
75
|
+
|
|
76
|
+
Quickly check if the project already has useful documentation:
|
|
77
|
+
|
|
78
|
+
- `README.md` — read it; it may contain setup instructions, architecture notes, or business context
|
|
79
|
+
- `docs/` directory — note what's there
|
|
80
|
+
- `.cursor/rules/` — the project may already have AI rules that inform the analysis
|
|
81
|
+
- `CHANGELOG.md` — recent entries reveal what's actively being developed
|
|
82
|
+
- `CONTRIBUTING.md` — may describe conventions
|
|
83
|
+
|
|
84
|
+
Don't spend too long on this. Just note what exists so later phases can leverage it.
|
|
85
|
+
|
|
86
|
+
## Phase 1 Output
|
|
87
|
+
|
|
88
|
+
By the end of this phase, you should be able to fill in these sections of `PROJECT_CONTEXT.md`:
|
|
89
|
+
|
|
90
|
+
- **Project overview**: What the product is, based on README + dependency analysis + directory structure clues
|
|
91
|
+
- **Tech stack table**: Framework, UI library, state management, build tool, language — all with versions
|
|
92
|
+
- **Directory structure**: The tree with per-directory role annotations
|
|
93
|
+
- **Environment configuration**: Variable names grouped by purpose, proxy rules
|
|
94
|
+
|
|
95
|
+
You should also have a clear mental map of where to look in subsequent phases:
|
|
96
|
+
- Where are the route definitions?
|
|
97
|
+
- Where is the HTTP request wrapper?
|
|
98
|
+
- Where are the stores?
|
|
99
|
+
- Where are the shared components?
|
|
100
|
+
- Where are the page components organized?
|
|
101
|
+
|
|
102
|
+
Carry these answers forward — Phase 2 will dive deep into each of these locations.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Phase 2: Context Analysis
|
|
2
|
+
|
|
3
|
+
The goal of this phase is to understand how the project actually works — not what files exist, but how data flows, how users are authenticated, how pages get rendered, and how shared code is meant to be used. This is the most important phase because it produces the core knowledge document.
|
|
4
|
+
|
|
5
|
+
Read the relevant files identified in Phase 1. For each mechanism below, trace the flow end-to-end rather than describing files in isolation.
|
|
6
|
+
|
|
7
|
+
## Mechanism A: Request Layer
|
|
8
|
+
|
|
9
|
+
Find the HTTP client setup — typically an axios instance, fetch wrapper, or framework-specific data fetching utility. There may be more than one.
|
|
10
|
+
|
|
11
|
+
**What to extract for each request pattern:**
|
|
12
|
+
|
|
13
|
+
1. **Base URL strategy.** Is it hardcoded, from environment variables, or determined by proxy rules? Does it differ per API domain?
|
|
14
|
+
2. **Authentication injection.** How are auth tokens attached? Headers? Cookies? Where does the token come from (localStorage, cookie, store)?
|
|
15
|
+
3. **Request lifecycle.** What happens before a request (interceptors, middleware)? What happens on success (data extraction — is it `response.data`, `response.data.content`, something else)? What happens on error (status code handling, redirects, user-facing messages)?
|
|
16
|
+
4. **Loading state.** Is there a global loading indicator? How do individual pages manage loading states?
|
|
17
|
+
5. **Multiple instances.** If the project has multiple request configurations (e.g., one for the main API, another for a third-party service), document each one and explain when each is used.
|
|
18
|
+
|
|
19
|
+
**Output format:** Describe each request pattern as a narrative flow, not a file description. Example of the level of detail needed:
|
|
20
|
+
|
|
21
|
+
> Business API requests go through `share/proxy.js`. The `axiosPostConfig(url, params)` function prepends `proxy/maidocha_svr/` to the URL, adds `Authtoken`, `oid`, and `lang` headers from cookies, shows a global loading spinner (unless `__NO_LOADING__` is set), and checks if the response code starts with "20" for success. On 401/403, the user is redirected to `/logout`. Success data is extracted from `response.content` or `response.data`.
|
|
22
|
+
|
|
23
|
+
## Mechanism B: Routing & Navigation
|
|
24
|
+
|
|
25
|
+
Find the router configuration — the entry file and any module/route definition files.
|
|
26
|
+
|
|
27
|
+
**What to extract:**
|
|
28
|
+
|
|
29
|
+
1. **Router mode.** Hash or history mode? This affects URL structure and deployment.
|
|
30
|
+
2. **Route organization.** Are routes in one file or split by module? What's the grouping logic?
|
|
31
|
+
3. **Layout structure.** Is there a shared layout component that wraps page content? What does it include (header, sidebar, breadcrumbs, tabs)?
|
|
32
|
+
4. **Navigation guards.** What checks happen before a route loads? Authentication verification? Permission checking? Data prefetching?
|
|
33
|
+
5. **Lazy loading.** Are page components loaded lazily? What's the import pattern?
|
|
34
|
+
6. **Route metadata.** What custom metadata is attached to routes (titles, permissions, icons)?
|
|
35
|
+
7. **The full page render chain.** Trace what happens from URL entry to visible page: URL → router match → guard execution → layout rendering → page component mounting. This chain is critical for understanding where to intervene when adding new pages.
|
|
36
|
+
|
|
37
|
+
## Mechanism C: State Management
|
|
38
|
+
|
|
39
|
+
Find the store directory and read each store file.
|
|
40
|
+
|
|
41
|
+
**What to extract for each store:**
|
|
42
|
+
|
|
43
|
+
1. **Responsibility.** What domain does this store own? User data? UI state? Business entity cache?
|
|
44
|
+
2. **Data structure.** What are the key state fields and their types? Don't list every field — focus on the ones that other parts of the codebase depend on.
|
|
45
|
+
3. **Core methods.** What are the main actions/getters? How do they interact with the API layer?
|
|
46
|
+
4. **Caching strategy.** Does the store cache data? How is freshness managed? Is there a TTL or manual invalidation?
|
|
47
|
+
5. **Consumption pattern.** How do pages typically access this store? Direct import? Injection? A composable/hook wrapper?
|
|
48
|
+
|
|
49
|
+
Also note **cross-store dependencies** — if one store reads from or triggers another, that relationship matters.
|
|
50
|
+
|
|
51
|
+
## Mechanism D: Auth & Permissions
|
|
52
|
+
|
|
53
|
+
Find the authentication and permission logic. This often spans multiple files — the login flow, route guards, permission utilities, and the user/auth store.
|
|
54
|
+
|
|
55
|
+
**What to extract:**
|
|
56
|
+
|
|
57
|
+
1. **Authentication flow.** How does a user prove their identity? Token-based? Session? OAuth? Where is the credential stored client-side?
|
|
58
|
+
2. **Session lifecycle.** When is auth state checked? On every navigation? On app init? How is session expiry handled?
|
|
59
|
+
3. **Route-level access control.** How does the system decide whether a user can access a given route? Is it role-based, permission-list-based, or menu-tree-based?
|
|
60
|
+
4. **In-page access control.** Beyond "can you see this page", how does the system control what a user can do within a page? Button visibility? Tab filtering? Field editability?
|
|
61
|
+
5. **Permission data source.** Where does permission information come from? An API call on login? A field in the user object? A separate permission service?
|
|
62
|
+
|
|
63
|
+
Document this as a flow: user opens app → auth check → permission tree constructed → routes filtered → page-level controls applied.
|
|
64
|
+
|
|
65
|
+
## Mechanism E: Shared Capabilities
|
|
66
|
+
|
|
67
|
+
Analyze the shared components, hooks/composables, and utility functions directories.
|
|
68
|
+
|
|
69
|
+
**For shared components,** don't just list Props. For each significant component, document:
|
|
70
|
+
|
|
71
|
+
1. **Purpose and when to use it.** Under what circumstances should a developer reach for this component instead of building from scratch?
|
|
72
|
+
2. **Key interface.** The most important Props and Events — not all of them, just the ones that define how the component behaves.
|
|
73
|
+
3. **Collaboration pattern.** How does this component work with other parts of the system? Does CustomTable auto-fetch data when readParam changes? Does a Dialog component pair with a specific hook?
|
|
74
|
+
4. **Gotchas.** Anything non-obvious about its behavior — auto-refresh triggers, special parameter names, data format expectations.
|
|
75
|
+
|
|
76
|
+
**For hooks/composables,** document:
|
|
77
|
+
|
|
78
|
+
1. **What problem it solves.** Why does this hook exist? What repetitive code does it eliminate?
|
|
79
|
+
2. **Parameters and return values.** Types and purpose.
|
|
80
|
+
3. **Typical usage.** A one-sentence description of how it's used in pages.
|
|
81
|
+
|
|
82
|
+
**For utilities,** briefly note the key functions and what they do. Only detail functions that are widely used or have non-obvious behavior.
|
|
83
|
+
|
|
84
|
+
## Bringing It Together
|
|
85
|
+
|
|
86
|
+
After analyzing all five mechanisms, the information should interconnect naturally. A page render involves routing (B) which triggers auth checks (D) which reads from the user store (C). The page then uses shared components (E) that call APIs through the request layer (A) which also populates stores (C).
|
|
87
|
+
|
|
88
|
+
When writing PROJECT_CONTEXT.md, let these connections show. If a shared component internally uses a specific API pattern, mention it in the component's documentation. If the auth mechanism stores data in a specific store, cross-reference it.
|
|
89
|
+
|
|
90
|
+
## Phase 2 Output
|
|
91
|
+
|
|
92
|
+
Fill in the `PROJECT_CONTEXT.md` template with:
|
|
93
|
+
|
|
94
|
+
- Project overview (from Phase 1, enriched with business context discovered during file reading)
|
|
95
|
+
- Directory structure with role annotations (from Phase 1)
|
|
96
|
+
- Request mechanism section (Mechanism A)
|
|
97
|
+
- Routing & navigation section (Mechanism B)
|
|
98
|
+
- State management section (Mechanism C)
|
|
99
|
+
- Auth & permissions section (Mechanism D)
|
|
100
|
+
- Shared components section (Mechanism E — components)
|
|
101
|
+
- Hooks / composables section (Mechanism E — hooks)
|
|
102
|
+
- Utility functions section (Mechanism E — utils)
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Phase 3: Pattern Extraction
|
|
2
|
+
|
|
3
|
+
The goal of this phase is to discover the "recipes" that developers follow when building features in this project. These patterns are what make the difference between an AI that understands the project and an AI that can actually build things in it.
|
|
4
|
+
|
|
5
|
+
## Strategy: Sample, Compare, Generalize
|
|
6
|
+
|
|
7
|
+
Don't try to read every page. Instead:
|
|
8
|
+
|
|
9
|
+
1. **Sample broadly.** Pick 2-3 pages from different business modules. Choose pages that look like they represent common feature types — a list/table page, a form/detail page, a dashboard/stats page.
|
|
10
|
+
|
|
11
|
+
2. **Read each sample page fully.** Read the complete source — template, script, and style. Note everything: what it imports, how it structures data, how it fetches data, how it handles user interactions, what components it uses.
|
|
12
|
+
|
|
13
|
+
3. **Compare across samples.** Look for structural similarities. Do multiple pages use the same component arrangement? The same data-fetching pattern? The same form-submit flow? These similarities are your patterns.
|
|
14
|
+
|
|
15
|
+
4. **Generalize.** Abstract the pattern from the concrete examples. A pattern is not "GiftManage.vue uses CustomTable with readURL" — it's "CRUD list pages use CustomTable with a readURL pointing to the list API, driven by a readParam object that CustomSearchBar updates on search."
|
|
16
|
+
|
|
17
|
+
## What Makes a Good Pattern
|
|
18
|
+
|
|
19
|
+
A pattern should contain everything an AI needs to replicate it from scratch given a new requirement. Specifically:
|
|
20
|
+
|
|
21
|
+
### Trigger Condition
|
|
22
|
+
|
|
23
|
+
When should this pattern be used? Express this in terms of **PRD language**, not code language. Think about what words in a requirement document would signal this pattern:
|
|
24
|
+
|
|
25
|
+
- "manage", "list", "add/edit/delete" → CRUD management page
|
|
26
|
+
- "view details", "review", "approve" → Detail/review page
|
|
27
|
+
- "statistics", "dashboard", "chart" → Data visualization page
|
|
28
|
+
- "configure", "settings", "toggle" → Configuration page
|
|
29
|
+
- "upload", "import", "batch" → Batch operation page
|
|
30
|
+
|
|
31
|
+
### File Checklist
|
|
32
|
+
|
|
33
|
+
What files need to be created or modified? Be exhaustive — this is where AI implementations typically miss steps:
|
|
34
|
+
|
|
35
|
+
**Files to create:**
|
|
36
|
+
- The page component itself (where, naming convention)
|
|
37
|
+
- Sub-components if the page is complex (where, when to split)
|
|
38
|
+
- Page-specific API file if needed (when vs using the shared request layer directly)
|
|
39
|
+
|
|
40
|
+
**Files to modify:**
|
|
41
|
+
- Route registration (which file, what format)
|
|
42
|
+
- Navigation/menu configuration (if separate from routes)
|
|
43
|
+
- Internationalization entries (which files, what keys)
|
|
44
|
+
- Permission configuration (if permission entries need manual registration)
|
|
45
|
+
|
|
46
|
+
### Standard Structure
|
|
47
|
+
|
|
48
|
+
What does the page component look like structurally? Describe in terms of the project's own vocabulary — which shared components form the skeleton, how they're arranged, and how data flows between them.
|
|
49
|
+
|
|
50
|
+
Don't write actual code. Describe the structure:
|
|
51
|
+
|
|
52
|
+
> The page has three sections: a CustomSearchBar at the top configured with searchContent array, a CustomTable in the middle bound to readURL and readParam, and a CustomDialog for add/edit triggered by toolbar buttons. When SearchBar emits @update, the handler merges search values into readParam and resets pagination to page 1. CustomTable watches readParam and auto-fetches. Dialog submission calls axiosPostConfig, then refreshes the table by touching readParam.
|
|
53
|
+
|
|
54
|
+
### Data Flow
|
|
55
|
+
|
|
56
|
+
Trace the data lifecycle for the page's primary operation:
|
|
57
|
+
|
|
58
|
+
- Where does configuration data come from? (enums, constants, API)
|
|
59
|
+
- How is list data fetched? (which API, what triggers it, how is it paginated)
|
|
60
|
+
- How is item data submitted? (which API, what format, what happens after)
|
|
61
|
+
- How are errors handled? (validation, API errors, user feedback)
|
|
62
|
+
|
|
63
|
+
### Reference Page
|
|
64
|
+
|
|
65
|
+
Name the actual file path of an existing page that best exemplifies this pattern. This is crucial — when the AI implements a new page, it can read this reference to see every concrete detail that the pattern description might miss.
|
|
66
|
+
|
|
67
|
+
## Discovering Patterns: What to Look For
|
|
68
|
+
|
|
69
|
+
When reading sample pages, pay attention to:
|
|
70
|
+
|
|
71
|
+
**Template structure.** Do pages share a similar component arrangement? A search bar + table + dialog is one pattern. A tab bar + conditional content is another. A form with save/cancel buttons is another.
|
|
72
|
+
|
|
73
|
+
**Data initialization.** How does the page set up its data on mount? Does it fetch enums? Load a list? Check permissions?
|
|
74
|
+
|
|
75
|
+
**User interaction flows.** Search → fetch → display. Click add → open dialog → fill form → submit → refresh. Click row → navigate to detail. These interaction flows tend to repeat.
|
|
76
|
+
|
|
77
|
+
**Component usage patterns.** Which shared components appear together frequently? If CustomTable and CustomSearchBar always appear as a pair, that's a pattern element.
|
|
78
|
+
|
|
79
|
+
**API call patterns.** Are APIs called directly in the page, through a composable, or through a centralized function? Is there a consistent error handling approach?
|
|
80
|
+
|
|
81
|
+
## Side-Effect Checklist
|
|
82
|
+
|
|
83
|
+
Beyond the page itself, document the "new page setup tax" — everything a developer must do beyond writing the component:
|
|
84
|
+
|
|
85
|
+
1. **Route registration.** Where to add the route, what fields are required (path, component, meta).
|
|
86
|
+
2. **Menu/sidebar entry.** Is it automatic from routes, or does it need a separate configuration?
|
|
87
|
+
3. **Internationalization.** What language files need new entries? What's the key naming convention?
|
|
88
|
+
4. **Permission setup.** Does the new page need permission entries in a backend system or configuration file?
|
|
89
|
+
5. **Navigation.** Does any existing page need to link to this new page?
|
|
90
|
+
|
|
91
|
+
## Handling Variation
|
|
92
|
+
|
|
93
|
+
Not every page will fit neatly into a pattern. That's fine. Your output should:
|
|
94
|
+
|
|
95
|
+
- Cover the most common patterns (the ones that account for 70-80% of pages)
|
|
96
|
+
- Note known variations on each pattern (e.g., "some CRUD pages use a drawer instead of a dialog for editing")
|
|
97
|
+
- Acknowledge that unusual pages exist without forcing them into a pattern
|
|
98
|
+
|
|
99
|
+
## Phase 3 Output
|
|
100
|
+
|
|
101
|
+
Fill in the `DEV_PATTERNS.md` template with:
|
|
102
|
+
|
|
103
|
+
- A "New Page Checklist" section listing the universal side-effects for any new page
|
|
104
|
+
- Pattern sections ordered by frequency (most common first)
|
|
105
|
+
- Each pattern containing: trigger condition, file checklist, standard structure, data flow, and reference page path
|