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/selftest/journey.mjs

View on GitHub
// Two-day fixture through the real local backend and the recording sno CLI.
// REM_DROP_ISOLATION=1 plants an isolation failure on this test backend instance only.
import assert from 'node:assert/strict';
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { run } from '../rem-reflect.ts';
import { RealBackend } from '../backend.ts';
import { existingTraces } from '../harvest.ts';
import { readLabels } from '../labeler.ts';
import { readPages } from '../pages.ts';
import { readLedger } from '../ledger.ts';
import { hashListing, stationSettings } from '../test-helpers.ts';
import {
  tmp, makeConfig, makeStore, writeInstalledSkill,
  writeClaudeSession, claudeUser, claudeAssistant, writeCodexSession, codexMeta, codexUser, codexAssistant,
} from '../test-helpers.ts';

const BIN = fileURLToPath(new URL('./bin', import.meta.url));
const DAY1 = new Date('2026-09-15T00:00:00Z');
const DAY2 = new Date('2026-09-16T00:00:00Z');
const SRC_MT = new Date('2026-09-14T00:00:00Z').getTime(); // fixture sessions: older than DAY1's quiet window
const SELF_MT = new Date('2026-09-15T06:00:00Z').getTime(); // loop-own turns: between DAY1 and DAY2's quiet window

// A fixture HOME whose .claude/projects and .codex/sessions ARE the harvest roots, so that when the
// isolation flags are dropped the shim saves its turn in the harvest root.
const home = tmp('home');
const claudeHome = join(home, '.claude'), codexHome = join(home, '.codex');
mkdirSync(claudeHome, { recursive: true }); mkdirSync(codexHome, { recursive: true });
for (const name of ['heartbeat', 'second-skill', 'nested-skill']) {
  writeInstalledSkill(claudeHome, name);
  writeInstalledSkill(codexHome, name);
}
writeFileSync(join(claudeHome, '.credentials.json'), '{"claude":"fixture-token"}');
writeFileSync(join(codexHome, 'auth.json'), '{"codex":"fixture-token"}');
const config = makeConfig({
  claude_home: claudeHome, codex_home: codexHome,
  claude_root: join(claudeHome, 'projects'), codex_root: join(codexHome, 'sessions'),
  project_names: {}, time_zone: 'UTC',
});
const store = makeStore(config);

// three Claude Code sessions and three Codex sessions, all newer than the cursor and older than quiet
for (let i = 0; i < 3; i++) {
  writeClaudeSession(config.claude_root, 'proj', `cc${i}`,
    [claudeUser('/n', `cc${i}`, 'do it'), claudeAssistant('/n', `cc${i}`, [{ type: 'text', text: 'ok' }])], SRC_MT + i);
  writeCodexSession(config.codex_root, `cx${i}`,
    [codexMeta(`cx${i}`, '/n'), codexUser('do it'), codexAssistant('ok')], SRC_MT + i, `2026/09/1${i + 4}`, `2026-09-1${i + 4}T00-00-00`);
}

// the loop spawns the shims: put them first on PATH and pin their session mtime to the test clock
process.env.HOME = home;
process.env.CLAUDE_CONFIG_DIR = claudeHome;
process.env.CODEX_HOME = codexHome;
// When run directly the driver puts its own shim bin on PATH. Under the self-test harness
// PATH is already the allowlist-only bin that holds the shims, so leave it untouched.
if (!process.env.REM_SELFTEST) process.env.PATH = `${BIN}:${process.env.PATH}`;
process.env.REM_SHIM_MTIME = String(SELF_MT);
process.env.REM_SNO_CAPTURE = join(home, 'cloud-requests.jsonl');
mkdirSync(join(home, '.sno'), { recursive: true });
writeFileSync(join(home, '.sno', 'settings.json'), stationSettings('rem-enhanced'));
const backend = () => {
  const live = new RealBackend(30_000);
  if (process.env.REM_DROP_ISOLATION === '1') live.isolation = () => [];
  return live;
};

// the fixture real directories must be untouched by the run: no saved turn, no renewed login
const claudeHomeBefore = hashListing(claudeHome);
const codexHomeBefore = hashListing(codexHome);

// --- day one ---
const r1 = run(store, DAY1, 'u', backend());
assert.equal(r1.code, 0, `day one exits success:\n${r1.lines.join('\n')}`);
assert.equal(readStatus(), 'success', 'day one terminal is success');

const traces = existingTraces(store);
assert.equal(traces.length, 6, `six traces harvested, got ${traces.length}`);
for (const t of traces) {
  for (const f of ['user_id', 'project_id', 'agent_id', 'source_harness', 'originator']) {
    assert.ok(t[f] !== undefined && t[f] !== '', `trace ${t.trace_id} carries ${f}`);
  }
  assert.ok(!('outcome' in t), `trace ${t.trace_id} carries no outcome`);
  const raw = JSON.parse(readFileSync(t.source_path_in_store ?? traceFile(t), 'utf8'));
  assert.ok(!('outcome' in raw), `trace file ${t.trace_id} holds no outcome`);
}
const labels = readLabels(store);
assert.equal(labels.size, 6, `six label files, got ${labels.size}`);
assert.ok([...labels.values()].some(label => label.decision === 'keep' && label.outcome === 'fail'
  && label.reason === 'fixture fail'), 'the own-CLI answer was parsed, not replaced by keep/unknown fallback');
