Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(guards): make the documented push remote true on every clone, not just this one

nirholas50e8b8dd2037
diff --git a/CLAUDE.md b/CLAUDE.md
index 94905f66a..b34292071 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -245,6 +245,8 @@ Rules:
- `threews` → `https://github.com/nirholas/three.ws` (canonical source of truth, the ONLY push and pull/fetch target)
- `threeD` → `https://github.com/nirholas/3D-Agent` (retired mirror; its `main` has diverged with foreign history)
+Git remotes are local config and cannot be committed, so a fresh clone only has `origin`: `postinstall` adds the `threews` remote automatically when it is missing (`scripts/setup-git-hooks.mjs`), and `npm run check:claude` fails if the documented push target does not resolve. Neither ever creates `threeD`.
+
When the user asks you to push (or to commit + push): `git push threews main`. Owner decision 2026-07-07: work happens on three.ws only; the 3D-Agent mirror is no longer kept in sync. Never force-push without an explicit request.
**NEVER run `git pull`, `git fetch`, or `git merge` from `threeD`, and never push to it.** Pulling from `threeD` merges foreign history into this repo and has caused destructive README overwrites. Do not do it under any circumstances, even to resolve conflicts or sync state.
diff --git a/scripts/setup-git-hooks.mjs b/scripts/setup-git-hooks.mjs
index 91be3a92b..c671dffcc 100644
--- a/scripts/setup-git-hooks.mjs
+++ b/scripts/setup-git-hooks.mjs
@@ -79,6 +79,40 @@ try {
hooksDir = path.resolve(root, hooksDir);
const hookPath = path.join(hooksDir, 'pre-push');
+// Ensure the remote CLAUDE.md tells agents to push to actually exists.
+//
+// A clone names its remote `origin`, but CLAUDE.md's push instruction is
+// `git push threews main`, so on a fresh clone that command fails at exactly the
+// moment the owner asked to ship (observed in this worktree on 2026-07-30). Git
+// remotes are local config and cannot be committed, so the only way to make the
+// documented command true everywhere is to re-derive it here on every install.
+//
+// Deliberately narrow: it adds ONLY the push target named in the doc, only when
+// that name is absent, and only at the URL the doc records. It never edits or
+// removes an existing remote, and it can never create the retired mirror, which
+// CLAUDE.md forbids fetching from. Runs before the hook logic below because that
+// path exits early once the hook is current.
+function ensureDocumentedRemote() {
+ const docPath = path.join(root, 'CLAUDE.md');
+ if (!existsSync(docPath)) return;
+ const doc = readFileSync(docPath, 'utf8');
+ const target = doc.match(/git push ([A-Za-z0-9_-]+) main/)?.[1];
+ if (!target) return;
+ const url = doc.match(new RegExp(`^-\\s+\`${target}\`\\s*(?:→|->)\\s*\`(https?://[^\`]+)\``, 'm'))?.[1];
+ if (!url) return;
+ const existingRemotes = execFileSync('git', ['remote'], { cwd: root, encoding: 'utf8' }).split('\n').filter(Boolean);
+ if (existingRemotes.includes(target)) return;
+ execFileSync('git', ['remote', 'add', target, url], { cwd: root, stdio: ['ignore', 'ignore', 'pipe'] });
+ console.log(`[setup-git-hooks] added the \`${target}\` remote (${url}) that CLAUDE.md documents as the push target`);
+}
+
+try {
+ ensureDocumentedRemote();
+} catch (err) {
+ // Never fail an install over this; the hook is the load-bearing half.
+ console.error(`[setup-git-hooks] could not verify the documented git remote: ${err.message}`);
+}
+
const existing = existsSync(hookPath) ? readFileSync(hookPath, 'utf8') : '';
if (existing.includes(MARKER)) {
if (existing === HOOK) process.exit(0); // current version already installed
diff --git a/tests/setup-git-hooks.test.js b/tests/setup-git-hooks.test.js
index d1b1b961f..af169317e 100644
--- a/tests/setup-git-hooks.test.js
+++ b/tests/setup-git-hooks.test.js
@@ -197,6 +197,86 @@ describe('setup-git-hooks (installer)', () => {
});
});
+describe('setup-git-hooks (documented remote)', () => {
+ // Git remotes are local config and cannot be committed, so a fresh clone has
+ // only `origin` while CLAUDE.md's instruction is `git push threews main`. That
+ // command failed in this worktree on 2026-07-30. The installer re-derives the
+ // documented target so the instruction is true on every machine, which also
+ // keeps check:claude from red-flagging an innocent clone.
+ const REMOTE_DOC = [
+ '### Remotes',
+ '',
+ '- `threews` -> `https://github.com/nirholas/three.ws`',
+ '- `threeD` -> `https://github.com/nirholas/3D-Agent`',
+ '',
+ 'When the user asks you to push: `git push threews main`.',
+ '',
+ ].join('\n');
+
+ /** A repo with a CLAUDE.md remote table and only an `origin` remote, like a clone. */
+ function cloneLikeRepo(name, doc = REMOTE_DOC) {
+ const dir = join(sandbox, name);
+ mkdirSync(dir, { recursive: true });
+ git(dir, ['init', '-q']);
+ stageScripts(dir);
+ writeFileSync(join(dir, 'CLAUDE.md'), doc);
+ git(dir, ['remote', 'add', 'origin', 'https://github.com/nirholas/three.ws']);
+ return dir;
+ }
+
+ const remotesOf = (dir) => git(dir, ['remote']).split('\n').filter(Boolean);
+
+ it('adds the push target a clone does not have', () => {
+ const dir = cloneLikeRepo('clone-like');
+ const { code, out } = install(dir);
+ expect(code).toBe(0);
+ expect(out).toContain('added the `threews` remote');
+ expect(remotesOf(dir)).toContain('threews');
+ expect(git(dir, ['remote', 'get-url', 'threews']).trim()).toBe('https://github.com/nirholas/three.ws');
+ });
+
+ it('never creates the retired mirror, which the doc forbids fetching from', () => {
+ const dir = cloneLikeRepo('no-mirror');
+ install(dir);
+ // `threeD` is in the documented table but is not the push target, so it must
+ // not be created. Fetching from it has corrupted this repo's history before.
+ expect(remotesOf(dir)).not.toContain('threeD');
+ });
+
+ it('leaves an existing remote of that name untouched', () => {
+ const dir = cloneLikeRepo('existing-remote');
+ git(dir, ['remote', 'add', 'threews', 'https://github.com/someone/fork']);
+ install(dir);
+ // Repointing somebody's remote is how a push ends up at the wrong repo.
+ // Surfacing the mismatch is check:claude's job, not this script's.
+ expect(git(dir, ['remote', 'get-url', 'threews']).trim()).toBe('https://github.com/someone/fork');
+ });
+
+ it('is idempotent across installs', () => {
+ const dir = cloneLikeRepo('remote-idempotent');
+ install(dir);
+ const { out } = install(dir);
+ expect(out).not.toContain('added the');
+ expect(remotesOf(dir).filter((r) => r === 'threews')).toHaveLength(1);
+ });
+
+ it('does nothing when the doc names no push target', () => {
+ const dir = cloneLikeRepo('no-target', '# No remote table and no push instruction here.\n');
+ const { code } = install(dir);
+ expect(code).toBe(0);
+ expect(remotesOf(dir)).toEqual(['origin']);
+ });
+
+ it('still installs the hook when the remote is already correct', () => {
+ // The hook is the load-bearing half; remote setup must never short-circuit it.
+ const dir = cloneLikeRepo('hook-still-installed');
+ git(dir, ['remote', 'add', 'threews', 'https://github.com/nirholas/three.ws']);
+ const { code } = install(dir);
+ expect(code).toBe(0);
+ expect(existsSync(join(dir, '.git', 'hooks', 'pre-push'))).toBe(true);
+ });
+});
+
describe('pre-push hook (behavior)', () => {
let baseSha;
let cleanSha;