skills-experimental/auto-mode-circuit-breaker-pattern/SKILL.md
# Auto Mode Circuit Breaker Pattern Skill Auto Mode Circuit Breaker Pattern - verifyAutoModeGateAccess async check + getDynamicConfig_BLOCKS_ON_INIT enabled/disabled/opt-in + setAutoModeCircuitBroken kick-out + isAutoModeGateEnabled sync check + getAutoModeEnabledStateIfCached cold start + kickOutOfAutoIfNeeded transform function + carouselAvailable vs canEnterAuto + hasAutoModeOptInAnySource + modelSupportsAutoMode + disableFastMode breaker。 ## 功能概述 从Claude Code的utils/permissions/permissionS
npx skillsauth add bianhaifeng789-hue/openclaw-config skills-experimental/auto-mode-circuit-breaker-patternInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Auto Mode Circuit Breaker Pattern - verifyAutoModeGateAccess async check + getDynamicConfig_BLOCKS_ON_INIT enabled/disabled/opt-in + setAutoModeCircuitBroken kick-out + isAutoModeGateEnabled sync check + getAutoModeEnabledStateIfCached cold start + kickOutOfAutoIfNeeded transform function + carouselAvailable vs canEnterAuto + hasAutoModeOptInAnySource + modelSupportsAutoMode + disableFastMode breaker。
从Claude Code的utils/permissions/permissionSetup.ts提取的Auto mode circuit breaker模式,用于OpenClaw的auto mode门控管理。
export async function verifyAutoModeGateAccess(
currentContext: ToolPermissionContext,
fastMode?: boolean,
): Promise<AutoModeGateCheckResult> {
// Fresh read of tengu_auto_mode_config.enabled — this async check runs once
// after GrowthBook initialization and is the authoritative source
const autoModeConfig = await getDynamicConfig_BLOCKS_ON_INIT<{
enabled?: AutoModeEnabledState
disableFastMode?: boolean
}>('tengu_auto_mode_config', {})
const enabledState = parseAutoModeEnabledState(autoModeConfig?.enabled)
// ...
}
// verifyAutoModeGateAccess
# Async check
# GrowthBook fresh read
# Authoritative source
const autoModeConfig = await getDynamicConfig_BLOCKS_ON_INIT<{
enabled?: AutoModeEnabledState
disableFastMode?: boolean
}>('tengu_auto_mode_config', {})
// AutoModeEnabledState: 'enabled' | 'disabled' | 'opt-in'
// 'enabled': available in carousel
// 'disabled': circuit breaker, fully unavailable
// 'opt-in': available only if user opted in
// getDynamicConfig_BLOCKS_ON_INIT
# enabled/disabled/opt-in
# Circuit breaker: 'disabled'
# Opt-in required
// Circuit breaker (enabled==='disabled') takes effect here.
autoModeStateModule?.setAutoModeCircuitBroken(
enabledState === 'disabled' || disabledBySettings,
)
// setAutoModeCircuitBroken
# enabled==='disabled' → true
# disabledBySettings → true
# Kick-out detection
export function isAutoModeGateEnabled(): boolean {
if (autoModeStateModule?.isAutoModeCircuitBroken() ?? false) return false
if (isAutoModeDisabledBySettings()) return false
if (!modelSupportsAutoMode(getMainLoopModel())) return false
return true
}
// isAutoModeGateEnabled
# Sync check
# Circuit breaker
# Settings disable
# Model support
/**
* Like getAutoModeEnabledState but returns undefined when no cached value
* exists (cold start, before GrowthBook init). Used by the sync
* circuit-breaker check in initialPermissionModeFromCLI, which must not
* conflate "not yet fetched" with "fetched and disabled" — the former
* defers to verifyAutoModeGateAccess, the latter blocks immediately.
*/
export function getAutoModeEnabledStateIfCached(): AutoModeEnabledState | undefined {
const config = getFeatureValue_CACHED_MAY_BE_STALE<
{ enabled?: AutoModeEnabledState } | typeof NO_CACHED_AUTO_MODE_CONFIG
>('tengu_auto_mode_config', NO_CACHED_AUTO_MODE_CONFIG)
if (config === NO_CACHED_AUTO_MODE_CONFIG) return undefined
return parseAutoModeEnabledState(config?.enabled)
}
// getAutoModeEnabledStateIfCached
# undefined on cold start
# Not conflated with 'disabled'
# defer to async check
/**
* Unified kick-out transform. Re-checks the FRESH ctx and only fires
* side effects when the kick-out actually applies.
*/
const kickOutOfAutoIfNeeded = (ctx: ToolPermissionContext): ToolPermissionContext => {
const inAuto = ctx.mode === 'auto'
if (!inAuto && !inPlanWithAutoActive) {
return setAvailable(ctx, false)
}
if (inAuto) {
autoModeStateModule?.setAutoModeActive(false)
setNeedsAutoModeExitAttachment(true)
return {
...applyPermissionUpdate(restoreDangerousPermissions(ctx), {
type: 'setMode',
mode: 'default',
destination: 'session',
}),
isAutoModeAvailable: false,
}
}
// ...
}
// kickOutOfAutoIfNeeded
# Transform function
# Re-check fresh ctx
# Fire side effects
// Carousel availability: not circuit-broken, not disabled-by-settings,
// model supports it, disableFastMode breaker not firing, and (enabled or opted-in)
let carouselAvailable = false
if (enabledState !== 'disabled' && !disabledBySettings && modelSupported) {
carouselAvailable = enabledState === 'enabled' || hasAutoModeOptInAnySource()
}
// canEnterAuto gates explicit entry (--permission-mode auto, defaultMode: auto)
// — explicit entry IS an opt-in, so we only block on circuit breaker + settings + model
const canEnterAuto = enabledState !== 'disabled' && !disabledBySettings && modelSupported
// carouselAvailable vs canEnterAuto
# Carousel: enabled OR opt-in
# Explicit entry: always opt-in
# Circuit breaker blocks both
export function hasAutoModeOptInAnySource(): boolean {
if (autoModeStateModule?.getAutoModeFlagCli() ?? false) return true
return hasAutoModeOptIn()
}
// hasAutoModeOptInAnySource
# CLI flag --enable-auto-mode
# Settings skipAutoPermissionPrompt
# Any source opt-in
const mainModel = getMainLoopModel()
const modelSupported = modelSupportsAutoMode(mainModel) && !disableFastModeBreakerFires
// modelSupportsAutoMode
# Model capability check
# disableFastMode breaker
# -fast model substring
// Temp circuit breaker: tengu_auto_mode_config.disableFastMode blocks auto
// mode when fast mode is on. Checks runtime AppState.fastMode (if provided)
// and, for ants, model name '-fast' substring (ant-internal fast models
// like capybara-v2-fast[1m] encode speed in the model ID itself).
const disableFastModeBreakerFires =
!!autoModeConfig?.disableFastMode &&
(!!fastMode ||
(process.env.USER_TYPE === 'ant' &&
mainModel.toLowerCase().includes('-fast')))
// disableFastMode breaker
# autoConfig.disableFastMode
# AppState.fastMode
# -fast model substring
{
"enabledState": "disabled",
"circuitBroken": true,
"canEnterAuto": false,
"carouselAvailable": false
}
getDynamicConfig_BLOCKS_ON_INIT('tengu_auto_mode_config') → await → fresh read → authoritative → async gate check
# async gate check blocks on init
# fresh read
# authoritative source
'enabled' → carousel available | 'disabled' → circuit breaker | 'opt-in' → opt-in required → three states → enabled/disabled/opt-in
# enabled/disabled/opt-in three states
# 'enabled': carousel
# 'disabled': circuit breaker
# 'opt-in': opt-in required
enabled==='disabled' || disabledBySettings → setAutoModeCircuitBroken(true) → isAutoModeCircuitBroken() → block re-entry → kick-out
# circuit breaker kick-out block re-entry
# enabled==='disabled'
# block re-entry
isAutoModeCircuitBroken() || disabledBySettings || !modelSupportsAutoMode → false → sync gate check → multiple conditions
# sync gate check multiple conditions
# circuit breaker
# settings disable
# model support
NO_CACHED_AUTO_MODE_CONFIG → undefined → not conflated with 'disabled' → defer to async check → cold start undefined
# cold start undefined not conflated
# undefined ≠ disabled
# defer to async check
kickOutOfAutoIfNeeded(ctx) → transform function → re-check fresh ctx → fire side effects → ctx.mode === 'auto' → kick-out
# transform function re-check fresh ctx
# transform function
# re-check ctx
# fire side effects
utils/permissions/permissionSetup.ts (771 lines)business
IAA 日报飞书输出能力。 支持把固定 CSV 模板一键转换成: - 中文运营结论 - 飞书卡片 JSON - 飞书发送载荷 Use when: - 需要把 IAA 日报直接发到飞书 - 需要从 CSV 一键生成运营日报
data-ai
IAA日报分析模型 功能: - 渠道日报自动分析 - 小时级+日级ROI联动判断 - 按地区输出加量/降量/停投建议 - 按产品类型输出阈值 - 自动识别利润区/观察区/止损区 Use when: - 分析每天投放数据 - 生成运营日报结论 - 判断是否加量/降量/停投 - 对比美加澳/日韩表现 Keywords: - 日报模型, 投放日报, 加量, 降量, 停投, ROI日报, 分地区分析
data-ai
IAA固定日报分析模板 功能: - 固定字段模板(可直接贴每天数据) - 自动输出总盘结论 - 自动输出美加澳/日韩结论 - 自动给出加量/降量/停投建议 - 适配文件修复/清理两类产品 Use when: - 需要固定日报格式 - 每天复盘渠道表现 - 给运营团队出统一结论 Keywords: - 固定模板, 日报模板, ROI模板, IAA日报, 运营模板
development
# HyperlinkPool Pattern Skill HyperlinkPool Pattern - HyperlinkPool class + strings array + stringMap + Index 0 no hyperlink + intern(hyperlink) + get(id) + undefined handling + 5-minute reset + OSC8 hyperlink interning。 ## 功能概述 从Claude Code的ink/screen.ts提取的HyperlinkPool模式,用于OpenClaw的OSC8超链接池管理。 ## 核心机制 ### HyperlinkPool Class ```typescript export class HyperlinkPool { private strings: string[] = [''] // Index 0 = no hyperlink private stringMap = new Map<string, number>() // strings