skills-experimental/entrypoint-truncation-pattern/SKILL.md
# Entrypoint Truncation Pattern Skill Entrypoint Truncation Pattern - MAX_ENTRYPOINT_LINES=200 + MAX_ENTRYPOINT_BYTES=25000 + Line AND Byte caps + truncateEntrypointContent + Line-truncates first + Byte-truncates at newline。 ## 功能概述 从Claude Code的memdir/memdir.ts提取的截断模式,用于OpenClaw的文件大小限制。 ## 核心机制 ### MAX_ENTRYPOINT_LINES ```typescript export const ENTRYPOINT_NAME = 'MEMORY.md' export const MAX_ENTRYPOINT_LINES = 200 // ~125 chars/line at 200 lines // Line cap for entrypoint ``` ### MAX_ENT
npx skillsauth add bianhaifeng789-hue/openclaw-config skills-experimental/entrypoint-truncation-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.
Entrypoint Truncation Pattern - MAX_ENTRYPOINT_LINES=200 + MAX_ENTRYPOINT_BYTES=25000 + Line AND Byte caps + truncateEntrypointContent + Line-truncates first + Byte-truncates at newline。
从Claude Code的memdir/memdir.ts提取的截断模式,用于OpenClaw的文件大小限制。
export const ENTRYPOINT_NAME = 'MEMORY.md'
export const MAX_ENTRYPOINT_LINES = 200
// ~125 chars/line at 200 lines
// Line cap for entrypoint
export const MAX_ENTRYPOINT_BYTES = 25_000
// ~125 chars/line at 200 lines. At p97 today; catches long-line indexes
// that slip past the line cap (p100 observed: 197KB under 200 lines).
// Byte cap catches long-line indexes
// p97 threshold
// p100: 197KB under 200 lines (long lines)
export type EntrypointTruncation = {
content: string
lineCount: number
byteCount: number
wasLineTruncated: boolean
wasByteTruncated: boolean
}
// Truncation result with flags
# Track both line and byte truncation
# Report which cap fired
/**
* Truncate MEMORY.md content to the line AND byte caps, appending a warning
* that names which cap fired. Line-truncates first (natural boundary), then
* byte-truncates at the last newline before the cap so we don't cut mid-line.
*/
export function truncateEntrypointContent(raw: string): EntrypointTruncation {
const trimmed = raw.trim()
const contentLines = trimmed.split('\n')
const lineCount = contentLines.length
const byteCount = trimmed.length
const wasLineTruncated = lineCount > MAX_ENTRYPOINT_LINES
// Check original byte count — long lines are failure mode the byte cap targets
const wasByteTruncated = byteCount > MAX_ENTRYPOINT_BYTES
if (!wasLineTruncated && !wasByteTruncated) {
return {
content: trimmed,
lineCount,
byteCount,
wasLineTruncated,
wasByteTruncated,
}
}
let truncated = wasLineTruncated
? contentLines.slice(0, MAX_ENTRYPOINT_LINES).join('\n')
: trimmed
// Byte truncation at last newline before cap
if (truncated.length > MAX_ENTRYPOINT_BYTES) {
const lastNewlineBeforeCap = truncated.lastIndexOf(
'\n',
MAX_ENTRYPOINT_BYTES,
)
truncated = truncated.slice(0, lastNewlineBeforeCap)
}
// Append warning naming which cap fired
const warning = wasLineTruncated
? `\n\n[⚠️ Truncated at ${MAX_ENTRYPOINT_LINES} lines]`
: `\n\n[⚠️ Truncated at ${MAX_ENTRYPOINT_BYTES / 1000}KB]`
return {
content: truncated + warning,
lineCount: truncated.split('\n').length,
byteCount: truncated.length,
wasLineTruncated,
wasByteTruncated,
}
}
// Line-truncates first (natural boundary)
// Byte-truncates at last newline before cap
// Don't cut mid-line
// Warning naming which cap fired
// Line-truncates first (natural boundary), then byte-truncates at the
# last newline before the cap so we don't cut mid-line.
// Order: Line → Byte
# Natural boundary first
# Avoid mid-line cut
const lastNewlineBeforeCap = truncated.lastIndexOf('\n', MAX_ENTRYPOINT_BYTES)
truncated = truncated.slice(0, lastNewlineBeforeCap)
// Find last newline before byte cap
// Slice at newline position
# Complete lines only
const warning = wasLineTruncated
? `\n\n[⚠️ Truncated at ${MAX_ENTRYPOINT_LINES} lines]`
: `\n\n[⚠️ Truncated at ${MAX_ENTRYPOINT_BYTES / 1000}KB]`
// Warning names which cap fired
// Line: "Truncated at 200 lines"
// Byte: "Truncated at 25KB"
{
"maxLines": 200,
"maxBytes": 25000,
"lineTruncated": false,
"byteTruncated": false
}
MAX_ENTRYPOINT_LINES=200 + MAX_ENTRYPOINT_BYTES=25000 → both caps enforced
// 双重限制
// Line限制自然边界
// Byte限制长行index
Line-truncates first → natural boundary → then byte-truncates → last newline
// 先Line截断(自然边界)
// 后Byte截断(last newline)
// 不在行中间cut
lastIndexOf('\n', MAX_ENTRYPOINT_BYTES) → slice at newline → complete lines
// 在byte cap前找最后一个newline
// 在newline位置截断
// 保证完整行
[⚠️ Truncated at 200 lines] OR [⚠️ Truncated at 25KB] → user knows which cap
// Warning明确说明哪个cap触发了
// 用户知道原因
memdir/memdir.tsbusiness
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