Skip to content

sno-ai/sno-station-skills / skills/R-recursive-self-improvement/rem-reflect/skill

rem-reflect

Verified

Self 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.

FileKindSize
SKILL.mdskill md14.1 KB
references/labeler.mdmarkdown1.2 KB
references/labeler.schema.jsonconfig1.7 KB
references/local-settings.jsonconfig126 B
references/local-writer.schema.jsonconfig2.3 KB
references/proposal.schema.jsonconfig3.2 KB
references/render.jsonconfig245 B
references/signals.jsonconfig71 B
references/text.jsonconfig4.0 KB
scripts/adopt.test.tsscript13.0 KB
scripts/adopt.tsscript14.3 KB
scripts/agent-sessions.tsscript9.1 KB
scripts/allowance-fallback.test.tsscript16.0 KB
scripts/allowance-request-isolation.test.tsscript7.1 KB
scripts/backend.tsscript9.1 KB
scripts/calls.tsscript8.6 KB
scripts/catalogue-cloud.test.tsscript1.5 KB
scripts/catalogue.tsscript3.2 KB
scripts/chunk.tsscript2.1 KB
scripts/cloud-apply.test.tsscript25.2 KB
scripts/cloud-batch.test.tsscript11.2 KB
scripts/cloud-day.test.tsscript6.8 KB
scripts/cloud-verdict.test.tsscript12.1 KB
scripts/cloud-wait.test.tsscript1.3 KB
scripts/cloud.tsscript24.4 KB
scripts/config.tsscript8.1 KB
scripts/cursor.test.tsscript16.1 KB
scripts/cursor.tsscript6.7 KB
scripts/evidence.tsscript1.5 KB
scripts/first-message.test.tsscript10.3 KB
scripts/harvest.test.tsscript16.5 KB
scripts/harvest.tsscript22.6 KB
scripts/hermes-openclaw.test.tsscript25.6 KB
scripts/identity.test.tsscript3.3 KB
scripts/identity.tsscript3.5 KB
scripts/installed-roots.test.tsscript11.0 KB
scripts/journey-adopt-lesson.test.tsscript4.1 KB
scripts/journey-ops.test.tsscript8.0 KB
scripts/labeler.test.tsscript3.6 KB
scripts/labeler.tsscript9.5 KB
scripts/ledger.tsscript2.1 KB
scripts/lessons.tsscript4.7 KB
scripts/local-filter.test.tsscript3.9 KB
scripts/local-first-output.test.tsscript23.5 KB
scripts/local-settings.tsscript1.4 KB
scripts/local-writer.tsscript12.7 KB
scripts/login-in-place.test.tsscript5.8 KB
scripts/model-json.tsscript4.1 KB
scripts/no-network.test.tsscript5.0 KB
scripts/observe.tsscript1.4 KB
scripts/page-journey.test.tsscript6.7 KB
scripts/pages.test.tsscript4.1 KB
scripts/pages.tsscript4.8 KB
scripts/proposer-loop.test.tsscript1.5 KB
scripts/proposer-validate.test.tsscript9.1 KB
scripts/proposer.tsscript8.7 KB
scripts/recall-hook.test.tsscript20.9 KB
scripts/recall.test.tsscript31.4 KB
scripts/recall.tsscript18.2 KB
scripts/reflect.test.tsscript9.3 KB
scripts/reflect.tsscript14.3 KB
scripts/rem-reflectexecutablescript823 B
scripts/rem-reflect.tsscript17.8 KB
scripts/render-chunk.test.tsscript7.2 KB
scripts/render.tsscript9.7 KB
scripts/report.tsscript8.2 KB
scripts/run-status.test.tsscript19.1 KB
scripts/sampling.test.tsscript2.1 KB
scripts/sampling.tsscript915 B
scripts/selftest-guard.test.tsscript4.2 KB
scripts/selftest/bin/claudeexecutablescript94 B
scripts/selftest/bin/codexexecutablescript93 B
scripts/selftest/bin/shim-core.cjsscript4.6 KB
scripts/selftest/bin/snoexecutablescript5.7 KB
scripts/selftest/fixtures/hermes-session-export.jsonlother1.5 KB
scripts/selftest/fixtures/openclaw-events.jsonlother3.7 KB
scripts/selftest/fixtures/verdict-traces.jsonconfig16.6 KB
scripts/selftest/journey-e2e.shexecutablescript1.4 KB
scripts/selftest/journey.mjsscript9.5 KB
scripts/selftest/observe-journey.mjsscript12.5 KB
scripts/selftest/run-selftest.shexecutablescript7.0 KB
scripts/selftest/spawn-python.mjsexecutablescript765 B
scripts/session.test.tsscript5.2 KB
scripts/session.tsscript251 B
scripts/signal-local.test.tsscript7.0 KB
scripts/skill-impact.test.tsscript6.2 KB
scripts/station-settings.test.tsscript13.6 KB
scripts/store-memory.test.tsscript3.4 KB
scripts/store.tsscript7.7 KB
scripts/test-helpers.tsscript15.3 KB
scripts/text.tsscript760 B
scripts/trigger.test.tsscript3.6 KB
scripts/trigger.tsscript2.5 KB
scripts/verdicts.test.tsscript8.1 KB
scripts/verdicts.tsscript8.0 KB

