generate-interface-uml
npx skills add https://github.com/openharmonyinsight/openharmony-skills --skill generate-interface-uml
Agent 安装分布
Skill 文档
Interface UML Generator
This skill helps generate PlantUML sequence diagrams and class diagrams for new interfaces, based on existing similar interfaces in the codebase.
When to Use
User wants to create UML diagrams (sequence diagrams, class diagrams) for:
- New API interfaces
- New method implementations
- Interface call chains
- IPC communication flows
Workflow
Step 1: Gather Basic Information
Start with what the user provides (often just an interface name), then ask questions to collect:
Essential Information:
- Interface name(s) – e.g.,
AddGlocalBlackList,RemoveGlocalBlackList - Parameters – What are the input parameters and their types?
- Return type – What does the interface return?
- Reference interface – Is there an existing similar interface to use as a template?
Optional Information (ask if needed): 5. Output directory – Where should the PlantUML files be saved? 6. Diagram types – Sequence diagram? Class diagram? Both? 7. Call chain destination – Which class/method does it ultimately call?
Step 2: Analyze Reference Interface
Search the codebase for the reference interface to understand the call chain:
# Find the reference interface implementation
grep -r "SetFocusAppInfo" --include="*.h" --include="*.cpp"
Key files to examine:
- Client-side interfaces:
RSInterfaces,RSRenderInterface - IPC layer:
RSIClientToRenderConnection,RSClientToRenderConnection - Service-side:
RSRenderPipelineAgent,RSMainThread - Target class: Where the interface ultimately executes
Step 3: Generate PlantUML Diagrams
Sequence Diagram Template
@startuml InterfaceNameåºåå¾
title InterfaceName æ¥å£è°ç¨æ¶åºå¾
autonumber
skinparam maxMessageSize 150
skinparam boxPadding 10
actor "客æ·ç«¯åºç¨" as Client
box "客æ·ç«¯è¿ç¨ (Client Process)" #LightBlue
participant "RSInterfaces" as RSInterfaces
participant "RSRenderInterface" as RSRenderInterface
participant "RSRenderPipelineClient\n(IPC Proxy)" as IPCProxy
end box
box "è·¨è¿ç¨éä¿¡ (IPC)" #LightYellow
participant "Binder/Hipc\néä¿¡éé" as Binder
end box
box "æå¡ç«¯è¿ç¨ (Render Service)" #LightGreen
participant "RSClientToRenderConnection\n(IPC Stub)" as IPCStub
participant "RSRenderPipelineAgent" as Agent
participant "RSMainThread" as MainThread
participant "TargetClass\n(å¨RSMainThread线ç¨ä¸æ§è¡)" as Target
end box
== 客æ·ç«¯è°ç¨æµç¨ ==
Client -> RSInterfaces: InterfaceName(params)
activate RSInterfaces
RSInterfaces -> RSRenderInterface: InterfaceName(params)
activate RSRenderInterface
RSRenderInterface -> IPCProxy: InterfaceName(params)
activate IPCProxy
== è·¨è¿ç¨IPCè°ç¨ ==
IPCProxy -> Binder: IPCè°ç¨\nInterfaceName
activate Binder
Binder -> IPCStub: æ¥æ¶IPCè°ç¨\nInterfaceName
activate IPCStub
== æå¡ç«¯å¤çæµç¨ ==
IPCStub -> Agent: InterfaceName(params)
activate Agent
Agent -> Agent: ScheduleMainThreadTask(\nlambdaä»»å¡)
Agent -> MainThread: PostTask(\næ§è¡InterfaceName)
activate MainThread
MainThread -> Target: TargetMethod(params)
activate Target
note right of Target
æè¿°å
·ä½æä½
end note
Target --> MainThread: è¿å
deactivate Target
MainThread --> Agent: ä»»å¡å®æ
deactivate MainThread
Agent --> IPCStub: è¿åç»æ\n(ERR_OK)
deactivate Agent
IPCStub --> Binder: è¿åIPCç»æ
deactivate IPCStub
Binder --> IPCProxy: è¿åIPCç»æ
deactivate Binder
IPCProxy --> RSRenderInterface: è¿åç»æ
deactivate IPCProxy
RSRenderInterface --> RSInterfaces: è¿åç»æ
deactivate RSRenderInterface
RSInterfaces --> Client: è¿åç»æ
deactivate RSInterfaces
@enduml
Class Diagram Template
@startuml InterfaceNameç±»å¾
title InterfaceNameç³»åæ¥å£æ¶åçç±»å
³ç³»å¾
skinparam classAttributeIconSize 0
skinparam class {
BackgroundColor<<client>> LightBlue
BackgroundColor<<service>> LightGreen
BackgroundColor<<static>> LightYellow
BorderColor Black
}
package "客æ·ç«¯ (Client)" <<client>> {
class RSInterfaces {
+ {static} GetInstance(): RSInterfaces&
+ InterfaceName(params): ReturnType
--
- renderInterface_: RSRenderInterface*
}
class RSRenderInterface {
+ InterfaceName(params): ReturnType
--
- renderPipelineClient_: RSRenderPipelineClient*
}
RSInterfaces --> RSRenderInterface
}
package "IPCéä¿¡å±" {
interface RSIClientToRenderConnection {
+ InterfaceName(params, ErrorCode&): ErrCode
}
class RSClientToRenderConnection {
+ InterfaceName(params, ErrorCode&): ErrCode
--
- renderPipelineAgent_: sptr<RSRenderPipelineAgent>
}
RSClientToRenderConnection ..|> RSIClientToRenderConnection
}
package "æå¡ç«¯ (Render Service)" <<service>> {
class RSRenderPipelineAgent {
+ InterfaceName(params, ErrorCode&): ErrCode
--
- rsRenderPipeline_: std::shared_ptr<RSRenderPipeline>
}
class RSMainThread {
+ PostTask(RSTask): void
+ ScheduleTask(Task): std::future<Return>
--
- mainThreadId_: std::thread::id
}
}
package "TargetClass (éæç±»)" <<static>> {
class TargetClass {
+ {static} TargetMethod(params): void
--
- {static} member_: Type
}
}
RSRenderInterface --> RSIClientToRenderConnection: éè¿IPCè°ç¨
RSClientToRenderConnection --> RSRenderPipelineAgent
RSRenderPipelineAgent ..> RSMainThread: ScheduleMainThreadTask
RSRenderPipelineAgent ..> TargetClass: è°ç¨éææ¹æ³
@enduml
Step 4: Save PlantUML Files
Write the generated PlantUML files to the specified directory:
- Use descriptive filenames:
InterfaceName_sequence.puml,InterfaceName_ClassDiagram.puml - Include UTF-8 BOM for Chinese character support if needed
- Save to user-specified output directory
Step 5: Optional – Create Comparison Diagram
If comparing with existing interfaces, create a comparison diagram showing:
- Parameter differences
- Call chain differences
- Target class differences
Questions to Ask User
- Interface names: What are the interface names you want to generate UML for?
- Reference interface: Which existing interface should be used as a reference?
- Parameters: What are the parameter types for the new interface(s)?
- Return type: What should the interface return?
- Target class: Which class does the interface ultimately call? (e.g., ScreenSpecialLayerInfo, RSMainThread)
- Thread requirement: Does it need to execute in a specific thread? (e.g., RSMainThread thread)
- Output directory: Where should the PlantUML files be saved?
Example Usage
User provides:
Generate UML for AddGlocalBlackList, RemoveGlocalBlackList, SetGlocalBlackList
Ask follow-up questions:
- “What should be the parameter type?” â
const std::vector<NodeId>& - “Which existing interface is similar?” â
SetFocusAppInfo - “Which class does it ultimately call?” â
ScreenSpecialLayerInfo - “What’s the output directory?” â Current code directory
Generate output:
AddGlocalBlackList_sequence.pumlRemoveGlocalBlackList_sequence.pumlSetGlocalBlackList_sequence.pumlInterfaceName_ClassDiagram.puml
Tips
- Use Chinese for diagram titles and notes if the codebase uses Chinese
- Include
autonumberfor sequence diagrams - Use color coding to distinguish client/service/static layers
- Add notes to explain key operations
- Group related steps with
== Section Name ==