skills-experimental/fixed-size-circular-buffer/SKILL.md
# Fixed-Size Circular Buffer Skill Fixed-Size Circular Buffer - CircularBuffer class + modulo arithmetic + head pointer + size tracking + add/getRecent/toArray + capacity fixed + oldest evict + rolling window + capacity constructor + buffer array。 ## 功能概述 从Claude Code的utils/CircularBuffer.ts提取的Fixed-size circular buffer模式,用于OpenClaw的滚动窗口数据存储。 ## 核心机制 ### CircularBuffer Class ```typescript export class CircularBuffer<T> { private buffer: T[] private head = 0 private size = 0 constr
npx skillsauth add bianhaifeng789-hue/openclaw-config skills-experimental/fixed-size-circular-bufferInstall 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.
Fixed-Size Circular Buffer - CircularBuffer class + modulo arithmetic + head pointer + size tracking + add/getRecent/toArray + capacity fixed + oldest evict + rolling window + capacity constructor + buffer array。
从Claude Code的utils/CircularBuffer.ts提取的Fixed-size circular buffer模式,用于OpenClaw的滚动窗口数据存储。
export class CircularBuffer<T> {
private buffer: T[]
private head = 0
private size = 0
constructor(private capacity: number) {
this.buffer = new Array(capacity)
}
// Fixed-size circular buffer
// Automatically evicts oldest when full
}
this.head = (this.head + 1) % this.capacity
// Circular pointer wrapping
// Modulo ensures head stays within [0, capacity-1]
# Wrap around
private head = 0
// Next write position
// Points to where next item will be inserted
# Write position
private size = 0
// Current number of items
// Increases until reaches capacity
# Actual size (<= capacity)
add(item: T): void {
this.buffer[this.head] = item
this.head = (this.head + 1) % this.capacity
if (this.size < this.capacity) {
this.size++
}
}
// Add item at head position
// Advance head with modulo
// Increase size until full
getRecent(count: number): T[] {
const result: T[] = []
const start = this.size < this.capacity ? 0 : this.head
const available = Math.min(count, this.size)
for (let i = 0; i < available; i++) {
const index = (start + this.size - available + i) % this.capacity
result.push(this.buffer[index]!)
}
return result
}
// Get most recent N items
// start: 0 if not full, head if full
# Calculate correct indices
toArray(): T[] {
if (this.size === 0) return []
const result: T[] = []
const start = this.size < this.capacity ? 0 : this.head
for (let i = 0; i < this.size; i++) {
const index = (start + i) % this.capacity
result.push(this.buffer[index]!)
}
return result
}
// Get all items in order (oldest to newest)
// start: 0 if not full, head if full
# Chronological order
constructor(private capacity: number) {
this.buffer = new Array(capacity)
}
// Fixed capacity
// Array pre-allocated
# No resizing
// Automatically evicts the oldest items when the buffer is full
// Overwrites oldest position when head wraps
# No explicit evict logic
# Just overwrite
// Useful for maintaining a rolling window of data
// Recent history tracking
# Rolling window pattern
this.buffer = new Array(capacity)
// Pre-allocated array
// No dynamic resizing
# Fixed allocation
const start = this.size < this.capacity ? 0 : this.head
// Not full: start from 0 (oldest at index 0)
// Full: start from head (oldest at head position)
# Different logic based on fullness
{
"capacity": 100,
"size": 50,
"head": 50,
"items": ["item1", "item2"]
}
head = (head + 1) % capacity → wrap around → circular → no overflow
# modulo确保pointer wrap
# 不会overflow
# circular loop
buffer[head] = item → head advances → wraps → overwrites oldest → automatic evict
# 写入head位置
# head advance
# wrap时覆盖oldest
# 自动evict
size < capacity: start=0 | size == capacity: start=head → different oldest position
# 未满: oldest在index 0
# 已满: oldest在head position
# 不同逻辑
toArray(): oldest to newest → start + i % capacity → chronological order → not reverse
# toArray oldest→newest顺序
# 按时间顺序排列
# 不是reverse
new Array(capacity) → pre-allocated → no resizing → fixed size → no dynamic allocation
# 预分配array
# 不resize
# 固定size
# 无动态allocation
utils/CircularBuffer.ts (84 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