docs: add AGENTS.md documentation files
Add comprehensive AGENTS.md documentation files across the project structure to document the agent architecture and capabilities. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
95
VBA/AGENTS.md
Normal file
95
VBA/AGENTS.md
Normal file
@@ -0,0 +1,95 @@
|
||||
# VBA Module Knowledge Base
|
||||
|
||||
**Scope:** `VBA/` directory - Core automation logic
|
||||
|
||||
## OVERVIEW
|
||||
|
||||
VBA modules for BOM extraction: ClassModules (domain logic), Modules (workflows), DocumentModules (sheet events).
|
||||
|
||||
## STRUCTURE
|
||||
|
||||
```
|
||||
VBA/
|
||||
├── ClassModules/ # 4 classes: BomExtractor, BomItem, ProductModelParser, ConditionEvaluator
|
||||
├── Modules/ # 4 modules: MainModule, BIPUploadModule, ComponentInventoryCheckModule, TestModule
|
||||
├── DocumentModules/ # Sheet9.cls (event handlers)
|
||||
└── vba_metadata.json # Module metadata
|
||||
```
|
||||
|
||||
## WHERE TO LOOK
|
||||
|
||||
| Task | Location | Notes |
|
||||
|------|----------|-------|
|
||||
| Main entry point | `Modules/MainModule.bas` | `ProcessProductModels()` |
|
||||
| BOM extraction | `ClassModules/BomExtractor.cls` | `ExtractBom()` with assembly logic |
|
||||
| Model parsing | `ClassModules/ProductModelParser.cls` | `Parse()` extracts 6 conditions |
|
||||
| Condition logic | `ClassModules/ConditionEvaluator.cls` | Expression evaluation |
|
||||
| BIP upload | `Modules/BIPUploadModule.bas` | Upload to BIP system |
|
||||
| Inventory check | `Modules/ComponentInventoryCheckModule.bas` | Component verification |
|
||||
|
||||
## CODE MAP
|
||||
|
||||
| Symbol | Type | Location | Role |
|
||||
|--------|------|----------|------|
|
||||
| `ProcessProductModels()` | Sub | `MainModule.bas` | Main entry point |
|
||||
| `ExtractBom()` | Function | `BomExtractor.cls` | Core matching logic |
|
||||
| `Parse()` | Function | `ProductModelParser.cls` | Model string parser |
|
||||
| `Evaluate()` | Function | `ConditionEvaluator.cls` | Condition evaluator |
|
||||
| `LoadFromRow()` | Sub | `BomItem.cls` | Row data loader |
|
||||
|
||||
## CONVENTIONS
|
||||
|
||||
### Module Organization
|
||||
- **ClassModules**: `*.cls` files with `Option Explicit`, public methods, private state
|
||||
- **Modules**: `*.bas` files with public subs, helper functions
|
||||
- **DocumentModules**: Sheet-specific event handlers (e.g., `Sheet9.cls`)
|
||||
|
||||
### Error Handling Pattern
|
||||
```vba
|
||||
On Error GoTo ErrorHandler
|
||||
' ... logic ...
|
||||
Exit Sub
|
||||
ErrorHandler:
|
||||
' Handle error
|
||||
```
|
||||
|
||||
### Data Loading
|
||||
- `BomExtractor.LoadBomData()` starts at row 4 (row 3 is header)
|
||||
- `BomItem.LoadFromRow()` uses `On Error Resume Next` for type conversions
|
||||
|
||||
## ANTI-PATTERNS (THIS PROJECT)
|
||||
|
||||
- **NEVER** change row indexing in `LoadBomData()` — hardcoded to start at row 4
|
||||
- **NEVER** reorder `BomItem` fields — column mapping is hardcoded (11 fields)
|
||||
- **NEVER** remove `On Error Resume Next` in `LoadFromRow()` — handles type conversion
|
||||
- **NEVER** bypass `ApplyAssemblyLogic()` — parent/child override is critical
|
||||
- **NEVER** hardcode workbook names — always use `ThisWorkbook`
|
||||
|
||||
## UNIQUE STYLES
|
||||
|
||||
### Assembly Logic (总成逻辑)
|
||||
Parent category overrides children if:
|
||||
1. Parent matches exactly 1 item
|
||||
2. All children match at least 1 item
|
||||
3. Result: parent output, children hidden
|
||||
|
||||
### Batch Output Pattern
|
||||
```vba
|
||||
' Collect in Collection
|
||||
' Convert to 2D array
|
||||
' Single Range.Value write
|
||||
```
|
||||
|
||||
### Condition Syntax
|
||||
- Format: `"field=value|field2=value2"` (pipe = OR)
|
||||
- Example: `"azxs=M|azxs=L"` (vertical OR horizontal installation)
|
||||
|
||||
## NOTES
|
||||
|
||||
### Scripting.Dictionary Dependency
|
||||
All classes use `CreateObject("Scripting.Dictionary")` - Windows only, not Mac-compatible.
|
||||
|
||||
### Workbook Sheets Required
|
||||
- `产品订单` - Input orders
|
||||
- `平台配置清单` - BOM configuration (starts at row 4)
|
||||
- `BOM 提取结果` - Auto-created output
|
||||
Reference in New Issue
Block a user