sno-ai/sno-station-skills / skills/R-recursive-self-improvement/rem-reflect/skill
rem-reflect
VerifiedSelf 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.
scripts/identity.test.ts
View on GitHubimport { test } from 'node:test';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { mkdirSync, realpathSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { normalizeRemote, projectId, readUserId, resolveIdentity } from './identity.ts';
import { git } from './store.ts';
import { tmp } from './test-helpers.ts';
test('missing Station identity generates one stable id in the loop store; an invalid present identity fails', () => {
const store = tmp('identity-store');
const missing = join(tmp('station-home'), 'identity.json');
const first = readUserId(store, missing);
assert.ok(first.length > 0);
assert.equal(readUserId(store, missing), first, 'the generated id is reused');
const invalid = join(tmp('station-home'), 'identity.json');
writeFileSync(invalid, '{}\n');
assert.throws(() => readUserId(store, invalid), /missing user_cuid/);
});
// Identity: remote host/org/repo, else configured name, else user-level ---
test('normalizeRemote folds scp and https to host/org/repo, drops .git', () => {
assert.equal(normalizeRemote('git@github.com:example/project.git'), 'github.com/example/project');
assert.equal(normalizeRemote('https://github.com/example/project.git'), 'github.com/example/project');
assert.equal(normalizeRemote('git@github.com:example/project'), 'github.com/example/project');
assert.equal(normalizeRemote(undefined), undefined);
});
test('projectId: remote wins, else a configured name for the directory', () => {
assert.equal(projectId('/any', 'git@github.com:example/project.git', {}), 'github.com/example/project');
assert.equal(projectId('/srv/notes', undefined, { '/srv/notes': 'my-notes' }), 'my-notes');
});
test('projectId derives a stable dir id from a non-git path or an origin-less work-tree top, while empty cwd stays user-level', () => {
const plain = tmp('identity-plain');
const repo = tmp('identity-originless');
const nested = join(repo, 'packages', 'one');
git(repo, ['init', '--quiet']);
mkdirSync(nested, { recursive: true });
const dirId = (path: string) => `dir:${createHash('sha256').update(realpathSync(path)).digest('hex').slice(0, 16)}`;
assert.equal(projectId(plain, undefined, {}), dirId(plain));
assert.equal(projectId(plain, undefined, {}), projectId(plain, undefined, {}), 'the same path is stable');
assert.equal(projectId(nested, undefined, {}), dirId(repo), 'all directories in one origin-less work tree share its top-level id');
assert.equal(projectId('', undefined, {}), 'user-level');
});
test('resolveIdentity carries the kind, the same source harness, and a path-derived project when no remote', () => {
const cwd = tmp('identity-resolve');
const claude = resolveIdentity({ user_id: 'u', harness: 'claude-code', cwd, project_names: {} });
assert.equal(claude.project_id, `dir:${createHash('sha256').update(realpathSync(cwd)).digest('hex').slice(0, 16)}`);
assert.equal(claude.agent_id, 'claude-code');
assert.equal(claude.source_harness, 'claude-code');
const codex = resolveIdentity({ user_id: 'u', harness: 'codex', cwd: '/x', remote: 'git@github.com:example/project.git', project_names: {}, originator: 'codex_exec' });
assert.equal(codex.project_id, 'github.com/example/project');
assert.equal(codex.originator, 'codex_exec');
});
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 472k | Updated | Claude CodeCodex | Unverified | Install |
| 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: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| 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 available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |