Skip to content

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

rem-reflect

Unverified

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

View on GitHub
import { existsSync, readFileSync, realpathSync } from 'node:fs';
import { homedir } from 'node:os';
import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

export interface Config {
  claude_home: string;
  codex_home: string;
  hermes_home: string;
  openclaw_home: string;
  claude_root: string;
  codex_root: string;
  cursor_root: string;
  project_names: Record<string, string>;
  time_zone: string;
}

export const paths = {
  identity: join(homedir(), '.sno', 'identity.json'),
  references: fileURLToPath(new URL('../references/', import.meta.url)),
};
// `cloudWaitMs`: how long one nightly upload waits for the cloud's answer, so a stalled cloud cannot hold
// the run silently for as long as the scheduler allows.
// `localSessionsPerHalf`: how many sessions per harness the Local First nightly run asks its own CLI about;
// one agent call each, so a night with hundreds of eligible sessions cannot run for hours.
export const limits = { firstDays: 7, quietMinutes: 30, chunkCharacters: 40_000, cloudWaitMs: 6 * 3_600_000, localSessionsPerHalf: 3 };
export const readingLimits = { ledgerRows: 200 };
export const sizeCaps = { skillMdLines: 30, descriptionChars: 200, reminderLines: 12 };
export const reflectionFiles = {
  raw: 'raw', staging: 'staging', pages: 'wiki/patterns', index: 'wiki/index.md', logs: 'wiki/logs.md',
  lessons: 'wiki/lessons.jsonl', usage: 'ledger/usage.jsonl', ledger: 'ledger/skill-impact.jsonl',
  labelerInput: 'labeler-input.json', labelerOutput: 'labeler-output.json',
  proposal: 'proposal.json', skillMd: 'SKILL.md', patch: 'patch.json', purpose: 'PURPOSE.md',
  report: 'REPORT.md', runLog: 'run.log', localWriter: 'ledger/local-writer.jsonl',
};
export const commands = ['run', 'accept', 'reject', 'tbd', 'recall', 'lesson', 'status', 'install-hooks'];
export const messages = {
  later: 'command not implemented',
  redacted: '[REDACTED]',
  help: 'Usage: sno rem-reflect run [--now <timestamp>] [--trigger timer|manual]|accept|reject|tbd|recall [--first-message]|recall install|lesson|status|install-hooks',
};

export function isObject(value: unknown): value is Record<string, unknown> {
  return typeof value === 'object' && value !== null && !Array.isArray(value);
}

export function storePath(env: NodeJS.ProcessEnv = process.env): string {
  return resolve(env.REM_REFLECT_STORE ?? join(homedir(), '.sno', 'experience'));
}

export type StationCell = 'off' | 'host' | 'sno-gpu';
export type StationMode = 'local-first' | 'agent-native' | 'rem-enhanced';
export class SettingsUnavailable extends Error {}

// Read the setup-owned settings on every call, with no default for a missing mode.
export function readStationSettings(env: NodeJS.ProcessEnv = process.env): Record<string, unknown> & { mode: StationMode } {
  const path = join(env.SNO_PROFILE_DIR ?? join(homedir(), '.sno'), 'settings.json');
  const fail = (reason: string): never => { throw new SettingsUnavailable(`settings unavailable: ${path}: ${reason}; run sno setup`); };
  if (!existsSync(path)) return fail('file missing');
  let settings: unknown;
  try { settings = JSON.parse(readFileSync(path, 'utf8')); } catch { return fail('not valid JSON'); }
  const file = isObject(settings) ? settings : {};
  const mode = file.mode;
  if (mode !== 'local-first' && mode !== 'agent-native' && mode !== 'rem-enhanced') return fail('mode is missing or unknown');
  return { ...file, mode };
}

export function stationCell(id: 'R2' | 'R3' | 'R4' | 'R5', env: NodeJS.ProcessEnv = process.env): StationCell {
  const path = join(env.SNO_PROFILE_DIR ?? join(homedir(), '.sno'), 'settings.json');
  const fail = (reason: string): never => { throw new SettingsUnavailable(`settings unavailable: ${path}: ${reason}; run sno setup`); };
  const file = readStationSettings(env);
  const mode = file.mode;
  const row = isObject(file.modelCalls) ? file.modelCalls[id] : undefined;
  if (id === 'R5' && row === undefined) return mode === 'local-first' ? 'host' : 'off';
  if (!isObject(row)) return fail(`modelCalls.${id} is missing`);
  const cell = row[mode];
  if (cell !== 'off' && cell !== 'host' && cell !== 'sno-gpu') return fail(`modelCalls.${id}.${mode} is not off, host or sno-gpu`);
  return cell;
}

