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.tsscript22.1 KB
scripts/local-settings.tsscript1.4 KB
scripts/local-writer.tsscript12.6 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/proposer-validate.test.ts

View on GitHub
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { mkdirSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { validateProposal, proposalSignature } from './proposer.ts';
import type { Proposal } from './proposer.ts';
import { appendLedger } from './ledger.ts';
import type { Page } from './pages.ts';
import { tmp, fixtureConfig, fixtureHarnessHomes, makeStore, writeInstalledSkill } from './test-helpers.ts';

const HOMES = fixtureHarnessHomes([]);
const ROOTS = [join(HOMES.claudeHome, 'skills'), join(HOMES.codexHome, 'skills')];
const HEARTBEAT = writeInstalledSkill(HOMES.claudeHome, 'heartbeat', 'Body line.\n<!-- reminders:start -->\n<!-- reminders:end -->\n');
writeInstalledSkill(HOMES.codexHome, 'heartbeat', 'Body line.\n<!-- reminders:start -->\n<!-- reminders:end -->\n');

function ctx(store: string, pages: Page[], roots = ROOTS): { store: string; pages: Page[]; roots: string[] } {
  return { store, pages, roots };
}
function page(id: string, cls: 'SKILL_DEFECT' | 'EXECUTION_LAPSE'): Page {
  return { page_id: id, summary: 's', class: cls, root_cause: { fact: 'f' } as Page['root_cause'], fix: 'x',
    body: '', count: 2, task_ids: [], last_seen: '2026-09-01', skills_observed: [], citations: [], skills_used: [] } as unknown as Page;
}
function base(over: Partial<Proposal>): Proposal {
  const merged: Record<string, unknown> = { kind: 'patch', target: HEARTBEAT, region: 'body', purpose: { summary: 'fix it', page_ids: ['pg-sd'] },
    scenario: { task_type: 'write', trigger: 'x', tools: [] }, skills_used: [], skill_target: null, knowledge_used: [],
    outcome: 'fail', evidence: [], ops: [{ op: 'append', text: 'one more line\n' }], ...over };
  // an explicit `undefined` key would fail the array/string schema checks; drop them
  for (const k of Object.keys(merged)) if (merged[k] === undefined) delete merged[k];
  return merged as unknown as Proposal;
}

const served = new Set([HEARTBEAT]);

// a create/patch missing a PURPOSE page id or an expertise field is refused ---
test('a patch with no PURPOSE page id, and one with an empty scenario.task_type, are refused', () => {
  const store = makeStore(fixtureConfig({ ...HOMES, claude_home: HOMES.claudeHome, codex_home: HOMES.codexHome }));
  const c = ctx(store, [page('pg-sd', 'SKILL_DEFECT')]);
  assert.throws(() => validateProposal(base({ purpose: { summary: 's', page_ids: [] } }), c, served), /page id/);
  assert.throws(() => validateProposal(base({ scenario: { task_type: '', trigger: 't', tools: [] } }), c, served), /expertise/);
});

// class routing and the reminders region rules ---
test('SKILL_DEFECT routes to a body patch and EXECUTION_LAPSE to a reminders patch', () => {
  const store = makeStore(fixtureConfig({ claude_home: HOMES.claudeHome, codex_home: HOMES.codexHome }));
  const c = ctx(store, [page('pg-sd', 'SKILL_DEFECT'), page('pg-el', 'EXECUTION_LAPSE')]);
  assert.doesNotThrow(() => validateProposal(base({}), c, served));
  // a body patch against an EXECUTION_LAPSE page is refused
  assert.throws(() => validateProposal(base({ region: 'body', purpose: { summary: 's', page_ids: ['pg-el'] } }), c, served), /disagrees/);
  // an EXECUTION_LAPSE reminders patch adds one line
  const rem = base({ region: 'reminders', ops: undefined, line: 'Always close the handle.', purpose: { summary: 's', page_ids: ['pg-el'] } });
  assert.doesNotThrow(() => validateProposal(rem, c, served));
});

test('a reminders line duplicate, and a replace_line not in the region, are refused', () => {
  const homes = fixtureHarnessHomes([]);
  const hb = writeInstalledSkill(homes.claudeHome, 'hb', '<!-- reminders:start -->\nExisting reminder line.\n<!-- reminders:end -->\n');
  const roots = [join(homes.claudeHome, 'skills'), join(homes.codexHome, 'skills')];
  const store = makeStore(fixtureConfig({ claude_home: homes.claudeHome, codex_home: homes.codexHome }));
  const c = ctx(store, [page('pg-el', 'EXECUTION_LAPSE')], roots);
  const s = new Set([hb]);
  const dup = base({ target: hb, region: 'reminders', ops: undefined, line: 'Existing reminder line.', purpose: { summary: 's', page_ids: ['pg-el'] } });
  assert.throws(() => validateProposal(dup, c, s), /byte-identical/);
  const badReplace = base({ target: hb, region: 'reminders', ops: undefined, line: 'New line.', replace_line: 'Not present.', purpose: { summary: 's', page_ids: ['pg-el'] } });
  assert.throws(() => validateProposal(badReplace, c, s), /not in the reminders/);
  const okReplace = base({ target: hb, region: 'reminders', ops: undefined, line: 'Replacement line.', replace_line: 'Existing reminder line.', purpose: { summary: 's', page_ids: ['pg-el'] } });
  assert.doesNotThrow(() => validateProposal(okReplace, c, s));
});

test('a 13th reminder line is refused (region cap of 12)', () => {
  const twelve = Array.from({ length: 12 }, (_, i) => `Reminder number ${i}.`).join('\n');
  const homes = fixtureHarnessHomes([]);
  const hb = writeInstalledSkill(homes.claudeHome, 'hb', `<!-- reminders:start -->\n${twelve}\n<!-- reminders:end -->\n`);
  const roots = [join(homes.claudeHome, 'skills'), join(homes.codexHome, 'skills')];
  const store = makeStore(fixtureConfig({ claude_home: homes.claudeHome, codex_home: homes.codexHome }));
  const c = ctx(store, [page('pg-el', 'EXECUTION_LAPSE')], roots);
  const thirteenth = base({ target: hb, region: 'reminders', ops: undefined, line: 'One too many.', purpose: { summary: 's', page_ids: ['pg-el'] } });
  assert.throws(() => validateProposal(thirteenth, c, new Set([hb])), /reminders block at the end of SKILL.md past/);
});

// the validator refusals and the two accepts ---
test('size, path, and create rules are each refused; a clean patch and create pass the validator', () => {
  const store = makeStore(fixtureConfig({ claude_home: HOMES.claudeHome, codex_home: HOMES.codexHome }));
  const c = ctx(store, [page('pg-sd', 'SKILL_DEFECT'), page('pg-el', 'EXECUTION_LAPSE')]);
  const sd = { page_ids: ['pg-sd'], summary: 's' };
  // 31-line growth
  assert.throws(() => validateProposal(base({ ops: [{ op: 'append', text: 'x\n'.repeat(31) }] }), c, served), /lines/);
  // 201-char description growth (replace the description line with a much longer one)
  assert.throws(() => validateProposal(base({ ops: [{ op: 'replace', target: 'fixture heartbeat.', text: 'd'.repeat(260) }] }), c, served), /description/);
  // rename name
  assert.throws(() => validateProposal(base({ ops: [{ op: 'replace', target: 'name: heartbeat', text: 'name: renamed' }] }), c, served), /name/);
  // replace target occurs nowhere
  assert.throws(() => validateProposal(base({ ops: [{ op: 'replace', target: 'NOT-THERE', text: 'y' }] }), c, served), /occurs 0 times|not once/);
  // patch a deployed copy / path outside skills/<unit>
  assert.throws(() => validateProposal(base({ target: tmp('outside') }), c, served), /patch must target/);
  // create naming the existing unit heartbeat
  const createBase = { kind: 'create' as const, target: 'heartbeat', purpose: sd, scenario: { task_type: 'w', trigger: 't', tools: [] },
    skills_used: [], skill_target: null, knowledge_used: [], outcome: 'fail' as const, evidence: [],
    skill_md: `---\nname: heartbeat\ndescription: "new one."\n---\n# x\n` };
  assert.throws(() => validateProposal(createBase, c, served), /already exists/);
  // create with a bad unit name
  assert.throws(() => validateProposal({ ...createBase, target: 'Bad_Name', skill_md: `---\nname: Bad_Name\ndescription: "d."\n---\n#x\n` }, c, served), /create target/);
  // create missing description
  assert.throws(() => validateProposal({ ...createBase, target: 'example-new', skill_md: `---\nname: example-new\n---\n#x\n` }, c, served), /frontmatter/);
  // create name != path
  assert.throws(() => validateProposal({ ...createBase, target: 'example-new', skill_md: `---\nname: other-name\ndescription: "d."\n---\n#x\n` }, c, served), /frontmatter/);
  // clean accepts: a modest body patch, and a valid create
  assert.doesNotThrow(() => validateProposal(base({ ops: [{ op: 'append', text: 'one clean line\n' }] }), c, served));
  assert.doesNotThrow(() => validateProposal({ ...createBase, target: 'example-new', skill_md: `---\nname: example-new\ndescription: "a brand new skill."\n---\n# example-new\n` }, c, served));
});

// The validator: a proposal byte-identical to a Rejected ledger row is refused, id recorded ---
test('a proposal byte-identical to a Rejected row is refused naming the row; a reworded one passes', () => {
  const store = makeStore(fixtureConfig({ claude_home: HOMES.claudeHome, codex_home: HOMES.codexHome }));
  const c = ctx(store, [page('pg-sd', 'SKILL_DEFECT')]);
  const rejected = base({ ops: [{ op: 'append', text: 'the rejected change\n' }] });
  appendLedger(store, { type: 'proposal', proposal_id: '20260901-0000/codex', verdict: 'Rejected', signature: proposalSignature(rejected) });
  // same change, only indentation/trailing-space differences -> refused
  const restyled = base({ ops: [{ op: 'append', text: '  the rejected change  \n' }] });
  assert.throws(() => validateProposal(restyled, c, served), /Rejected proposal: 20260901-0000\/codex/);
  // one word changed -> staged
  assert.doesNotThrow(() => validateProposal(base({ ops: [{ op: 'append', text: 'the accepted change\n' }] }), c, served));
});
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