feat: 模块化命令框架 + runbook 严格断言与查询结果回传

- core/module: 命令模板、门控(feature flag/confirm/dry-run)、ecode 错误标签、ResultFormatter
- runbook executor: http.get/http.post/assert.json(expect_success 严格断言)、目标主机管理、任务落库、最终 stdout 直接回传
- cf 模块: /cf dns list 支持域名自动解析 zone_id;dns list/zones/workers list 格式化回传;API success:false 判真失败
- 全部 CF/CPA runbook 接入严格断言,杜绝假阳性 success
- 新增 cpa/cfdav/mail/sub 模块与 runbooks;QQ 订阅到期提醒调度
- Web 后台: 模块设置(CF/CPA/cfdav/AI)、OPS 任务、渠道管理、审计页
This commit is contained in:
2026-09-13 07:42:17 +08:00
parent 9085c490f3
commit 81939825d1
86 changed files with 6885 additions and 467 deletions
+16 -1
View File
@@ -33,6 +33,7 @@ func commandSpecs() []coremodule.CommandSpec {
},
DryRunMsg: "🧪 dry-run: 将执行 /cf zones(未实际执行)",
SuccessMsg: func(jobID uint) string { return fmt.Sprintf("✅ /cf zones 已执行,job=%d", jobID) },
ResultFormatter: func(out string) (string, bool) { return FormatZones(out) },
},
ErrPrefix: "/cf zones 执行失败: ",
},
@@ -44,7 +45,19 @@ func commandSpecs() []coremodule.CommandSpec {
if len(parts) < 4 {
return nil, fmt.Errorf(ecode.Tag(ecode.ErrStepFailed, "参数不足,示例:/cf dns list <zone_id>"))
}
return map[string]string{"zone_id": parts[3]}, nil
zoneID := parts[3]
if !isHex32(zoneID) {
acct, tok := cfSettings()
if acct == "" || tok == "" {
return nil, fmt.Errorf(ecode.Tag(ecode.ErrStepFailed, "cf 凭据未配置,无法解析域名;请直接传 zone_id"))
}
resolved, _, err := ResolveZoneIDIfDomain(zoneID, acct, tok)
if err != nil {
return nil, fmt.Errorf(ecode.Tag(ecode.ErrStepFailed, err.Error()))
}
zoneID = resolved
}
return map[string]string{"zone_id": zoneID}, nil
},
Gate: coremodule.Gate{
NeedFlag: "enable_module_cf",
@@ -52,6 +65,7 @@ func commandSpecs() []coremodule.CommandSpec {
},
DryRunMsg: "🧪 dry-run: 将执行 /cf dns list <zone_id>(未实际执行)",
SuccessMsg: func(jobID uint) string { return fmt.Sprintf("✅ /cf dns list 已执行,job=%d", jobID) },
ResultFormatter: func(out string) (string, bool) { return FormatDNSList(out) },
},
ErrPrefix: "/cf dns list 执行失败: ",
ErrHint: "/cf dns list <zone_id>",
@@ -247,6 +261,7 @@ func commandSpecs() []coremodule.CommandSpec {
},
DryRunMsg: "🧪 dry-run: 将执行 /cf workers list(未实际执行)",
SuccessMsg: func(jobID uint) string { return fmt.Sprintf("✅ /cf workers list 已执行,job=%d", jobID) },
ResultFormatter: func(out string) (string, bool) { return FormatWorkers(out) },
},
ErrPrefix: "/cf workers list 执行失败: ",
},