scripts/calls.ts

View on GitHub
import { isObject } from './config.ts';
import { contentText, payload } from './harvest.ts';
import type { StoredRecord, Trace } from './harvest.ts';

export interface CallRecord {
  call_id: string;
  line_start: number;
  line_end: number;
  turn: string | null;
  tool: string;
  target: string | null;
  started_at: string | null;
  ended_at: string | null;
  failed: boolean;
  failure_kind: 'exit_nonzero' | 'tool_error' | 'denied' | 'interrupted' | 'timeout' | 'edit_mismatch' | 'script_error' | 'hook_block' | null;
  exit_code: number | null;
  benign_nonzero: boolean;
  error_excerpt: string | null;
  // The whole command (`target` is cut at 200 characters) and the last 2,000 characters of its result,
  // kept for success and failure alike: external verdicts and trigger conditions are computed from them.
  command_text: string | null;
  result_excerpt: string | null;
}

const head = (value: unknown): string | null => typeof value === 'string' && value ? value.slice(0, 200) : null;
const time = (value: unknown): string | null => typeof value === 'string' ? value : typeof value === 'number' ? new Date(value).toISOString() : null;
const tail = (value: string): string | null => value ? value.slice(-600) : null;
const excerpt = (value: string): string | null => value ? value.slice(-2000) : null;
const text = (value: unknown): string | null => typeof value === 'string' && value ? value : null;
const outputText = (value: unknown): string => Array.isArray(value) ? contentText(value) : typeof value === 'string' ? value : '';