for (const [, label] of labels) {
  assert.equal(label.decision, 'keep', 'the local CLI never affirmatively dropped a fixture session');
  assert.ok(['success', 'fail', 'unknown'].includes(label.outcome), 'a label carries an outcome');
  assert.ok(label.reason, 'a label carries a reason');
  assert.ok(label.model || label.labeled_by, 'a label carries the resolving model or backend');
}
const pages = readPages(store);
assert.equal(pages.length, 6, 'the recorded cloud answer wrote one cited page for every retained session');
assert.ok(pages.every(p => p.class), 'every page carries a class');
assert.deepEqual(new Set(pages.map(p => p.agent_id)), new Set(['codex', 'claude-code']));
assert.ok(existsSync(join(store, 'wiki', 'index.md')), 'the index is written');
const proposals = readLedger(store).filter(x => x.type === 'proposal');
assert.ok(proposals.some(p => p.half === 'claude-code') && proposals.some(p => p.half === 'codex'), 'one proposal per half');

const sent = readFileSync(process.env.REM_SNO_CAPTURE, 'utf8').trim().split('\n').map(line => JSON.parse(line));
assert.equal(sent.length, 1, 'one complete batch crossed the recorded cloud CLI');
assert.equal(sent[0].halves.flatMap(half => half.sessions).length, 6, 'all kept sessions crossed the same consent boundary');
assert.equal(sent[0].catalogue.length, 6, 'each installed skill body from both harness homes was uploaded');
for (const entry of sent[0].catalogue) assert.ok(entry.skill_md.includes(`name: ${entry.name}`), 'complete SKILL.md body was uploaded');
const uploaded = new Map(sent[0].halves.flatMap(half => half.sessions).map(session => [session.trace_id, session]));
for (const page of pages) {
  const cite = page.citations[0];
  const trace = uploaded.get(cite.trace_id);
  assert.ok(trace && trace.chunks.some(chunk => chunk.text.includes(cite.quote)), `page ${page.page_id} cites uploaded text`);
}
assert.ok(existsSync(join(store, 'staging', idOf(DAY1), 'cloud-response.json')), 'the answer is saved for repeatable local application');

const report = readFileSync(join(store, 'staging', idOf(DAY1), 'REPORT.md'), 'utf8');
assert.match(report, /Uploaded: 6/);
assert.match(report, /Pages written: 6/);
assert.match(report, /Pending decisions: 2/);

// the turns ran on the fixture login in place: no login was copied anywhere under the store
assert.deepEqual(findAll(store).filter(p => /(\.credentials|auth)\.json$/.test(p)), [], 'no login file was copied under the store');

// --- day two ---
const r2 = run(store, DAY2, 'u', backend());
const day2New = existingTraces(store).filter(t => /loopself-/.test(t.session_id));
assert.equal(r2.code, 0, `day two succeeded:\n${r2.lines.join('\n')}`);
const day2Log = readFileSync(join(store, 'staging', idOf(DAY2), 'run.log'), 'utf8');
assert.ok(/harvested sessions under store: 0/.test(day2Log), 'day two ran the harvest and recorded the under-store count');
const citingLoop = readPages(store).some(page => page.citations.some(cite => /loopself-/.test(cite.trace_id)));
assert.equal(day2New.length, 0, `day two harvested no loop-own session; got ${day2New.length}, cloud cited it: ${citingLoop}`);
assert.equal(hashListing(claudeHome), claudeHomeBefore, 'the real Claude home stayed unchanged');
assert.equal(hashListing(codexHome), codexHomeBefore, 'the real Codex home stayed unchanged');
console.log('JOURNEY OK isolated');

function readStatus() {
  const s = JSON.parse(readFileSync(join(store, 'state.json'), 'utf8'));
  return s.last_terminal?.status;
}
function idOf(now) {
  const p = new Intl.DateTimeFormat('en-CA', { timeZone: 'UTC', year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }).formatToParts(now);
  const g = (n) => p.find(x => x.type === n).value;
  return `${g('year')}${g('month')}${g('day')}-${g('hour')}${g('minute')}`;
}
function findJsonl(root) {
  const out = [];
  const walk = (d) => { for (const e of readdirSync(d, { withFileTypes: true })) { const p = join(d, e.name); if (e.isDirectory()) walk(p); else if (e.name.endsWith('.jsonl')) out.push(p); } };
  walk(root);
  return out;
}
function traceFile(t) {
  // raw/<user>/<agent>/<project>/<session>.v<n>.json — find it by session id under raw/
  const hits = findRaw(join(store, 'raw')).filter(p => p.includes(t.session_id) && p.endsWith('.json') && !p.endsWith('.label.json'));
  return hits[0];
}
function findAll(root) {
  const out = [];
  const walk = (d) => { for (const e of readdirSync(d, { withFileTypes: true })) { const p = join(d, e.name); if (e.isDirectory()) walk(p); else out.push(p); } };
  walk(root);
  return out;
}
function findRaw(root) {
  if (!existsSync(root)) return [];
  const out = [];
  const walk = (d) => { for (const e of readdirSync(d, { withFileTypes: true })) { const p = join(d, e.name); if (e.isDirectory()) walk(p); else out.push(p); } };
  walk(root);
  return out;
}
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