matthewwong525/WongStack / .agents/plugins/memory
memory
Verifiedscripts/lib/machine-id.mjs
View on GitHub// One private installation identity per OS user. Publish a complete file exclusively:
// simultaneous first starts either win the hard link or read the winner's complete ID.
import { randomUUID } from 'node:crypto';
import { chmodSync, linkSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { homedir } from 'node:os';
import { join } from 'node:path';
export const MACHINE_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
const CHMOD_REFUSED = new Set(['EPERM', 'EACCES', 'EROFS']);
export function machineIdFile(environment = process.env) {
const userHome = environment.HOME || environment.USERPROFILE || homedir();
const data = process.platform === 'win32' ? environment.LOCALAPPDATA || join(userHome, 'AppData', 'Local')
: environment.XDG_DATA_HOME || join(userHome, '.local', 'share');
return join(data, 'wongstack', 'machine-id');
}
export function machineId(file = machineIdFile()) {
const read = () => {
const id = readFileSync(file, 'utf8').trim();
if (!MACHINE_ID.test(id)) throw new Error(`Invalid WongStack machine identity at ${file}; restore the original file or ask the admin. Ownership was not changed.`);
// A sandbox (such as Codex's background run) may refuse the re-chmod; the file was made 0600, so read on.
try { chmodSync(file, 0o600); } catch (error) { if (!CHMOD_REFUSED.has(error.code)) throw error; }
return id;
};
try { return read(); } catch (error) { if (error.code !== 'ENOENT') throw error; }
mkdirSync(join(file, '..'), { recursive: true, mode: 0o700 });
const temporary = `${file}.${process.pid}.${randomUUID()}.tmp`;
try {
writeFileSync(temporary, `${randomUUID()}\n`, { flag: 'wx', mode: 0o600 });
try { linkSync(temporary, file); } catch (error) { if (error.code !== 'EEXIST') throw error; }
return read();
} finally { rmSync(temporary, { force: true }); }
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |