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/verdicts.ts

View on GitHub
import type { CallRecord } from './calls.ts';
import type { Evidence } from './evidence.ts';

// An external verdict is a test, type/lint check, build or git landing that code identifies in a session's
// calls; the model never decides one. Lessons cite one through `verdict_ref`.
export type VerdictKind = 'test' | 'typecheck_lint' | 'build' | 'landed';
export interface Verdict { line: number; kind: VerdictKind; passed: boolean; command: string }
export interface VerdictRef { line: number; kind: VerdictKind; passed: boolean }

const KINDS: Record<string, VerdictKind> = {
  pytest: 'test', vitest: 'test', jest: 'test', 'bun test': 'test', 'npm test': 'test', 'pnpm test': 'test',
  'bun run test': 'test', 'npm run test': 'test', 'pnpm run test': 'test',
  'cargo test': 'test', 'go test': 'test', bats: 'test', prove: 'test',
  tsc: 'typecheck_lint', ruff: 'typecheck_lint', eslint: 'typecheck_lint', mypy: 'typecheck_lint',
  shellcheck: 'typecheck_lint', biome: 'typecheck_lint',
  'npm run build': 'build', 'bun build': 'build', 'cargo build': 'build', make: 'build',
  'git commit': 'landed', 'git push': 'landed',
};
// Commands whose identity includes their first subcommand; only the package managers run a script as `run <name>`
// (`cargo run test` starts a program with an argument).
const MULTI = new Set(['bun', 'npm', 'pnpm', 'cargo', 'go', 'git']);
const RUN_SCRIPT = new Set(['bun', 'npm', 'pnpm']);
// Wrappers in front of the real command: dropped with their argument count.
const DROP_ONE = new Set(['env', 'nice', 'sudo', 'npx', 'bunx']);
const DROP_TWO = new Set(['cd', 'timeout', '-u', 'uv run', 'pnpm exec', 'npm exec', 'python3 -m', 'python -m']);
const PASS = /\b([1-9]\d*) (passed|passing)\b|Ran ([1-9]\d*) tests?|^ok [1-9]\d* /m;
// `fail` alone is bun's summary line (` 1 fail`), which comes with a `Ran N tests` line the pass expression matches.
const FAIL = /\b[1-9]\d* (failed|failing|fail)\b|^not ok /m;
const ANSI = /\x1b\[[0-9;]*m/g;

// Split a shell command at &&, ||, ;, | and newlines outside quotes.
export function segments(command: string): string[] {
  const out: string[] = [];
  let current = '';
  let quote: string | null = null;
  for (let i = 0; i < command.length; i++) {
    const ch = command[i];
    if (quote) {
      current += ch;
      if (ch === quote) quote = null;
      else if (ch === '\\' && quote === '"') current += command[++i] ?? '';
      continue;
    }
    if (ch === "'" || ch === '"') { quote = ch; current += ch; continue; }
    if (ch === '\\') { current += ch + (command[++i] ?? ''); continue; }
    if ((ch === '&' || ch === '|') && command[i + 1] === ch) { out.push(current); current = ''; i++; continue; }
    if (ch === ';' || ch === '|' || ch === '\n') { out.push(current); current = ''; continue; }
    current += ch;
  }
  out.push(current);
  return out.map(segment => segment.trim()).filter(Boolean);
}

function unwrapped(words: string[]): string[] {
  for (;;) {
    const [first, second] = words;
    if (first === undefined) return words;
    if (DROP_TWO.has(first) || DROP_TWO.has(`${first} ${second}`)) { words = words.slice(2); continue; }
    // A wrapper's own option (`npx --yes`, `sudo -E`) comes before the command word and is dropped with the wrapper.
    if (DROP_ONE.has(first) || first.startsWith('-') || /^[A-Za-z_]\w*=/.test(first)) { words = words.slice(1); continue; }
    // A secrets or environment runner (`<tool> run [options] -- command`) wraps the real command; a command's own `run` does not.
    const name = first.slice(first.lastIndexOf('/') + 1);
    if (second === 'run' && verdictKind(name) === null && !MULTI.has(name)) {
      const end = words.indexOf('--');
      words = end === -1 ? words.slice(2) : words.slice(end + 1);
      continue;
    }
    return words;
  }
}

// One segment's command word after its wrappers: the first word's file name, plus the first subcommand
// of a multi-path command (`npm run build`, `git push`). Null for a segment that is only wrappers.
export function commandWord(segment: string): string | null {
  // Words split at whitespace outside quotes, so `MSG='a b' cmd` is an assignment and a command.
  const words = segment.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) ?? [];
  const [first, second, third] = unwrapped(words);
  if (!first) return null;
  const name = first.slice(first.lastIndexOf('/') + 1);
  if (!MULTI.has(name) || !second) return name;
  return second === 'run' && third && RUN_SCRIPT.has(name) ? `${name} run ${third}` : `${name} ${second}`;
}

export function verdictKind(id: string | null): VerdictKind | null {
  if (!id) return null;
  return KINDS[id] ?? (id.endsWith('.t') ? 'test' : null);
}

// The verdict identity of a whole command: its verdict-carrying segments must all be one family (they
// merge into one, `git commit && git push` → `git push`); two families in one command give no identity,
// because the aggregated output cannot be attributed to either.
export function commandId(command: string): string | null {
  const judged = segments(command).map(commandWord).filter(word => verdictKind(word) !== null);
  if (new Set(judged.map(verdictKind)).size !== 1) return null;
  return judged[judged.length - 1];
}

// Whether any segment runs a test, verdict or not: a later test call disqualifies a success lesson even when the
// combination rule dropped its verdict, because it may have failed.
export function runsTest(command: string): boolean {
  return segments(command).some(segment => verdictKind(commandWord(segment)) === 'test');
}

export function externalVerdicts(calls: readonly CallRecord[]): Verdict[] {
  const verdicts: Verdict[] = [];
  for (const call of calls) {
    if (call.command_text === null) continue;
    const kind = verdictKind(commandId(call.command_text));
    if (!kind) continue;
    const verdict = { line: call.line_end, kind, command: call.command_text };
    if (kind !== 'test') { verdicts.push({ ...verdict, passed: !call.failed }); continue; }
    // A test verdict needs a summary line with a non-zero count; a test call without one is no verdict.
    const text = (call.result_excerpt ?? '').replace(ANSI, '');
    if (call.failed || FAIL.test(text)) verdicts.push({ ...verdict, passed: false });
    else if (PASS.test(text)) verdicts.push({ ...verdict, passed: true });
  }
  return verdicts;
}

export interface VerdictClaim { polarity: 'from_failure' | 'from_success'; verdict_line: unknown; evidence: readonly Pick<Evidence, 'line_start' | 'line_end'>[] }
// The verdict a lesson may cite, or the reason it may not. A success lesson cites a passed test after which
// no test-identity call ran (a later test may have failed without a verdict); a failure lesson cites a failed
// test, check or build within 60 lines of one of its evidence ranges. Nothing is chosen for the model.
export function verdictRef(claim: VerdictClaim, verdicts: readonly Verdict[], calls: readonly CallRecord[]): { ref: VerdictRef } | { reason: string } {
  const verdict = verdicts.find(item => item.line === claim.verdict_line);
  if (!verdict) return { reason: `verdict_line ${String(claim.verdict_line)} names no external verdict` };
  const ref = { line: verdict.line, kind: verdict.kind, passed: verdict.passed };
  if (claim.polarity === 'from_success') {
    if (verdict.kind !== 'test' || !verdict.passed) return { reason: `from_success cites a ${verdict.passed ? 'passed' : 'failed'} ${verdict.kind} verdict at line ${verdict.line}` };
    const later = calls.find(call => call.line_end > verdict.line && call.command_text !== null && runsTest(call.command_text));
    if (later) return { reason: `from_success cites line ${verdict.line} but a test ran later at line ${later.line_end}` };
    return { ref };
  }
  if (verdict.passed || verdict.kind === 'landed') return { reason: `from_failure cites a ${verdict.passed ? 'passed' : 'failed'} ${verdict.kind} verdict at line ${verdict.line}` };
  if (!claim.evidence.some(item => verdict.line >= item.line_start - 60 && verdict.line <= item.line_end + 60)) {
    return { reason: `from_failure cites line ${verdict.line}, more than 60 lines from every evidence range` };
  }
  return { ref };
}
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: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated 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: 323kUpdated Claude CodeCodexVerifiedInstall