export function defaultConfig(home: string = homedir()): Config {
  const claude_home = join(home, '.claude');
  const codex_home = join(home, '.codex');
  return {
    claude_home, codex_home,
    hermes_home: process.env.HERMES_HOME ?? join(home, '.hermes'),
    openclaw_home: process.env.OPENCLAW_STATE_DIR ?? join(home, '.openclaw'),
    claude_root: join(claude_home, 'projects'),
    codex_root: join(codex_home, 'sessions'),
    cursor_root: join(home, '.cursor', 'projects'),
    project_names: {},
    time_zone: Intl.DateTimeFormat().resolvedOptions().timeZone,
  };
}

export function validateConfig(value: unknown): Config {
  if (!isObject(value)) throw new Error('config.json: expected an object');
  const result = defaultConfig();
  for (const key of ['claude_home', 'codex_home', 'claude_root', 'codex_root', 'time_zone'] as const) {
    const field = value[key];
    if (typeof field !== 'string' || !field.trim()) throw new Error(`config.json: invalid ${key}`);
    if (key !== 'time_zone' && !isAbsolute(field)) throw new Error(`config.json: ${key} must be absolute`);
    result[key] = field;
  }
  // Existing published stores have no entries for the newly supported agents.
  for (const key of ['hermes_home', 'openclaw_home'] as const) {
    const field = value[key] ?? result[key];
    if (typeof field !== 'string' || !isAbsolute(field)) throw new Error(`config.json: ${key} must be absolute`);
    result[key] = field;
  }
  // Stores written before Cursor support have no cursor_root.
  if (value.cursor_root !== undefined) {
    if (typeof value.cursor_root !== 'string' || !isAbsolute(value.cursor_root)) throw new Error('config.json: cursor_root must be absolute');
    result.cursor_root = value.cursor_root;
  }
  if (!isObject(value.project_names)) throw new Error('config.json: invalid project_names');
  for (const [directory, name] of Object.entries(value.project_names)) {
    if (!isAbsolute(directory) || typeof name !== 'string' || !name.trim()) {
      throw new Error('config.json: invalid project_names entry');
    }
    result.project_names[directory] = name;
  }
  try { new Intl.DateTimeFormat('en', { timeZone: result.time_zone }).format(); }
  catch { throw new Error('config.json: invalid time_zone'); }
  return result;
}

export function loadConfig(store: string): Config {
  let value: unknown;
  try { value = JSON.parse(readFileSync(join(store, 'config.json'), 'utf8')); }
  catch { throw new Error('config.json: missing or unparsable; repair it before running'); }
  return validateConfig(value);
}

export function canonicalPath(path: string): string {
  const absolute = resolve(path);
  if (existsSync(absolute)) return realpathSync(absolute);
  const parent = dirname(absolute);
  return join(canonicalPath(parent), relative(parent, absolute));
}

export function isWithin(parent: string, child: string): boolean {
  const suffix = relative(canonicalPath(parent), canonicalPath(child));
  return suffix === '' || (!suffix.startsWith('../') && suffix !== '..' && !isAbsolute(suffix));
}

export function skillRoots(config: Config): string[] {
  return [config.claude_home, config.codex_home, config.hermes_home, config.openclaw_home].map(home => join(home, 'skills'));
}

export function validateRoots(config: Config, store: string): void {
  for (const key of ['claude_root', 'codex_root'] as const) {
    if (isWithin(store, config[key])) throw new Error(`config.json: ${key} lies inside store: ${config[key]}`);
  }
}

export function calendar(now: Date, timeZone: string): { date: string; id: string } {
  const parts = new Intl.DateTimeFormat('en-CA', {
    timeZone, year: 'numeric', month: '2-digit', day: '2-digit',
    hour: '2-digit', minute: '2-digit', hourCycle: 'h23',
  }).formatToParts(now);
  const part = (name: string): string => parts.find(item => item.type === name)?.value ?? '';
  const date = `${part('year')}-${part('month')}-${part('day')}`;
  return { date, id: `${date.replaceAll('-', '')}-${part('hour')}${part('minute')}` };
}
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 CodeCodexUnverifiedInstall
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