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>
3.3 KiB
3.3 KiB
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:
*.clsfiles withOption Explicit, public methods, private state - Modules:
*.basfiles with public subs, helper functions - DocumentModules: Sheet-specific event handlers (e.g.,
Sheet9.cls)
Error Handling Pattern
On Error GoTo ErrorHandler
' ... logic ...
Exit Sub
ErrorHandler:
' Handle error
Data Loading
BomExtractor.LoadBomData()starts at row 4 (row 3 is header)BomItem.LoadFromRow()usesOn Error Resume Nextfor type conversions
ANTI-PATTERNS (THIS PROJECT)
- NEVER change row indexing in
LoadBomData()— hardcoded to start at row 4 - NEVER reorder
BomItemfields — column mapping is hardcoded (11 fields) - NEVER remove
On Error Resume NextinLoadFromRow()— 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:
- Parent matches exactly 1 item
- All children match at least 1 item
- Result: parent output, children hidden
Batch Output Pattern
' 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