export function readCalls(trace: Trace): CallRecord[] {
  const calls: CallRecord[] = [];
  if (trace.agent_id !== 'codex') {
    const uses = new Map<string, { item: StoredRecord; block: Record<string, unknown> }>();
    for (const item of trace.records) {
      const message = payload(item.record, trace.agent_id);
      if (!Array.isArray(message.content)) continue;
      for (const block of message.content.filter(isObject)) {
        if (block.type === 'tool_use' && typeof block.id === 'string') uses.set(block.id, { item, block });
        if (block.type !== 'tool_result' || typeof block.tool_use_id !== 'string') continue;
        const use = uses.get(block.tool_use_id);
        const result = outputText(block.content);
        const structured = item.record.toolUseResult;
        const benign = isObject(structured) && 'returnCodeInterpretation' in structured;
        const exit = /^(?:Error: )?Exit code (-?\d+)/.exec(result)?.[1]
          ?? (typeof structured === 'string' ? /^(?:Error: )?Exit code (-?\d+)/.exec(structured)?.[1] : undefined)
          ?? (trace.agent_id !== 'claude-code' && isObject(structured) && typeof structured.exit_code === 'number'
            ? String(structured.exit_code) : undefined);
        const exitCode = exit === undefined ? null : Number(exit);
        const failed = block.is_error === true && !benign;
        const denial = item.record.toolDenialKind;
        const kind = !failed ? null : denial === 'interrupted' || (isObject(structured) && structured.interrupted === true) || result.includes('[Request interrupted by user]')
          ? 'interrupted' : typeof denial === 'string' ? 'denied'
          : result.startsWith('PreToolUse:') ? 'hook_block'
          : result.includes('Command timed out after') ? 'timeout'
          : result.includes('Failed to find expected lines') ? 'edit_mismatch'
          : exitCode !== null ? 'exit_nonzero' : 'tool_error';
        const input = use?.block.input;
        const fields = isObject(input) ? input : {};
        calls.push({ call_id: block.tool_use_id, line_start: use?.item.line_number ?? item.line_number,
          line_end: item.line_number, turn: typeof item.record.promptId === 'string' ? item.record.promptId : null,
          tool: typeof use?.block.name === 'string' ? use.block.name : 'unknown',
          target: head(fields.file_path ?? fields.command ?? fields.url ?? fields.pattern),
          started_at: time(use?.item.record.timestamp), ended_at: time(item.record.timestamp), failed,
          failure_kind: kind, exit_code: exitCode, benign_nonzero: benign,
          error_excerpt: failed ? tail(result || (typeof structured === 'string' ? structured : '')) : null,
          command_text: text(fields.command), result_excerpt: excerpt(result || (typeof structured === 'string' ? structured : '')) });
      }
    }
    return calls;
  }

  const scripts = new Map<string, { item: StoredRecord; input: string; turn: string | null }>();
  const cells = new Map<string, string>();
  const waits = new Map<string, string>();
  for (const item of trace.records) {
    const record = payload(item.record, 'codex');
    if (item.record.type === 'event_msg' && record.type === 'item_completed' && isObject(record.item)) {
      const step = record.item;
      if (!['CommandExecution', 'FileChange', 'McpToolCall'].includes(String(step.type)) || step.source === 'user_shell') continue;
      const exit = typeof step.exit_code === 'number' ? step.exit_code : null;
      const failed = step.status === 'failed' || step.status === 'declined' || exit !== null && exit !== 0
        || isObject(step.result) && step.result.isError === true;
      const error = outputText(step.aggregated_output ?? step.stderr ?? (isObject(step.result) ? step.result.content : ''));
      const command = Array.isArray(step.parsed_cmd) && isObject(step.parsed_cmd[0]) ? step.parsed_cmd[0].cmd : null;
      const target = step.type === 'CommandExecution' ? head(command)
        : step.type === 'FileChange' && isObject(step.changes) ? head(Object.keys(step.changes)[0])
          : head(`${String(step.server ?? '')}/${String(step.tool ?? '')}`);
      calls.push({ call_id: String(step.id ?? `item-${item.line_number}`), line_start: item.line_number,
        line_end: item.line_number, turn: typeof record.turn_id === 'string' ? record.turn_id : null,
        tool: step.type === 'CommandExecution' ? 'shell' : step.type === 'FileChange' ? 'edit' : String(step.tool ?? 'mcp'),
        target, started_at: time(record.started_at_ms), ended_at: time(record.completed_at_ms), failed,
        failure_kind: !failed ? null : step.status === 'declined' ? 'denied' : exit === 124 ? 'timeout'
          : exit !== null && exit !== 0 ? 'exit_nonzero' : 'tool_error',
        exit_code: exit, benign_nonzero: false, error_excerpt: failed ? tail(error) : null,
        command_text: text(command), result_excerpt: excerpt(error) });
      continue;
    }
    if (record.type === 'custom_tool_call' && typeof record.call_id === 'string') {
      scripts.set(record.call_id, { item, input: String(record.input ?? ''),
        turn: isObject(record.internal_chat_message_metadata_passthrough)
          && typeof record.internal_chat_message_metadata_passthrough.turn_id === 'string'
          ? record.internal_chat_message_metadata_passthrough.turn_id : null });
      continue;
    }
    if (record.type === 'function_call' && record.name === 'wait' && typeof record.call_id === 'string'
      && typeof record.arguments === 'string') {
      try {
        const args: unknown = JSON.parse(record.arguments);
        if (isObject(args) && typeof args.cell_id === 'string') waits.set(record.call_id, args.cell_id);
      } catch { /* an unparseable wait has no cell to join */ }
      continue;
    }
    if (!['custom_tool_call_output', 'function_call_output'].includes(String(record.type))) continue;
    const output = outputText(record.output);
    const direct = typeof record.call_id === 'string' ? scripts.get(record.call_id) : undefined;
    const cell = /Script running with cell ID ([^\s]+)/.exec(output)?.[1];
    if (cell && direct && typeof record.call_id === 'string') cells.set(cell, record.call_id);
    const waitCell = typeof record.call_id === 'string' ? cells.get(waits.get(record.call_id) ?? '') : undefined;
    const script = direct ?? (waitCell ? scripts.get(waitCell) : undefined);
    if (!script || !/^(Script failed|Script terminated|aborted by user)/m.test(output)) continue;
    const kind = output.includes('apply_patch verification failed') ? 'edit_mismatch'
      : output.includes('Command blocked by PreToolUse hook') ? 'hook_block'
        : /Script terminated|aborted by user/.test(output) ? 'interrupted' : 'script_error';
    calls.push({ call_id: direct ? String(record.call_id) : String(waitCell), line_start: script.item.line_number,
      line_end: item.line_number, turn: script.turn, tool: 'exec', target: head(script.input),
      started_at: time(script.item.record.timestamp), ended_at: time(item.record.timestamp), failed: true,
      failure_kind: kind, exit_code: null, benign_nonzero: false, error_excerpt: tail(output),
      command_text: null, result_excerpt: excerpt(output) });
  }
  return calls;
}
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: 472kUpdated Claude CodeCodexVerifiedInstall
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: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
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 availableStars: 322kUpdated Claude CodeCodexVerifiedInstall