openlark-api
npx skills add https://github.com/foxzool/open-lark --skill openlark-api
Agent 安装分布
Skill 文档
OpenLark API æ¥å£å®ç°è§èï¼éæ¥ï¼
ð§ æè½è·¯ç±æå
æ¬æè½éç¨åºæ¯ï¼
- æ·»å /éæå个é£ä¹¦å¼æ¾å¹³å° API
- éè¦ç¡®å® API è½çè·¯å¾ï¼bizTag â crate â æä»¶è·¯å¾ï¼
- éè¦åèä»£ç æ¨¡æ¿ï¼Body/Response + Builderï¼
- éè¦äºè§£ç«¯ç¹è§èãRequestOption 约å®ãService é¾å¼è°ç¨
å ¶ä»æè½ï¼
- å®¡æ¥æ´ä½è®¾è®¡è§è â
Skill(openlark-design-review) - ç»ä¸
validate()åæ³ âSkill(openlark-validation-style)
æ¬æä»¶åªä¿ç”坿§è¡çæå°æµç¨”ï¼æ å示ä¾ä¸ docPath æåè½åè§ references/ ä¸ scripts/ã
0. å¿«é工使µï¼æ°å¢ä¸ä¸ª APIï¼
- å®ä½ APIï¼å¨
./api_list_export.csvæ¿å°bizTagãmeta.Projectãmeta.Versionãmeta.Resourceãmeta.Name- è¥æ
docPathï¼ç¨èæ¬æå请æ±/ååºä½å®ä¹ï¼è§ §4ï¼
- è¥æ
- é crateï¼æ ¹æ® bizTag éæ© feature crateï¼è§ §1ï¼
- å®è·¯å¾ï¼
crates/{crate}/src/{bizTag}/{project}/{version}/{resource...}/{name}.rs - å代ç ï¼
Body/Response+ Builderï¼execute/sendï¼+ 端ç¹å¸¸é/enum- å¿
é¡»æ¯æ RequestOptionï¼ç¨äº
user_access_token/tenant_key/ èªå®ä¹ header
- å¿
é¡»æ¯æ RequestOptionï¼ç¨äº
- 补导åºï¼å¨
mod.rsä¸pub mod .../pub use ... - è¡¥é¾è·¯ï¼å¨çº¦å®å
¥å£è¡¥é½é¾å¼è°ç¨ï¼é»è®¤
service.rsï¼ä½openlark-docsä¾å¤ï¼è§ §2ï¼ - éªè¯ï¼
just fmt && just lint && just test
1. Feature Crate â bizTag
ä»åºä»¥ tools/api_coverage.toml ä½ä¸º crateâbizTag çå¯ä¸æ¥æºã
# æ¥çæææ å°
python3 tools/validate_apis.py --list-crates
# éªè¯ç¹å® crate çè¦çç
python3 tools/validate_apis.py --crate openlark-docs
忥æå·§ï¼è½çè·¯å¾ä»¥”ç®æ crate ç°æç»æ”为åï¼åè references/file-layout.md
2. Service é¾å¼è°ç¨ï¼å®ç° + è°ç¨çº¦å®ï¼
æ¬èæä¾”å¦ä½å®ç°”çææ¯è§èãè¥éè¦å®¡æ¥”æ¯å¦åºè¯¥ç»ä¸èå¼”ï¼Request èªæ Config vs Builder â Serviceï¼ï¼è§
Skill(openlark-design-review) §1ã
2.1 å®ç°ä¾§ï¼service.rs
ç®æ ï¼è®© openlark-client è½èµ° client.<biz>.service().<project>().<version>()...<api>()
- è¥ crate å·²æ
src/service.rsï¼å¨é¡¶å± service æ°å¢pub fn {bizTag}(&self) -> ... - è¥æ²¡æï¼å建
src/service.rså¹¶å¨lib.rsä¸pub mod service; openlark-docsç¹ä¾ï¼ä¸ºé¿å strict API æ ¡éªèæ¬æ”é¾å¼å ¥å£”计为 API å®ç°æä»¶ï¼é¾å¼å ¥å£æ¾å¨crates/openlark-docs/src/common/chain.rsï¼åªå模åçº§å ¥å£ä¸ Config éä¼ ï¼ä¸ä¸º 200+ API æåæ¹æ³ã
â ï¸ Service 屿 忍¡å¼
æ£ç¡®ç¤ºä¾ï¼åè openlark-docs/src/common/chain.rsï¼ï¼
use std::sync::Arc;
use openlark_core::config::Config;
/// DocClient åªææ Arc<Config>
#[derive(Debug, Clone)]
pub struct DocClient {
config: Arc<Config>,
}
impl DocClient {
pub fn new(config: Config) -> Self {
Self { config: Arc::new(config) }
}
/// å Service åªéä¼ Arc<Config>
pub fn drive(&self) -> DriveService {
DriveService::new(self.config.clone())
}
}
/// Service å±åªææ Arc<Config>ï¼ä¸ææç¬ç« HTTP client
#[derive(Debug, Clone)]
pub struct DriveService {
config: Arc<Config>,
}
impl DriveService {
pub fn new(config: Arc<Config>) -> Self {
Self { config }
}
pub fn v1(&self) -> DriveV1 {
DriveV1::new(self.config.clone())
}
}
â ç¦æ¢æ¨¡å¼ï¼
- â Service ææç¬ç«ç HTTP client åæ®µ
- â 使ç¨
LarkClientä½ä¸ºå ·ä½ç±»åï¼å®æ¯ traitï¼ - â 卿µè¯ä¸ä½¿ç¨
.unwrap()è°ç¨Config::build()ï¼build() ç´æ¥è¿å Configï¼
â æ£ç¡®æ¨¡å¼ï¼
- â
Service åªææ
Arc<Config> - â
Config::build()ç´æ¥è¿åConfigï¼ä¸éè¦.unwrap() - â
HTTP ä¼ è¾ç±
openlark_core::Transportå¤ç
2.2 è°ç¨ä¾§ï¼RequestOption 约å®
å¿
é¡»æä¾ execute_with_options(..., RequestOption) æçä»·ç¾åï¼å¹¶å° option éä¼ å° Transport::request(..., Some(option))
使ç¨åºæ¯ï¼
- ç¨æ·æ API â
user_access_token - ååºåºç¨ â
tenant_key/app_ticket - é¾è·¯è¿½è¸ª â
request_id/ èªå®ä¹ header
â ï¸ ä¸è¦åªè°ç¨
ApiRequest::request_option(...)ï¼å®ä» åå¹¶ headerï¼token æ¨æéè¦èµ° Transport
详ç»ç¤ºä¾è§ references/standard-example.md
3. API 模æ¿ï¼ä»¥ä»åºç°æé£æ ¼ä¸ºåï¼
以䏿ä¾ä¸¤ç§ä»åºä¸çå®åå¨ç飿 ¼ãå®ç°æ¶ä¼å æ¨¡ä»¿ç®æ crate çç°ææä»¶é£æ ¼ï¼é¿å å¨åä¸ project/version å æ··ç¨å¤ç§èå¼ã
èå¼ä¸è´æ§å®¡æ¥è§
Skill(openlark-design-review) §1ã
3.1 Request / Response
use openlark_core::{api::ApiRequest, config::Config, http::Transport, SDKResult};
use openlark_core::req_option::RequestOption;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct {Name}Body {
// åæ®µæå®æ¹ææ¡£ï¼ç¨ serde rename 对é½
// å¯éï¼Option<T> + #[serde(skip_serializing_if = "Option::is_none")]
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct {Name}Response {
// åæ®µæå®æ¹ææ¡£
}
3.2 Builder + execute/send
use std::sync::Arc;
pub struct {Name}Request {
config: Arc<Config>,
// è·¯å¾/æ¥è¯¢åæ°ï¼æéï¼
}
impl {Name}Request {
pub fn new(config: Arc<Config>) -> Self { /* ... */ }
pub async fn execute(self, body: {Name}Body) -> SDKResult<{Name}Response> {
self.execute_with_options(body, RequestOption::default()).await
}
pub async fn execute_with_options(
self,
body: {Name}Body,
option: RequestOption,
) -> SDKResult<{Name}Response> {
// 端ç¹å¿
é¡»å¤ç¨ crate ç endpoints å¸¸éæ enumï¼ç¦æ¢æå "/open-apis/..."ï¼
let req: ApiRequest<{Name}Response> = ApiRequest::post({ENDPOINT_CONST_OR_ENUM});
let resp = Transport::request(req, &self.config, Some(option)).await?;
resp.data.ok_or_else(|| openlark_core::error::validation_error("ååºæ°æ®ä¸ºç©º", "æå¡å¨æ²¡æè¿åææçæ°æ®"))
}
}
4. æäº¤åæ£æ¥æ¸ å
- è½çè·¯å¾æ£ç¡®ï¼ä¸å模åç°æç»æä¸è´ï¼
- Request/Response åæ®µå¯¹é½å®æ¹ææ¡£ï¼å«
serde(rename)ï¼ - HTTP æ¹æ³ä¸
urlä¸è´ï¼ç«¯ç¹ä½¿ç¨å¸¸éæ enum -
mod.rså·²å¯¼åº -
service.rså·²æä¾é¾å¼è®¿é® - å·²æä¾
execute_with_options(..., RequestOption)å¹¶éä¼ å° Transport -
just fmt && just lint && just testéè¿
5. docPath ç½é¡µè¯»å
python3 .claude/skills/openlark-api/scripts/fetch_docpath.py "<docPath>" --format md --out /tmp/doc.md
6. References
- ç®å½è§èä¸åæ¥ï¼
references/file-layout.md - CSV æ å°è§åï¼
references/csv-mapping.md - æ å示ä¾ï¼ç
§æç»æï¼ï¼
references/standard-example.md