sno-ai/sno-station-skills / skills/R-recursive-self-improvement/rem-reflect/skill
rem-reflect
VerifiedSelf Learning from this machine's Claude Code, Codex, Hermes, OpenClaw and Cursor sessions. Decide skill changes and lessons with accept/reject/tbd; recall lessons at session start.
scripts/chunk.ts
View on GitHubimport { limits } from './config.ts';
import type { Rendering, RenderedRecord } from './render.ts';
export interface Chunk {
id: string;
trace_id: string;
index: number;
total: number;
line_range: [number, number];
oversized: boolean;
header: string;
body: string;
text: string;
}
export function chunkRendering(traceId: string, rendering: Rendering, size: number = limits.chunkCharacters): Chunk[] {
if (!Number.isInteger(size) || size <= 0) throw new Error('chunk size must be a positive integer');
const groups: RenderedRecord[][] = [];
let group: RenderedRecord[] = [];
let length = 0;
for (const record of rendering.records) {
if (group.length && length + record.text.length > size) {
groups.push(group); group = []; length = 0;
}
group.push(record); length += record.text.length;
if (length > size) { groups.push(group); group = []; length = 0; }
}
if (group.length || groups.length === 0) groups.push(group);
const chunks = groups.map((records, index): Chunk => {
const body = records.map(record => record.text).join('');
const line_range: [number, number] = [records[0]?.line_number ?? 0, records.at(-1)?.line_number ?? 0];
const oversized = body.length > size;
const header = `${traceId} chunk ${index + 1} of ${groups.length} lines ${line_range[0]}-${line_range[1]}${oversized ? ' oversized' : ''}`;
return { id: `${traceId}#${index + 1}`, trace_id: traceId, index: index + 1, total: groups.length,
line_range, oversized, header, body, text: `${header}\n${body}` };
});
if (chunks.map(chunk => chunk.body).join('') !== rendering.body) throw new Error('rendering body does not match its records');
return chunks;
}
export function reassembleChunks(chunks: readonly Chunk[]): string {
for (const [index, chunk] of chunks.entries()) {
if (chunk.index !== index + 1 || chunk.total !== chunks.length || chunk.trace_id !== chunks[0]?.trace_id) {
throw new Error('chunks must be complete, in order, and from one trace');
}
}
return chunks.map(chunk => chunk.text.slice(chunk.text.indexOf('\n') + 1)).join('');
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Unverified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |